AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   passing var in menu handler (quick fix please) (https://forums.alliedmods.net/showthread.php?t=241089)

aron9forever 05-27-2014 14:58

passing var in menu handler (quick fix please)
 
Code:
new id = x         static menu[1000], len     len = 0     len += formatex(menu[len], charsmax(menu) - len, "\yJucatorul -\d %s\y te-a provocat la PHF pe %d Credite^n^n",szName,Miza)     len += formatex(menu[len], charsmax(menu) - len, "\y1.\w Accepta^n")     len += formatex(menu[len], charsmax(menu) - len, "\y2.\w Refuza^n")     show_menu(iPlayer, KEYSMENU, menu, -1, "Piatra hartie foarfeca") public menu_phf(id, key) {     if(cs_get_user_team(id) == CS_TEAM_T)     {         switch (key)         {             case 0:             {                 g_acceptphf[id]=true                 client_cmd(id,"spk buttons/button9")             }             case 1:             {                 g_acceptphf[id]=false                 remove_task(51373)                 g_phfinit[id]=0                 client_cmd(id,"spk buttons/button9")             }         }     } }

I need to send original "id" to the menu handler, how can I do that?
I need to set g_phfinit[] to 0 for the player that invoked the menu on iPlayer

aron9forever 05-28-2014 09:11

Re: passing var in menu handler (quick fix please)
 
okay so I "solved" this by creating a 1dimensional array that stores the invoker's id in the position of the invoked player's cell, any better way to do this?
I've searched for documentation but couldn't find any other optional params in the show_menu command

Code:
new id = x         static menu[1000], len     len = 0     len += formatex(menu[len], charsmax(menu) - len, "\yJucatorul -\d %s\y te-a provocat la PHF pe %d Credite^n^n",szName,Miza)     len += formatex(menu[len], charsmax(menu) - len, "\y1.\w Accepta^n")     len += formatex(menu[len], charsmax(menu) - len, "\y2.\w Refuza^n")     show_menu(iPlayer, KEYSMENU, menu, -1, "Piatra hartie foarfeca")         g_phfdata[iPlayer]=id public menu_phf(id, key) {     if(cs_get_user_team(id) == CS_TEAM_T)     {         switch (key)         {             case 0:             {                 g_acceptphf[id]=true                 client_cmd(id,"spk buttons/button9")             }             case 1:             {                 g_acceptphf[id]=false                 remove_task(51373)                 g_phfinit[id]=0                                 g_phfinit[g_phfdata[id]]=0                 client_cmd(id,"spk buttons/button9")             }         }     } }

YamiKaitou 05-28-2014 09:19

Re: passing var in menu handler (quick fix please)
 
You can use the NewMenu system and put the ID in as the info parameter of each item

aron9forever 05-28-2014 09:30

Re: passing var in menu handler (quick fix please)
 
Quote:

Originally Posted by YamiKaitou (Post 2143501)
You can use the NewMenu system and put the ID in as the info parameter of each item

this?
Code:
new menu1 = menu_create("menu name", "menu_handler");         menu_additem(menu1, "asd", "1", 0);         menu_additem(menu1, "asd", "2", 0);         menu_additem(menu1, "asd", "3", 0);         menu_additem(menu1, "asd", "4", 0);         menu_additem(menu1, "asd", "5", 0);

you can't use variables inside menu options can you? I need to display the value of the pot...

YamiKaitou 05-28-2014 09:54

Re: passing var in menu handler (quick fix please)
 
https://forums.alliedmods.net/showth...364#PlayerMenu


All times are GMT -4. The time now is 09:45.

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