Jump to content
  • 0

Randomic Menu


Question

Posted (edited)

Hello guys,

I've got this piece of code here:

getinventorylist; 
	for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){	
        
	    set .@itemtype, getiteminfo(@inventorylist_id[.@i], ITEMINFO_SUBTYPE);
	    set .@itemid, getiteminfo(@inventorylist_id[.@i], ITEMINFO_ID);

        if((.@itemtype == CARD_ENCHANT)){
                    set .@menu$, .@menu$ + "- Enchant " + getitemname(@inventorylist_id[.@i]) + "";
					set .@menu$, .@menu$ + ":";
					setarray .@rune[.@i], .@itemid;
					mes ""+.@i+" - "+.@rune[.@i]+"";
        } 
	}

I got the Menu created right:

image.png.4493253bdb2617a06ebe7a7f037b1925.png

But now i need to select the index from menu to create a specific call.

So i setup this:

mes "[Enchant Rune Book]";
	mes "I see you possess some of my treasures.";
	mes "What do you desire?";
	.@eqi = select(.@menu$) -1;
	.@runeId = .@rune[.@eqi];

	dispbottom ""+ .@eqi +", "+ .@runeId +"";


image.png.b5f894f41708214b434fca0afebd795f.png

Once i select the first 3 indexes, i got the right item ID. On the 4th index i got the problem. It's like the index jumped for no reason here, because the 5th index got the 4th ID.

Someone can give me a hint how to make this work? Thank you

Edited by Banned

3 answers to this question

Recommended Posts

  • 0
Posted (edited)
18 hours ago, Rynbef said:

Try use no -1.

 

Rynbef~

Can you be more specific? I'm already using it on menu selection.

 

Edit: i've read you comment wrong. But i already test without -1 and ir doesnt work either

This is the NPC:

prontera,150,150,4	script	Enchant Rune Book#book	4_VR_BOOK_YELLOW,{
	
	mes "[Enchant Rune Book]";

	if (checkweight(1201,1) == 0){
		mes "- Wait a minute !! -";
		mes "- Currently you're carrying -";
		mes "- too many items with you. -";
		mes "- Please try again -";
		mes "- after you lose some weight. -";
		close;
	}

	mes "Those who dare to read the ancient scriptures shall face the consequences.";
	next;
	mes "[Enchant Rune Book]";
	mes "The Magic of the Runes is alive once more.";
	next;
	getinventorylist; 
	for(set .@i,0; .@i < @inventorylist_count; set .@i,.@i+1){	
        
	    set .@itemtype, getiteminfo(@inventorylist_id[.@i], ITEMINFO_SUBTYPE);
	    set .@itemid, getiteminfo(@inventorylist_id[.@i], ITEMINFO_ID);

        if((.@itemtype == CARD_ENCHANT)){
                    set .@menu$, .@menu$ + "- Enchant " + getitemname(@inventorylist_id[.@i]) +"";
					set .@menu$, .@menu$ + ":";
					setarray .@rune[.@i], .@itemid;
					//mes ""+.@i+" - "+.@rune[.@i]+"";
        } 
	}
	set .@menu$, .@menu$ + "- Cancel";

	mes "[Enchant Rune Book]";
	mes "I see you possess some of my treasures.";
	mes "What do you desire?";
	.@eqi = select(.@menu$) -1;
	if(.@eqi > 2){
		set .@eqi, .@eqi+1;
	}
	.@runeId = .@rune[.@eqi];

	dispbottom ""+ .@eqi +", "+ .@runeId +"";
	
	switch(.@runeId){
        case 4767: callfunc("f_EnchantRune", 4767, EQI_HEAD_MID, 3); break;
        case 4842: callfunc("f_EnchantRune", 4842, EQI_HAND_R, 3); break;
        case 4892: callfunc("f_EnchantRune", 4892, EQI_HAND_L, 1); break;
		case 35000: callfunc("f_EnchantRune", 35000, EQI_HAND_R, 1); break;
        case 35001: callfunc("f_EnchantRune", 35001, EQI_HAND_R, 2); break;
        case 35002: callfunc("f_EnchantRune", 35002, EQI_HAND_R, 3); break;
        case 35003: callfunc("f_EnchantRune", 35003, EQI_HEAD_MID, 3); break;
        case 35004: callfunc("f_EnchantRune", 35004, EQI_ARMOR, 1); break;
        case 35005: callfunc("f_EnchantRune", 35005, EQI_ARMOR, 2); break;
        case 35006: callfunc("f_EnchantRune", 35006, EQI_ARMOR, 3); break;
		default:
			next;
			mes "[Enchant Rune Book]";
			mes "Get out of here";
			close;
	}

	
	end;


}

 

Edited by Banned

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