Raised This Month: $51 Target: $400
 12% 

how to do off/on in the menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anakonda001
Member
Join Date: Jul 2020
Old 08-21-2020 , 14:41   how to do off/on in the menu
Reply With Quote #1

hello everyone as do in 5 point of off/on grenade sound, that would when clicked on point the on/off (and that would be written there on or off sound)

Code:
menu_additem(g_iMenu, "\r[\ysound grenade\r]", "5");
Code:
#include <amxmodx>

new g_iMenu;

public plugin_init() {
    register_plugin("Server Menu", "0.1", "maFFyoZZyk");
    register_clcmd("say /menu", "CmdMenu");
    register_clcmd("menu", "CmdMenu");
    register_clcmd("nightvision", "CmdMenu");
}

public plugin_cfg() {
    g_iMenu = menu_create("\wМеню", "MenuHandler")
    menu_additem(g_iMenu, "\r[\yanew\r]", "1");
    menu_additem(g_iMenu, "\r[\yreset score\r]", "2");
    menu_additem(g_iMenu, "\r[\ytest \rVIP]", "3");
    menu_additem(g_iMenu, "\r[\yvote for ban\r]", "4");
    menu_additem(g_iMenu, "\r[\ysound grenade\r]", "5");
    menu_additem(g_iMenu, "\r[\ymute\r]", "6");
    menu_additem(g_iMenu, "\r[\yadmin menu\r]", "7");
    menu_additem(g_iMenu, "\r[\ytop 15\r]", "8");
    
    menu_setprop(g_iMenu, MPROP_NEXTNAME, "further");
    menu_setprop(g_iMenu, MPROP_BACKNAME, "back");
    menu_setprop(g_iMenu, MPROP_EXITNAME, "exit");
    menu_setprop(g_iMenu, MPROP_EXIT,MEXIT_ALL);
}

public plugin_end() {
    menu_destroy(g_iMenu);
}

public CmdMenu(id) {
    menu_display(id, g_iMenu);
    return PLUGIN_HANDLED;
}

public MenuHandler(id, menu, item) {
    if (item == MENU_EXIT) {
        return;
    }
        
    new data[7];
    menu_item_getinfo(menu, item, .info = data, .infolen = charsmax(data));
    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: client_cmd(id, "say /gsound");
	case 6: client_cmd(id, "say /mute");
        case 7:client_cmd(id, "amxmodmenu");
	case 8: client_cmd(id, "say /top15");
    }
}
anakonda001 is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-21-2020 , 18:19   Re: how to do off/on in the menu
Reply With Quote #2

Create a boolean which holds MAX_PLAYER + 1 cells. After that, make the menu key to remember that selection by setting the boolean true or false. After all, you need to make your menu faster and make it holding some strings, the entire MENU needs to be made using a temporary text, example:
Code:
new temp[64] formatex(temp, charsmax(temp), "\wМеню") new menu = menu_create(temp, "MenuHandler") // the others menu items needs that too...
After all this =))), you use the condition operator to check if the bool is true or false:
Code:
g_bSomeBool[index] ? "/*Bool is True*/" : "/*Bool is False*/"
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-22-2020 , 04:01   Re: how to do off/on in the menu
Reply With Quote #3

I didn't understand anything
anakonda001 is offline
LaranjoBreks
Junior Member
Join Date: Aug 2020
Location: Rio de Janeiro, Rio de j
Old 08-22-2020 , 06:28   Re: how to do off/on in the menu
Reply With Quote #4

Quote:
Originally Posted by Shadows Adi View Post
Create a boolean which holds MAX_PLAYER + 1 cells. After that, make the menu key to remember that selection by setting the boolean true or false. After all, you need to make your menu faster and make it holding some strings, the entire MENU needs to be made using a temporary text, example:
Code:
new temp[64] formatex(temp, charsmax(temp), "\wМеню") new menu = menu_create(temp, "MenuHandler") // the others menu items needs that too...
After all this =))), you use the condition operator to check if the bool is true or false:
Code:
g_bSomeBool[index] ? "/*Bool is True*/" : "/*Bool is False*/"

at first glance to understand what you mean but in practice things are different I ask that please if you can guide us to do this so that we can understand once and for all, be recorded for us how to do it and never need third-party help
LaranjoBreks is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-22-2020 , 06:35   Re: how to do off/on in the menu
Reply With Quote #5

Quote:
Originally Posted by Shadows Adi View Post
Create a boolean which holds MAX_PLAYER + 1 cells.
here is the bool command from the plugin
Code:
new bool:g_bDisabled[MAX_PLAYERS + 1];
anakonda001 is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-22-2020 , 08:11   Re: how to do off/on in the menu
Reply With Quote #6

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; }
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-22-2020 , 08:37   Re: how to do off/on in the menu
Reply With Quote #7

1) the Off label does not change to On
2) you can still do that when you click on/off in this item, the menu itself does not close when you click

Last edited by anakonda001; 08-22-2020 at 08:40.
anakonda001 is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 08-22-2020 , 08:48   Re: how to do off/on in the menu
Reply With Quote #8

I said: USE THIS ONLY YOU DON'T HAVE A NATIVE TO CHECK IF THE SOUNDS ARE ON OR OFF (Not Recommanded).
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 08-22-2020 at 08:48.
Shadows Adi is offline
anakonda001
Member
Join Date: Jul 2020
Old 08-22-2020 , 08:53   Re: how to do off/on in the menu
Reply With Quote #9

Quote:
Originally Posted by Shadows Adi View Post
I said: USE THIS ONLY YOU DON'T HAVE A NATIVE TO CHECK IF THE SOUNDS ARE ON OR OFF (Not Recommanded).
I don't understand what it is
meaning from what you did, if I could in my menu make the inscription Grenade sound Off and there and leave

Last edited by anakonda001; 08-22-2020 at 09:00.
anakonda001 is offline
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 #10

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
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 00:48.


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