Jump to content
  • 0

Dynamic Menu help


Lord Ganja

Question


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

Hi. Im using this dynamic menu for my custom enchantment. But it seems getting debugs whenever it runs into this script. I can't seem to figure out whats the problem.

mes .npc$;
mes "Please select an equipment from the menu."; next;
while(set(.@a,.@a+1)<=.e_len) {
	if(getequipid(.@a)>-1) {
		if(getiteminfo(getequipid(.@a),2)!=4) {
		    set .@menu$, .@menu$+.eqp$[.@a-1]+"- [^0000FF"+getitemname(getequipid(.@a))+"^000000]:";
		    set(.@menu[getarraysize(.@menu)],.@a);
		}
	}
}

OnInit:
setarray .eqp$, "Upper Headgear", "Armor", "Left Hand", "Right Hand", "Garment","Shoes", "Accessory1", "Accessory2", "Mid Headgear", "Low Headgear";
set      .e_len , getarraysize(.eqp$);

Debugs:

[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
[Debug]: Source (NPC): Ganja Runes#1 at turbo_room (76,110)
Edited by Lord Ganja
Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

	if (getequipid(.@a) > -1) {

For checking if they have an item equipped in that slot, you should use getequipisequiped.

Even though 'getequipid' returns -1 if no item is equipped, that is considered a failure of the script command and that's why the map-server shows the debug message.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   7
  • Joined:  01/02/12
  • Last Seen:  


set .@menu$, "";

for(set .@i,0; .@i < getarraysize(.eqp$); set .@i, .@i +1){

if(.eqp$[.@i] != "") {

set .@menu$, .@menu$ + "- [^0000FF"+getitemname(getequipid(.@i))+"^000000]";

set .@menu$, .@menu$ + ":";

}

}

set @selected,select(.@menu$)-1;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

	set .@menu$, "";
	for(set .@i,0; .@i < getarraysize(.eqp$); set .@i, .@i +1){
		if(.eqp$[.@i] != "") {
			set .@menu$, .@menu$ + "- [^0000FF"+getitemname(getequipid(.@i))+"^000000]";
			set .@menu$, .@menu$ + ":";
		}
	}		
	set @selected,select(.@menu$)-1;

 

I forgot to mention. Weapons are excluded. It shouldn't put weapons on the menu if weapon is equipped. How would I do that?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   7
  • Joined:  01/02/12
  • Last Seen:  

 

	set .@menu$, "";
	for(set .@i,0; .@i < getarraysize(.eqp$); set .@i, .@i +1){
		if(.eqp$[.@i] != "") {
			set .@menu$, .@menu$ + "- [^0000FF"+getitemname(getequipid(.@i))+"^000000]";
			set .@menu$, .@menu$ + ":";
		}
	}		
	set @selected,select(.@menu$)-1;

 

I forgot to mention. Weapons are excluded. It shouldn't put weapons on the menu if weapon is equipped. How would I do that?

 

Oh, sorry i don't know ;) you can add check

 if (getequipisequiped(EQI_HAND_L)) {mes "uneqip weapon first"; close;}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

I tried this script for it exclude weapons, but im having debugs and i don't know why

if( getiteminfo(getequipid(.@i),2) == 4 )
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

 

	if (getequipid(.@a) > -1) {

For checking if they have an item equipped in that slot, you should use getequipisequiped.

Even though 'getequipid' returns -1 if no item is equipped, that is considered a failure of the script command and that's why the map-server shows the debug message.

 

What should I use so it won't display weapons on the menu, even if a weapon is equipped?

 

EDIT:

Nvmind, figured it out. Thanks for your help :)

Edited by Lord Ganja
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...