Jump to content
  • 0
jasonch

Array trouble

Question

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

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

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

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

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
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

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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.