hi there.
I start making a menu that listen all players on the server. After a player on the menu is choosen a submenu open (which is not fully included here) where the submenu show some amounts ( 5, 10, 20, 50, 100 )
My problem is: I cant hold the id (in my code the var: tempid) of the player I choose in the menu through to the submenu.
PHP Code:
#include <amxmodx>
#include <fun>
#include <zp50_ammopacks>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "plowed"
#define MAXAMOUNT 5
new g_ammoAmount[MAXAMOUNT][] = {
5,
10,
20,
50,
100
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /menu", "donateMenu")
}
public donateMenu(id) {
new menu = menu_create("Donate menu:","menu_handler")
new players[32], pnum, tempid
new szName[32], szTempid[10]
new ammos[32]
new desc[64]
get_players(players, pnum)
for(new i = 0; i < pnum; i++) {
tempid = players[i]
ammos[tempid] = zp_ammopacks_get(tempid)
get_user_name(tempid, szName, charsmax(szName))
formatex(desc, charsmax(desc), "\w%s \rAmmos: \y%d", szName, ammos[tempid])
num_to_str(tempid, szTempid, charsmax(szTempid))
menu_additem(menu, desc, szTempid, 0)
}
menu_display(id, menu, 0)
}
public menu_handler(id, menu, item) {
if(item == MENU_EXIT) {
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], szName[64]
new access, callback
menu_item_getinfo(menu, item, access, data, charsmax(data), szName, charsmax(szName), callback)
new tempid = str_to_num(data)
new Title[128], name[32], Auswahl[20]
get_user_name(tempid, name, charsmax(name))
formatex(Title, charsmax(Title), "Donate ammos to %s", name)
new submenu = menu_create(Title, "submenu_handler")
for(new i; i > sizeof g_ammoAmount;i++) {
formatex(Auswahl, charsmax(Auswahl),"\y%d\w HP", g_ammoAmount[i])
menu_additem(submenu, Auswahl, "i", 0)
}
menu_setprop(submenu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, submenu, 0)
return PLUGIN_HANDLED
}
public submenu_handler(id, submenu, item) {
if(item == MENU_EXIT) {
menu_destroy(submenu)
return PLUGIN_HANDLED
}
new data[6], szName[64]
new access, callback
menu_item_getinfo(submenu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data)
switch(key)
{
case 1:
{
//ex set_user_health of the player I choose..BUT I dont know how to get on that playerid I choose :S:DSX
}
case 2:
{
}
case 3:
{
}
case 4:
{
}
case 5:
{
}
}
}
some help or advices would be nice !
__________________