Jump to content
  • 0

setnpcdisplay help?


Litro Endemic

Question


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

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

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

ah.. my mistake, have fixed that but still the script is not working as intended, strnpcinfo(0) != NPC DIsplay Name after changing the name via setnpcdisplay, try it to reproduce the problem

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

try to add breaks after each case block

 

case 1:

    break;

case 2:

    break;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

and that is why ? break purpose is to get out of bracket, since I end the script correctly AFAIK im not sure why the script need break

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

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

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