Ok so i tried from 0 and now works but not everytime. Then i first join in the server and then another player connect to server everyting works fine, but if i joined second and try to ban some player i get banned by myself. Any suggestion? Code:
HTML Code:
#include <amxmodx>
#include <amxmisc>
new reason[32]
new bantime[32]
new target[33];
public plugin_init()
{
register_plugin("Banmenu", "SomeBody", "1.0");
register_clcmd("amx_newbanmenu", "cmdBanMenu")
}
public cmdBanMenu(id) {
if(!(get_user_flags(id) & ADMIN_BAN)) {
return PLUGIN_HANDLED
}
//Create a variable to hold the menu
new menu = menu_create( "Choose player to BAN", "menu_handler3" );
//We will need to create some variables so we can loop through all the players
new players[32], pnum, tempid;
//Some variables to hold information about the players
new szName[32],szUserId[32];
//Fill players with available players
get_players( players, pnum);
//Start looping through all players
for ( --pnum; pnum>=0; pnum-- )
{
//Save a tempid so we do not re-index
tempid = players[pnum];
//Get the players name and userid as strings
get_user_name( tempid, szName, charsmax( szName ) );
formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid))
//Add the item for this player
menu_additem( menu, szName,szUserId, 0 );
}
//We now have all players in the menu, lets display the menu
menu_display( id, menu);
return PLUGIN_HANDLED
}
public menu_handler3( id, menu, item )
{
if ( item == MENU_EXIT )
{
return PLUGIN_HANDLED;
}
new szData3[6], szName[64];
new item,access, item_callback;
menu_item_getinfo( menu, item,access, szData3,charsmax(szData3), szName,charsmax( szName ), item_callback );
target[id] = find_player("k", str_to_num(szData3))
menu_destroy( menu );
AwesomeMenu( id )
return PLUGIN_HANDLED;
}
public AwesomeMenu( id ) {
new menu = menu_create( "Choose player BAN REASON", "menu_handler" );
menu_additem( menu, "Cheating", "", 0 );
menu_additem( menu, "Camping", "", 0 );;
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, menu, 0 );
}
public menu_handler( id, menu, item )
{
if ( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new item_access, item_callback;
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
switch( item )
{
case 0:
{
format(reason,charsmax(reason),"Cheating")
format(bantime,charsmax(bantime),"4320")
}
case 1:
{
format(reason,charsmax(reason),"Camping")
format(bantime,charsmax(bantime),"518400")
}
}
menu_destroy( menu );
Punish(id)
return PLUGIN_HANDLED;
}
public Punish(id) {
//kick
if (is_user_connected( target[id] ) )
{
new name[32]
get_user_name(id,name,31)
new name2[32]
get_user_name(target[id],name2,31)
client_cmd(id, "amx_ban ^"%s^" ^"%s^" ^"%s^"", name2,bantime,reason)
}
return PLUGIN_HANDLED;
}