Raised This Month: $ Target: $400
 0% 

how to do off/on in the menu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
LaranjoBreks
Junior Member
Join Date: Aug 2020
Location: Rio de Janeiro, Rio de j
Old 08-22-2020 , 09:01   Re: how to do off/on in the menu
Reply With Quote #7

Quote:
Originally Posted by Shadows Adi View Post
Read all COMMENTS.

Code:
#include <amxmodx> new bool:g_bDisabled[MAX_PLAYERS + 1]; /* USE THIS ONLY YOU DON'T HAVE A NATIVE TO CHECK IF THE SOUNDS ARE ON OR OFF (Not Recommanded)*/ new bool:g_bPressed[MAX_PLAYERS + 1]; public plugin_init() {     register_plugin("Server Menu", "0.1", "maFFyoZZyk");     register_clcmd("say /menu", "CmdMenu");     register_clcmd("menu", "CmdMenu");     register_clcmd("nightvision", "CmdMenu"); } public client_putinserver(id) {     g_bDisabled[id] = false; /*Or true, your choise...*/     g_bPressed[id] = true; } public CmdMenu(id) {         new temp[64];                                           /* Create a temporary array which will hold the menu's infos. */     formatex(temp, charsmax(temp), "\wМеню");               /* Storing the menu title infos in our temporary array. */     new g_iMenu = menu_create(temp, "MenuHandler");             /* Assigning the temp to the menu_create native */         formatex(temp, charsmax(temp), "\r[\yAnew\r]");             /* Storing a menu item text in our var */     menu_additem(g_iMenu, temp, "1");                           /* Assigning our text into menu_additem */      /* This will be the first item from menu */         formatex(temp, charsmax(temp), "\r[\yReset score\r]");      /* Continue to assign the next text in the rest of menu_additem natives... */     menu_additem(g_iMenu, temp, "2");                           /* This will be the second item from menu */         formatex(temp, charsmax(temp), "\r[\yTest \rVIP]");         /* Continue to assign the next text in the rest of menu_additem natives... */     menu_additem(g_iMenu, temp, "3");                           /* This will be the third item from menu */         formatex(temp, charsmax(temp), "\r[\yVote for Ban\r]");     menu_additem(g_iMenu, temp, "4");                           /* This will be the fourth item from menu */         formatex(temp, charsmax(temp), "\r[\yGrenade Sounds\r] %s", g_bDisabled[id] ? /*The Boolean is true, so we make our string prints \rON*/"\y[\rON\y]" : /*Boolean is false, changing it to \rOFF*/"\y[\rOFF\y]");     menu_additem(g_iMenu, temp, "5");                           /* This will be the fifth item from menu */         formatex(temp, charsmax(temp), "\r[\yMute\r]");     menu_additem(g_iMenu, temp, "6");                           /* This will be the sixth item from menu */         formatex(temp, charsmax(temp), "\r[\yAdmin Menu\r]");     menu_additem(g_iMenu, temp, "7");                           /* This will be the seventh item from menu */         formatex(temp, charsmax(temp), "\r[\yTop 15\r]");               menu_additem(g_iMenu, temp, "8");                           /* This will be the eighth item from menu */         menu_setprop(g_iMenu, MPROP_NEXTNAME, "NEXT");     menu_setprop(g_iMenu, MPROP_BACKNAME, "BACK");     menu_setprop(g_iMenu, MPROP_EXITNAME, "EXIT");         menu_setprop(g_iMenu, MPROP_EXIT, MEXIT_ALL);         menu_display(id, g_iMenu); } public MenuHandler(id, menu, item) {     if (item == MENU_EXIT)     {         menu_destroy(menu);         return PLUGIN_HANDLED;     }         new data[7];     new dummy;     new name[32];     menu_item_getinfo(menu, item, dummy, data, charsmax(data), name, charsmax(name), dummy);         switch (str_to_num(data))     {         case 1: client_cmd(id, "say /anew");         case 2: client_cmd(id, "say /rs");         case 3: client_cmd(id, "say /viptest");         case 4: client_cmd(id, "say /voteban");         case 5:         {             if (g_bDisabled[id])             {                 if (g_bPressed[id])                 {                     client_cmd(id, "say /gsound");                     g_bDisabled[id] = false;                 }                 else                 {                     client_cmd(id, "say /gsound");                     g_bDisabled[id] = true;                 }             }             else             {                 client_cmd(id, "say /gsound");                 g_bDisabled[id] = false;             }         }         case 6: client_cmd(id, "say /mute");         case 7:client_cmd(id, "amxmodmenu");         case 8: client_cmd(id, "say /top15");     }     menu_destroy(menu);     return PLUGIN_HANDLED; }

in this case of your example is g_bDisabled being used as an on / off button and not to lock the menu choices?
LaranjoBreks is offline
 



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


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