Jump to content
  • 0

Array trouble


jasonch

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

Hello guys! I hope you all a good day!

So I want a Npc to display(dispbottom or mes command) a certain variable on an array BASED on the permanent value attached on the character. Here's the fake short version of my script:

 

function	script	Fake_Func	{
		dispbottom "Test";
		dispbottom ""+.tmenu$[getd(Var1)]+"";
		end;
		}



prontera,153,193,6	script	Fake_Npc	123,{

menu	""+.tmenu$[1]+"",-,
		""+.tmenu$[2]+"",T1,
		"Info",T2;
					Var1 = 1; end;
				T1: Var1 = 2; end;
				T2: Fake_Func;
				
OnInit:
	setarray .tmenu$[1],"Dog","Cat";
}

 

When the char chooses "Dog" in the menu, 1 will be registered to "Var1". And when the char chooses "Info" in the menu, I want it to display the word "Dog" on the bottom.

The getd command ain't helping me. Please help me guys! Thank you!!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  657
  • Reputation:   662
  • Joined:  11/12/12
  • Last Seen:  

Hmm, I believe the following would be easier to maintain:

prontera,153,193,6	script	Fake_Npc	123,{
	.@menu$ = implode(.tmenu$, ":");
	.@option = select(.@menu$ + ":Info") - 1;
	
	if (.@option < getarraysize(.tmenu$)) {
		Var1 = .@option;
	}
	else {
		dispbottom "Test";
		dispbottom .tmenu$[Var1];
	}
	
	end;
OnInit:
	setarray .tmenu$, "Dog", "Cat";
	end;
}

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

I got it to work guys. I just put the function script inside the npc script:

prontera,153,193,6	script	Fake_Npc	123,{
function Fake_Func;
function Fake_Func { <code> }
}

And that's it, it worked!

Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

function	script	Fake_Func	{
		dispbottom "Test";
		dispbottom ""+ getvariableofnpc(.tmenu$[var1],"Fake_Npc") +"";
		end;
		}

prontera,153,193,6	script	Fake_Npc	123,{
menu	""+.tmenu$[1]+"",-,
		""+.tmenu$[2]+"",T1,
		"Info",T2;
					var1 = 1; end;
				T1: var1 = 2; end;
				T2: Fake_Func;
				
OnInit:
	setarray .tmenu$[1],"Dog","Cat";
	end;
}

you can do like that if you want the function outside the npc

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  29
  • Reputation:   1
  • Joined:  12/31/11
  • Last Seen:  

@Tokei Yes! Totally using this. Thanks guys!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...