AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hiding menu options & Drop weapon [ Solved ] (https://forums.alliedmods.net/showthread.php?t=27110)

hip_hop_x 04-14-2006 20:13

Hiding menu options & Drop weapon [ Solved ]
 
1.How to hide the menu after a player chosed one option?

Code:
public giveArma(id, key) {     //This is the menu     if (key == 4)     {         }else if (key == 0){          give_item(id, "weapon_ak47")     engclient_cmd(id, "drop", "weapon_awp")     engclient_cmd(id, "drop", "weapon_m4a1")     client_print(id, print_chat, " Am ales 1 optiune")         } else if (key == 1) {          give_item(id, "weapon_m4a1")     engclient_cmd(id, "drop", "weapon_awp")     engclient_cmd(id, "drop", "weapon_ak47")     client_print(id, print_chat, " Am ales a 2 optiune")       } else if (key == 2) {          give_item(id, "weapon_usp")     engclient_cmd(id, "drop", "weapon_awp")     engclient_cmd(id, "drop", "weapon_ak47")     engclient_cmd(id, "drop", "weapon_m4a1")     client_print(id, print_chat, " Am ales a 3 optiune")       set_user_armor(id, 200)     }else if (key == 3){     give_item(id, "weapon_usp")     client_print(id, print_chat, " Am ales a 4 optiune")       } }

2.And how i can make a player drop weapon and cant pickup?
I used
Code:
engclient_cmd(id, "drop", "weapon_m4a1")
but the player will still can pickup that weapon after he droped.

VEN 04-15-2006 14:47

Try make weaponbox entity not solid.

hip_hop_x 04-28-2006 08:59

At the menu, any code to make an submenu unselectable ?

Please need help.

organizedKaoS 04-28-2006 14:52

For the menu, try making a global variable, ie, g_MenuDone[33].

On putinserver, assign every id g_MenuDone[id] = 0.

Do a check in the menu,
Code:
if(g_MenuDone[id])
checks if the player has g_MenuDone[id] 1, if its 1, stop the menu from showing to that player, if not, show the menu.

Everytime they make a selection, make the players id 1,
Code:
g_MenuDone[id] = 1

On every round end, reset the variable. So on round end, you should have something like
Code:
public reset(id)      {      g_MenuDone[id] = 0 }
That way on round start, everyone can access the menu again.

hip_hop_x 04-28-2006 18:31

Help
 
Ok. I'm a newbie in amxx scripting. Can you modifi my script? I searched for global variables in doc but haven't found about them.
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #include <engine> //#include <cstrike> new armament = 0 public plugin_init() {     new g_MenuDone[id]     register_plugin("Menu Demo", "1.0", "BAILOPAN")     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     register_menucmd(register_menuid("Ce putere alegi?"), keys, "giveWeapon")     register_concmd("amx_arma","cmd_arma",ADMIN_LEVEL_A)     register_clcmd("arma", "showWeaponMenu")     register_clcmd("say giveme", "showWeaponMenu")     register_clcmd("giveme", "showWeaponMenu")     register_cvar("min_reclama", "240")     set_task(20.0,"reclama") } public cmd_arma(id) {     new arg[2]     read_argv(1,arg,1)     if(equal(arg,"1")){     armament = 1     set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)     client_cmd(id, "showWeaponMenu")     show_hudmessage(0,"Arma mod turned on")         } else if(equal(arg,"0")){     armament = 0     show_hudmessage(0,"Arma mod turned off.")         } else {     if (armament==0){     console_print(id,"Usage: amx_arma 1 = 0n 0 = now it's OFF")         }     if (armament==1){     console_print(id,"Usage: amx_arma 1 = 0n 0 = now it's ON")         }     }     return PLUGIN_CONTINUE } public showWeaponMenu(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     format(menu, 191, "Ce putere alegi?^n^n0. Exit\n^n1. Ak power^n2. M4a1 power^n3. Vip power")     show_menu(id, keys, menu)     return PLUGIN_HANDLED } public giveWeapon(id, key) {     //Menu keys     if (key == 4)     {             }else if (key == 0){         give_item(id, "weapon_ak47")         engclient_cmd(id, "drop", "weapon_awp")         engclient_cmd(id, "drop", "weapon_m4a1")         client_print(id, print_chat, "Am ales 1 optiune")         } else if (key == 1) {         give_item(id, "weapon_m4a1")         engclient_cmd(id, "drop", "weapon_awp")         engclient_cmd(id, "drop", "weapon_ak47")         client_print(id, print_chat, "Am ales a 2 optiune")       } else if (key == 2) {         client_print(id, print_chat, "Am ales a 3 optiune")           set_user_armor(id, 200)         new armele = CSW_AK47|CSW_AUG|CSW_AWP|CSW_G3SG1|CSW_GALI|CSW_GALIL|CSW_M249|CSW_M4A1|CSW_MP5NAVY|CSW_P228|CSW_P90|CSW_SCOUT|CSW_SG550|CSW_SG552|CSW_TMP|CSW_XM1014|CSW_USP|CSW_ELITE|CSW_MAC10|CSW_FIVESEVEN|CSW_GLOCK18         if( MENU_KEY_3 ==         give_item(id, "weapon_deagle")     } else if (key == 3){         //nimic                     } } public reclama() {     client_print(0,print_chat,"press y and wrote: giveme")       set_task(get_cvar_float("min_reclama"),"reclama")       return PLUGIN_HANDLED }


How to add that function in here? Plz help me. Newbie ask for help :cry:

Orangutanz 04-28-2006 19:16

Just add this at the end of your giveWeapon function:
show_menu(id, 0, " ", 0)

That'll remove the menu from displaying.

hip_hop_x 04-28-2006 19:34

show_menu(id, 0, " ", 0) doesn't work. :(( I got this error: Error: Expected token: ")", but found "-identifier-" on line 79

Ok, sucks. I will try to make other type of plugin, not with menus :((.

Orangutanz 04-28-2006 20:37

You have more problems than just that, I just tried compiling what you had on here:

That line that you mentioned is due to this: if( MENU_KEY_3 ==
No ending bracket, besides that what is it suppose to be doing?

Another problem inside: plugin_init()
new g_MenuDone[id]

^ what is that for? plugin_init doesn't send an id, so why is that declared here ? :shock:

Orangutanz 04-28-2006 20:48

A little tip, properly structure you statements and functions. It makes finding errors quicker and updating your script in the future.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #include <engine> //#include <cstrike> new armament = 0 public plugin_init() {     register_plugin("Menu Demo", "1.0", "BAILOPAN")     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     register_menucmd(register_menuid("Ce putere alegi?"), keys, "giveWeapon")     register_concmd("amx_arma","cmd_arma",ADMIN_LEVEL_A)     register_clcmd("arma", "showWeaponMenu")     register_clcmd("say giveme", "showWeaponMenu")     register_clcmd("giveme", "showWeaponMenu")     register_cvar("min_reclama", "240")     set_task(20.0,"reclama") } public cmd_arma(id) {     new arg[2]     read_argv(1,arg,1)     if(equal(arg,"1"))     {         armament = 1         set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 2)         showWeaponMenu(id)         show_hudmessage(0,"Arma mod turned on")     }     else if(equal(arg,"0"))     {         armament = 0         show_hudmessage(0,"Arma mod turned off.")     }     else     {         if(armament==0)         {             console_print(id,"Usage: amx_arma 1 = 0n 0 = now it's OFF")         }         if(armament==1)         {             console_print(id,"Usage: amx_arma 1 = 0n 0 = now it's ON")         }     }     return PLUGIN_CONTINUE } public showWeaponMenu(id) {     new menu[192]     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3     format(menu, 191, "Ce putere alegi?^n^n0. Exit\n^n1. Ak power^n2. M4a1 power^n3. Vip power")     show_menu(id, keys, menu)     return PLUGIN_HANDLED } public giveWeapon(id, key) {     //Menu keys     if(key == 4)     {             }     else if(key == 0)     {         give_item(id, "weapon_ak47")         engclient_cmd(id, "drop", "weapon_awp")         engclient_cmd(id, "drop", "weapon_m4a1")         client_print(id, print_chat, "Am ales 1 optiune")         }     else if(key == 1)     {         give_item(id, "weapon_m4a1")         engclient_cmd(id, "drop", "weapon_awp")         engclient_cmd(id, "drop", "weapon_ak47")         client_print(id, print_chat, "Am ales a 2 optiune")       }     else if(key == 2)     {         client_print(id, print_chat, "Am ales a 3 optiune")           set_user_armor(id, 200)         //new armele = CSW_AK47|CSW_AUG|CSW_AWP|CSW_G3SG1|CSW_GALI|CSW_GALIL|CSW_M249|CSW_M4A1|CSW_MP5NAVY|CSW_P228|CSW_P90|CSW_SCOUT|CSW_SG550|CSW_SG552|CSW_TMP|CSW_XM1014|CSW_USP|CSW_ELITE|CSW_MAC10|CSW_FIVESEVEN|CSW_GLOCK18         give_item(id, "weapon_deagle")     }     else if(key == 3)     {         //nimic       }     show_menu(id, 0, " ", 0) } public reclama() {     client_print(0,print_chat,"press y and wrote: giveme")       set_task(get_cvar_float("min_reclama"),"reclama")       return PLUGIN_HANDLED }

Orangutanz 04-28-2006 21:01

For giveWeapon(id, key)

You could use a switch statement instead of loads of if/else if/else

Example:
Code:
public giveWeapon(id, key) {     switch(key)     {         case 0:         {             // your code         }         case 1:         {             // your code         }         case 2:         {             // your code         }         case 3:         {             // your code         }         case 4:         {             // your code         }     }     show_menu(id, 0, " ", 0) }


All times are GMT -4. The time now is 05:06.

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