Raised This Month: $ Target: $400
 0% 

Weird menu bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-08-2009 , 17:29   Weird menu bug
Reply With Quote #1

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
zacky is offline
Send a message via Skype™ to zacky
Jon
Veteran Member
Join Date: Dec 2007
Old 06-08-2009 , 18:14   Re: Weird menu bug
Reply With Quote #2

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.

Last edited by Jon; 06-08-2009 at 18:18.
Jon is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-08-2009 , 19:18   Re: Weird menu bug
Reply With Quote #3

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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
zacky
Senior Member
Join Date: Mar 2008
Location: Sweden
Old 06-09-2009 , 14:04   Re: Weird menu bug
Reply With Quote #4

EDIT: xPaw found error, i forgot to change formatex(item, 63 to: formatex(item, 127

Last edited by zacky; 06-09-2009 at 14:09.
zacky is offline
Send a message via Skype™ to zacky
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-09-2009 , 14:10   Re: Weird menu bug
Reply With Quote #5

Quote:
Originally Posted by zacky View Post
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.
__________________
joaquimandrade is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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