So, what's your doubt?
The code you provided add all CT players and their respective indexes to the menu.
Code:
menu_additem(menu, szName, szTempid)
In your case, szTempid is the index of the player. To get it in the menu_handler function, use menu_item_getinfo
Code:
new szTempid[10], iAccess, iCallback
menu_item_getinfo(menu, item, iAccess, szTempid, charsmax(szTempid), _, _, iCallback)
new player_id = str_to_num(szTempid)
// do something with player_id
I would store the player userid instead of its index because if any of the players that are in the menu disconnect and another join in the same slot while the menu is open, you will end up selecting the wrong player. In your case, instead of this
Code:
num_to_str(tempid, szTempid, 9)
Code:
new player_id = str_to_num(szTempid)
you would have the following
Code:
num_to_str(get_user_userid(tempid), szTempid, 9)
Code:
new player_id = find_player("k", str_to_num(szTempid))
if (player_id)
{
// player was found, do something
}
else
{
// player is no longer connected
}
__________________