AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weird menu bug (https://forums.alliedmods.net/showthread.php?t=94245)

zacky 06-08-2009 17:29

Weird menu bug
 
Hi every1, it becomes an weird menu bug in my plugin, and i cant find an error.

This is how it looks in-game:
[IMG]http://img37.**************/img37/6712/menubugr.jpg[/IMG]

And heres the code:
PHP Code:

new mPsArmorShop menu_create("\rArmor \wShop""handlePsArmorShop");

new 
item[64];
formatex(item63"100 Armor on spawn \r(You have this all the time) \y- \r%d \wpoints"get_pcvar_num(gCvarAlwaysHundredArmorCost));
menu_additem(mPsArmorShopitem"1");

new 
item1[64];
formatex(item163"10 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorOneCost));
menu_additem(mPsArmorShopitem1"2");

new 
item2[64];
formatex(item263"20 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorTwoCost));
menu_additem(mPsArmorShopitem2"3");

new 
item3[64];
formatex(item363"30 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorThreeCost));
menu_additem(mPsArmorShopitem3"4");

new 
item4[64];
formatex(item463"40 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorFourCost));
menu_additem(mPsArmorShopitem4"5");

new 
item5[64];
formatex(item563"50 Extra Armor \r(CT) \y- \r%d \wpoints^n"get_pcvar_num(gCvarCtArmorFiveCost));
menu_additem(mPsArmorShopitem5"6");

new 
item6[64];
formatex(item663"10 Extra Armor \r(T) \y- \r%d \wpoints"get_pcvar_num(gCvarTArmorOneCost));
menu_additem(mPsArmorShopitem6"7");

new 
item7[64];
formatex(item763"20 Extra Armor \r(T) \y- \r%d \wpoints"get_pcvar_num(gCvarTArmorTwoCost));
menu_additem(mPsArmorShopitem7"8");

new 
item8[64];
formatex(item863"30 Extra Armor \r(T) \y- \r%d \wpoints"get_pcvar_num(gCvarTArmorThreeCost));
menu_additem(mPsArmorShopitem8"9");

new 
item9[64];
formatex(item963"40 Extra Armor \r(T) \y- \r%d \wpoints"get_pcvar_num(gCvarTArmorFourCost));
menu_additem(mPsArmorShopitem9"10");

new 
item10[64];
formatex(item1063"50 Extra Armor \r(T) \y- \r%d \wpoints"get_pcvar_num(gCvarTArmorFiveCost));
menu_additem(mPsArmorShopitem10"11");

menu_setprop(mPsArmorShopMPROP_EXITMEXIT_ALL);
menu_setprop(mPsArmorShopMPROP_EXITNAME"Close");
menu_display(idmPsArmorShop0); 

Thanks
-zacky

Jon 06-08-2009 18:14

Re: Weird menu bug
 
I dont know if this will solve your problem, but you don't need to create a new variable for each menuitem. You can re-format the item variable instead of creating a new one.

PHP Code:

new item[64]; 
formatex(item63"100 Armor on spawn \r(You have this all the time) \y- \r%d \wpoints"get_pcvar_num(gCvarAlwaysHundredArmorCost)); 
menu_additem(mPsArmorShopitem"1"); 

new 
item1[64]; 
formatex(item163"10 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorOneCost)); 
menu_additem(mPsArmorShopitem1"2"); 

// Change to -> 

new item[64]; 
formatex(item63"100 Armor on spawn \r(You have this all the time) \y- \r%d \wpoints"get_pcvar_num(gCvarAlwaysHundredArmorCost)); 
menu_additem(mPsArmorShopitem"1"); 

formatex(item63"10 Extra Armor \r(CT) \y- \r%d \wpoints"get_pcvar_num(gCvarCtArmorOneCost)); 
menu_additem(mPsArmorShopitem"2"); 

Also the whole thing could probably been done with a loop, but if you want a cvar for each option that is up to you.

Exolent[jNr] 06-08-2009 19:18

Re: Weird menu bug
 
Code:
new item[64]; // 63 characters long //100 Armor on spawn \r(You have this all the time) \y- \r10000 \wpoints //123456789012345678901234567890123456789012345678901234567890123

Therefore, the last character is a '\' which could be messing up your menus.
Increase the array size to hold the whole string.

zacky 06-09-2009 14:04

Re: Weird menu bug
 
EDIT: xPaw found error, i forgot to change formatex(item, 63 to: formatex(item, 127

joaquimandrade 06-09-2009 14:10

Re: Weird menu bug
 
Quote:

Originally Posted by zacky (Post 844992)
EDIT: xPaw found error, i forgot to change formatex(item, 63 to: formatex(item, 127

Use charsmax instead. You can't get wrong with it.


All times are GMT -4. The time now is 13:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.