AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_menu (https://forums.alliedmods.net/showthread.php?t=46016)

Nostrodamous 10-16-2006 19:58

get_user_menu
 
hi , can some 1 help me figure out how to use get_user_menu the right way . I want to make it so if the menu disapeers the player dies , so they have to pick from the menu or die , forcing them to practice with the weapons i want . i cant seem to get it rite. I tried to do
Code:
public ak_show(id, key) {  if(key == 0)  // yes  {   fm_give_item(id, "weapon_ak47");   cs_set_user_bpammo(id , CSW_AK47 , 200);  }  else  {   if(key == 2)   {    user_kill(id);   }   else   {    if(get_user_menu(id)==0)    {         user_kill(id);   }  }  return PLUGIN_CONTINUE; }
thanks :|

k007 10-16-2006 20:06

Re: get_user_menu
 
if your having a problem making a menu and it keys use amxmodx studio and go to generators and click on menu generators.
or you could use this
http://sniperbeamer.amxmod.info/menu...numaker.htm?en

Nostrodamous 10-16-2006 20:16

Re: get_user_menu
 
no i know how to make menus im not a noob. Let me explaine further . I have a menu that will dispaly 2 options , practice or die. the menus works both options work , but i want to make it so that if the player doesnt choose , for instance if he jsut lets the menu go away and doesnt choose , then i want him to die also. so get_user_menu returns 0 if the player is not looking at a menu (ie he let the menu go away) . but i cant seem to get the paramters right . let me show u my code so far
Code:
/* This Plugin Is To Initiaite A Practice Mode Within Your Server , With Any weapon you wish to use . */ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fakemeta_util> new keys = MENU_KEY_1 | MENU_KEY_2 ; new menu[192]; public plugin_init() {  register_plugin("practice_mod" , "1.5" , "Nas");  register_cvar("amx_practice" , "1"); /* Menus    */  register_menucmd(register_menuid("type_menu"),1023, "type_show");  register_menucmd(register_menuid("ak_menu"),1023, "ak_show");  register_menucmd(register_menuid("m4_menu"), 1023, "m4_show");  register_menucmd(register_menuid("galil_menu"), 1023 , "galil_show");  register_menucmd(register_menuid("aug_menu"), 1023 , "aug_show"); /* Commands */  register_concmd("amx_practice" , "type_menu", ADMIN_CVAR, "Shows The Practice Menu"); } public type_menu(id) {  format(menu, 191, "[Practice]^n1. Rifles^n2. SMG's^n3. Pistol's^n4. Nades^n^n0: Exit" );  show_menu(0 , keys, menu, -1, "type_menu")  return PLUGIN_CONTINUE; } public type_show(id) { } public ak_menu(id) {  if(get_cvar_num("amx_practice")==0)  {   return PLUGIN_HANDLED;  }  else  {   format(menu, 191, "Ready For Ak Practice?^n1. Practice^2. Die" );   show_menu(0 , keys, menu, -1, "ak_menu")   return PLUGIN_CONTINUE;  }  return PLUGIN_CONTINUE; }   public ak_show(id, key) {  if(key == 0)  // yes  {   fm_give_item(id, "weapon_ak47");   cs_set_user_bpammo(id , CSW_AK47 , 200);  }  else  {   if(key == 2)   {    user_kill(id);   }   else   {    if(get_user_menu(id)==0)    {     user_kill(id);    }   }  }  return PLUGIN_CONTINUE; }     public m4_menu(id) {  if(get_cvar_num("amx_practice")==0)  {   return PLUGIN_HANDLED;  }  else  {   format(menu, 191, "Ready For M4 Practice?^n1. Practice^2. Die" );   show_menu(0 , keys, menu, -1, "m4_menu")   return PLUGIN_CONTINUE;  }  return PLUGIN_HANDLED; } public m4_show(id, key ) {  if(key == 0) // yes  {   strip_guns(id);   fm_give_item(id  , "weapon_m4a1");   cs_set_user_bpammo(id , CSW_M4A1 , 200);  }  else  {   user_kill(id);  }  return PLUGIN_CONTINUE; } public galil_menu(id) {  if(get_cvar_num("amx_practice")==0)  {   return PLUGIN_HANDLED;  }  else  {   format(menu, 191, "Ready For Galil Practice?^n1. Practice^2. Die" );   show_menu(0 , keys, menu, -1, "galil_menu")   return PLUGIN_CONTINUE;  }  return PLUGIN_CONTINUE; }   public galil_show(id, key) {  if(key == 0) // yes  {   strip_guns(id);   fm_give_item(id , "weapon_galil");   cs_set_user_bpammo(id , CSW_GALIL , 200);  }  else  {   user_kill(id);  }  return PLUGIN_CONTINUE; } public aug_menu(id) {  if(get_cvar_num("amx_practice")==0)  {   return PLUGIN_HANDLED;  }  else  {   format(menu, 191, "Ready For Aug Practice?^n1. Practice^2. Die" );   show_menu(0 , keys, menu, -1, "aug_menu") ;   return PLUGIN_CONTINUE;  }  return PLUGIN_HANDLED; } public aug_show(id , key) {  if(key == 0)  // yes  {   strip_guns(id);   fm_give_item(id  , "weapon_aug");   cs_set_user_bpammo(id , CSW_AUG, 200);  }  else  {   user_kill(id);  }  return PLUGIN_HANDLED; } public strip_guns(id) {  fm_strip_user_gun(id, CSW_GLOCK18);  fm_strip_user_gun(id, CSW_M4A1);  fm_strip_user_gun(id, CSW_AK47);  fm_strip_user_gun(id, CSW_SCOUT);  fm_strip_user_gun(id, CSW_XM1014);  fm_strip_user_gun(id, CSW_MAC10);  fm_strip_user_gun(id, CSW_AUG);  fm_strip_user_gun(id, CSW_ELITE);  fm_strip_user_gun(id, CSW_FIVESEVEN);  fm_strip_user_gun(id, CSW_UMP45);  fm_strip_user_gun(id, CSW_SG550);  fm_strip_user_gun(id, CSW_GALIL);  fm_strip_user_gun(id, CSW_FAMAS);  fm_strip_user_gun(id, CSW_USP);  fm_strip_user_gun(id, CSW_AWP);  fm_strip_user_gun(id, CSW_MP5NAVY);  fm_strip_user_gun(id, CSW_M249);  fm_strip_user_gun(id, CSW_M3);  fm_strip_user_gun(id, CSW_TMP);  fm_strip_user_gun(id, CSW_G3SG1);  fm_strip_user_gun(id, CSW_DEAGLE);  fm_strip_user_gun(id, CSW_SG552);  fm_strip_user_gun(id, CSW_P90);  fm_strip_user_gun(id, CSW_P228);  server_cmd("humans_join_team" , "any");  server_cmd("mp_autoteambalance" , "1");  server_cmd("mp_limitteams" , "1");  server_cmd("mp_c4tmer" , "45");  server_cmd("mp_freezetime" , "6");  server_cmd("mp_friendlyfire" , "1");  server_cmd("mp_tkpunish" , "1");  server_cmd("sv_alltalk" , "0");  server_cmd("sv_gravity" , "800");  server_cmd("amx_awppv" , "0");  server_cmd("DF_hook_on" , "0"); }
so how do i use get_user_menu properly to detect when the players menu has gone away ? im getting error for argument mismatch on it.

k007 10-16-2006 20:23

Re: get_user_menu
 
ur code is kinda of messed up and ur using fm utli,
Code:

When there is no menu the index is 0. If the id is negative then the menu is VGUI in other case the id is from
thats from the func wiki if you read
and why not just make an exit key and slay them when they press it?

Nostrodamous 10-16-2006 20:33

Re: get_user_menu
 
well the problem is that if they decide not to press it the menu will go away . they avoid pressing it . so they wont press exit or 1 or 2 . so i want to make it so that if they dont press anything theyll die also . like a fail safe. and yes i already read the documentation. thats how i knew what it returned for a value. and i tried to pass paramters trough it and it still gave me erorrs. and my code isnt finished so this is only half of the code. its not finished yet . but i cant get the get_user_menu to work. :|

k007 10-16-2006 20:51

Re: get_user_menu
 
hmm how about a task after xSeconds to close it and kill them?

Nostrodamous 10-16-2006 20:53

Re: get_user_menu
 
I had considered this before , but then I came to the get_user_menu. which seems like a more appropriate less cpu exspensive way. if i dont have to i dont want to use a set_task. So im using that as a last resort . I'd really like to figure out a way to use the get_user_menu:cry:

Rolnaaba 10-17-2006 12:11

Re: get_user_menu
 
first of all your menu method sux, much easier to use cases, then if you use cases you could do the following
Code:
case 1: //practice case 2: //die default: //kill them

I will work on your menu dont have time right at the moment but if someone hasnt done it by tomarrow I can show a different method.

Rolnaaba 10-17-2006 12:13

Re: get_user_menu
 
also dont use server_cmd to set cvars

Rolnaaba 10-17-2006 13:09

Re: get_user_menu
 
here is what I have so far, removed server cmds you can add those when you use it correctly and removed cvar check cause I didnt feel like putting atm but you can add those but this should work:
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fakemeta_util> #define PLUGIN "Practice Mod" #define VERSION "1.0" #define AUTHOR "Rolnaaba" #define Keystype_menu (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4) #define Keysak_menu (1<<0)|(1<<1) #define Keysm4_menu (1<<0)|(1<<1) #define Keysgalil_menu (1<<0)|(1<<1) #define Keysaug_menu (1<<0)|(1<<1) public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)    register_cvar("amx_practice", "1")    register_menucmd(register_menuid("type_menu"), Keystype_menu, "Pressedtype_menu")  register_menucmd(register_menuid("ak_menu"), Keysak_menu, "Pressedak_menu")  register_menucmd(register_menuid("m4_menu"), Keysm4_menu, "Pressedm4_menu")  register_menucmd(register_menuid("galil_menu"), Keysgalil_menu , "Pressedgalil_menu")  register_menucmd(register_menuid("aug_menu"), Keysaug_menu , "Pressedaug_menu")    register_concmd("amx_practice" , "Showtype_menu", ADMIN_CVAR, "Shows The Practice Menu") } public Showtype_menu(id) {  show_menu(id, Keystype_menu, "1. Ak's^n2. M4's^n3. Galil's^n4. Aug's^n^n0. Exit", -1, "Practice Menu") } public Pressedtype_menu(id, key) {  switch (key) {   case 0: {    Showak_menu(id)     }   case 1: {    Showm4_menu(id)   }   case 2: {    Showgalil_menu(id)   }   case 3: {    Showaug_menu(id)   }   case 4: {    EndMenu(id)   }  } } public Showak_menu(id) {  show_menu(id, Keysak_menu, "Ready For Ak Practice?^n1. Practice^2. Die", -1, "Practice Menu") } public Pressedak_menu(id, key) {  switch(key) {   case 0: {    strip_guns(id)    fm_give_item(id, "weapon_ak47");    cs_set_user_bpammo(id , CSW_AK47 , 200)   }   case 1: {    user_kill(id)   }   default: {    user_kill(id)   }  } } public Showm4_menu(id) {  show_menu(id, Keysm4_menu, "Ready For M4 Practice?^n1. Practice^2. Die", -1, "Practice Menu") } public Pressedm4_menu(id, key) {  switch(key) {   case 0: {    strip_guns(id)    fm_give_item(id  , "weapon_m4a1")    cs_set_user_bpammo(id , CSW_M4A1 , 200)   }   case 1: {    user_kill(id)   }   default: {    user_kill(id)   }  } } public Showgalil_menu(id) {  show_menu(id, Keysgalil_menu, "Ready For Galil Practice?^n1. Practice^2. Die", -1, "Practice Menu") } public Pressedgalil_menu(id, key) {  switch(key) {   case 0: {    strip_guns(id)    fm_give_item(id , "weapon_galil")    cs_set_user_bpammo(id , CSW_GALIL , 200)   }   case 1: {    user_kill(id)   }   default: {    user_kill(id)   }  } } public Showaug_menu(id) {  show_menu(id, Keysgalil_menu, "Ready For Aug Practice?^n1. Practice^2. Die", -1, "Practice Menu") } public Pressedaug_menu(id, key) {  switch(key) {   case 0: {    strip_guns(id)    fm_give_item(id  , "weapon_aug")    cs_set_user_bpammo(id , CSW_AUG, 200)   }   case 1: {    user_kill(id)   }   default: {    user_kill(id)   }  } } public strip_guns(id) {  fm_strip_user_gun(id, CSW_GLOCK18)  fm_strip_user_gun(id, CSW_M4A1)  fm_strip_user_gun(id, CSW_AK47)  fm_strip_user_gun(id, CSW_SCOUT)  fm_strip_user_gun(id, CSW_XM1014)  fm_strip_user_gun(id, CSW_MAC10)  fm_strip_user_gun(id, CSW_AUG)  fm_strip_user_gun(id, CSW_ELITE)  fm_strip_user_gun(id, CSW_FIVESEVEN)  fm_strip_user_gun(id, CSW_UMP45)  fm_strip_user_gun(id, CSW_SG550)  fm_strip_user_gun(id, CSW_GALIL)  fm_strip_user_gun(id, CSW_FAMAS)  fm_strip_user_gun(id, CSW_USP)  fm_strip_user_gun(id, CSW_AWP)  fm_strip_user_gun(id, CSW_MP5NAVY)  fm_strip_user_gun(id, CSW_M249)  fm_strip_user_gun(id, CSW_M3)  fm_strip_user_gun(id, CSW_TMP)  fm_strip_user_gun(id, CSW_G3SG1)  fm_strip_user_gun(id, CSW_DEAGLE)  fm_strip_user_gun(id, CSW_SG552)  fm_strip_user_gun(id, CSW_P90)  fm_strip_user_gun(id, CSW_P228) } public EndMenu(id) {  return PLUGIN_HANDLED }


All times are GMT -4. The time now is 04:51.

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