Something is wrong with the ban command.
#1

Hello. So I have made a ban command, but when I ban someone, it bans me too, just says "The server closed the connection". How to fix that?

Here is my code:

PHP код:
CMD:ban(playerid,params[])
{
    if(
pInfo[playerid][pAdminLevel] >= 2)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
targetid,reason[105],ip[50],string[256];
            if(
sscanf(params"us[105]"targetid,reason)) return SendClientMessage(playerid,-1,"{C0C0C0}USAGE: /ban [playerid] [reason]");
            if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online.");
            
format(stringsizeof(string), "{DC143C}Administrator %s has banned %s [Reason: %s]",PlayerName(playerid),PlayerName(targetid),reason);
            
SendClientMessageToAll(-1,string);
            
format(string,sizeof(string), "You are banned from the server!\n\n{DC143C}Banned by{ffffff}: %s\n{DC143C}Reason{ffffff}: %s\n\nYou can post Ban Appeal on our Forums:\n{FFFF33}www.blablabla.com",PlayerName(playerid), reason);
            
ShowPlayerDialog(targetid,DIALOG_HELP,DIALOG_STYLE_MSGBOX,"{DC143C}BANNED",string,"Close","");
            
pInfo[targetid][pBanned] = 1;
            
GetPlayerIp(targetidipsizeof(ip));
            
format(stringsizeof(string), "banip %s",ip);
            
SetTimerEx("BanTimer"1000false"i"playerid);
        }
    }
    else {
        
//SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
    
}
    return 
1;
}
public 
BanTimer(playerid)
{
    
Ban(playerid);
    return 
1;
}
forward BanTimer(playerid); 
Thanks in advance for the help!
Reply
#2

SetTimerEx("BanTimer", 1000, false, "i", playerid); is playerid instead of targetid
Reply
#3

The reason why you get banned is because you have specified the playerid parameter in the timer:
pawn Код:
SetTimerEx("BanTimer", 1000, false, "i", playerid);
Instead of specifying the playerid specify the targetid:
pawn Код:
SetTimerEx("BanTimer", 1000, false, "i", targetid);
Edit: Too late, someone already posted before me.
Reply
#4

Ah, thanks. Silly me for not noticing the mistake.

+REP both of ya.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)