Jump to content
  • 0

Question

Posted

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

4 answers to this question

Recommended Posts

  • 0
Posted

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
  • 0
Posted

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!

  • 0
Posted
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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...