Jump to content

Question

Posted

script commands reference

*setnpcdisplay("<npc name>", "<display name>", <class id>, <size>)
*setnpcdisplay("<npc name>", "<display name>", <class id>)
*setnpcdisplay("<npc name>", "<display name>")
*setnpcdisplay("<npc name>", <class id>)

Changes the display name and/or display class of the target NPC.
Returns 0 is successful, 1 if the NPC does not exist.
Size is 0 = normal 1 = small 2 = big.
problem:

after change display name with setnpcdisplay, strnpcinfo(0) can't be used any more. is there a way to make script below working as intended

 

prontera,150,150,0	script	display_test	112,{
	switch(select("~ Change Display:~ Change to Original")) {
		case 1:
			.j++;
			//setnpcdisplay("<npc name>", "<display name>", <class id>)
			if ((.j % 2) == 0)
				setnpcdisplay(strnpcinfo(0), "Display "+.@j, 113);
			else
				setnpcdisplay(strnpcinfo(0), "Display "+.@j, 114);
			npctalk "Display sprite and name changed strnpcinfo(0): "+strnpcinfo(0);
			end;
		case 2:
			.j = 0;
			npctalk "Display reverted to origin";
			setnpcdisplay(strnpcinfo(0), "display_test", 112);
			end;
	}
}

In Game Result

screenAlba007.jpg

screenAlba008.jpg

screenAlba009.jpg

screenAlba010.jpg

7 answers to this question

Recommended Posts

Posted (edited)

I noticed that you're using two types of variables for "j." One is a permanent npc variable ".j" and a temporary one, ".@j"

Plus you did not set the initial value of your variable for which I added an "OnInit" block.

Try this.Not tested.

prontera,150,150,0	script	display_test	112,{
	switch(select("~ Change Display:~ Change to Original")) {
		case 1:
			.j++;
			//setnpcdisplay("<npc name>", "<display name>", <class id>)
			if ((.j % 2) == 0)
				setnpcdisplay(strnpcinfo(0), "Display "+.j, 113);
			else
				setnpcdisplay(strnpcinfo(0), "Display "+.j, 114);
			npctalk "Display sprite and name changed strnpcinfo(0): "+strnpcinfo(0);
			end;
		case 2:
			.j = 0;
			npctalk "Display reverted to origin";
			setnpcdisplay(strnpcinfo(0), "display_test", 112);
			end;
	}

OnInit:
   set .j, 0;
end;
}
Edited by jezznar
Posted (edited)

Well as far as my scripting SOP is concerned,I put breaks in switch cases and default for fail-safe. And as I've also said I think you also missed the "OnInit" part for which your script, IMO, is missing to have it working correctly. I'll check it out in the next few mins.

Edited by jezznar
Posted

If i'm not mistake, the setnpcdisplay is like a fakename, arent save in npc data.

 

You can hold the actual name in a variable?

i kind of forgoten if i have done it or yet, so i have to save the orignal npc name into variable, i will try that, because strnpcinfo storing the fakename if it was

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