You shouldn't be using the id from get_players in your menu data. You should be using the userid (from get_user_userid()) because if someone leaves after you open the menu and another person joins, they will get that same id and you might ban someone that wasn't supposed to be banned.
Also, to use the "#" in the amx_ban command requires the userid (from get_user_userid()), not the entity id (from get_players()). So, I think you only need to make the following changes:
Code:
public BPlayerMenu0(id)
{
new menu = menu_create( "\rthS\d | \yChoose Player:", "BPlayerMenu_Handler0" )
new players[32], pnum, tempid;
new szName[32], szUserId[32]
get_players(players, pnum, "a")
for (new i; i<pnum; i++)
{
tempid = players[i];
get_user_name(tempid, szName, charsmax(szName))
// formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
new szUserId[12]
num_to_str(get_user_userid(tempid), szUserId, charsmax(szUserId))
menu_additem(menu, szName, szUserId, 0);
}
menu_display( id, menu, 0 )
}
public BPlayerMenu_Handler0(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new szIP[40];
new szData[6], szName[64], AdminName[64];
new _access, item_callback;
menu_item_getinfo(menu, item, _access, szData,charsmax(szData), szName,charsmax(szName), item_callback);
new tempid = str_to_num(szData)
new player = find_player("k", tempid)
if (player && is_user_alive(player))
{
get_user_ip(player, szIP, charsmax(szIP), 1)
get_user_name(id, AdminName, charsmax(AdminName))
server_cmd("amx_ban ^"#%d^" ^"30^" ^"Do not swear^"",tempid)
console_print(id, "Banned name: ^"%s^"", szName)
console_print(id, "Banned IP: ^"%s^"", szIP)
console_print(id, "Ban reason: Swearing")
console_print(id, "Ban Time: 30 minutes")
console_print(id, "Admin: ^"%s^"", AdminName)
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}