AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   controling variables with menu (https://forums.alliedmods.net/showthread.php?t=230183)

GhostMan 11-21-2013 10:49

controling variables with menu
 
PHP Code:

new bool:option1bool:option2 

Quote:

Settings:
1. OPTION1 [OFF]
2. OPTION2 [OFF]

9. Start
0. Exit
How to generate such menu?

If OPTION1 [OFF] then option1 == false, iš [ON], then option1 == true. Same goes with option2. Also can change value of cvar multible times. Menu closes when you press 9 or 0.

fysiks 11-21-2013 11:40

Re: controling variables with menu
 
You simply need to format the string for the menu item based on the value of the boolean.

bcKq 11-21-2013 17:18

Re: controling variables with menu
 
PHP Code:

// option1
new szText[24];
formatex(szTextcharsmax(szText), "%s"option1 "OPTION1 [ON]" "OPTION1 [OFF]");
menu_additem(menuszText);
// option2
formatex(szTextcharsmax(szText), "%s"option2 "OPTION2 [ON]" "OPTION2 [OFF]");
menu_additem(menuszText); 


Blizzard_87 11-22-2013 05:42

Re: controling variables with menu
 
Quote:

Originally Posted by bcKq (Post 2063734)
PHP Code:

// option1
new szText[24];
formatex(szTextcharsmax(szText), "%s"option1 "OPTION1 [ON]" "OPTION1 [OFF]");
menu_additem(menuszText);
// option2
formatex(szTextcharsmax(szText), "%s"option2 "OPTION2 [ON]" "OPTION2 [OFF]");
menu_additem(menuszText); 


or simply this



Code:
// above plugin_init() new bool:option1[ 33 ], bool:option2[ 33 ]; // in menu function // option1 new szText[24]; formatex(szText, charsmax(szText), "OPTION1  [%s]", option1[ id ] ? "ON" : "OFF"); menu_additem(menu, szText); // option2 formatex(szText, charsmax(szText), "OPTION2  [%s]", option2[ id ] ? "ON" : "OFF"); menu_additem(menu, szText);

if you didnt index the boolean then there would be only one on/off for anyone using that.. then anyone could turn on/off the option.
this way you can set individual settings on each index.


All times are GMT -4. The time now is 23:12.

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