[CODE] Players menu
Posted: Thu Sep 24, 2026 2:18 pm
Here is a function i wrote to put a list of players into a certain menu. Its just to get you somewhere if you need to put a player list into your menu. The data it puts to each item is [source];[playerID]
You can pass "" as the source to this function if you don't need it. Separate your data by the ; delimiter in whatever manner you see fit.
@RETURN: amount of players in the list
@ PARAMETER:
p_menu: pointer to the menu in which to put the list
source[]: data to pass to the item signifying where the menu came from
itemAccess: Admin access to utilize this menu
getPlayersFlags[]: Flags to use in the getPlayers() function
@NOTE: feel free to remove the semicolon from the formatex statement if you don't use the source parameter.
You can pass "" as the source to this function if you don't need it. Separate your data by the ; delimiter in whatever manner you see fit.
@RETURN: amount of players in the list
@ PARAMETER:
p_menu: pointer to the menu in which to put the list
source[]: data to pass to the item signifying where the menu came from
itemAccess: Admin access to utilize this menu
getPlayersFlags[]: Flags to use in the getPlayers() function
@NOTE: feel free to remove the semicolon from the formatex statement if you don't use the source parameter.
Code: Select all
/* THIS FUNCTION AUTOMATICALLY SETS THE EXIT (creates a useable menu)
p_menu is a pointer to the menu that we're going to add the players list to
source[] is the source menu to keep track of what's going on internally
itemAccess is the "access" paramater for menu_additem
getPlayersFlags[] is a string of flags for the get_players command
RETURNS: number of players in the list */
mhlp_getPlayerMenu(&p_menu, source[]="fal", itemAccess=0, getPlayersFlags[]="ch")
{
new players[32], player, plyrCnt
new sz_name[32], sz_info[8]
get_players(players, plyrCnt, getPlayersFlags)
for(new i=0; i<plyrCnt; i++)
{
player = players[i]
get_user_name(player, sz_name, charsmax(sz_name) )
formatex(sz_info, charsmax(sz_info), "%s;%d", source, player)
menu_additem(p_menu, sz_name, sz_info, itemAccess)
}
menu_setprop(p_menu, MPROP_EXIT, MEXIT_ALL)
return plyrCnt
}