SA-MP Forums Archive
Kick command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Kick command (/showthread.php?tid=412972)



Kick command - Noles2197 - 03.02.2013

When a player is kicked, it closes the connection of the player being kicked before it shows the reason.
Anyone know how to make it show why the player was kicked to them before they're kicked?

pawn Код:
CMD:kick(playerid, params[])
{
    if(pInfo[playerid][Admin]>0)
    {
        new str[128],reason[64],id;
        if(sscanf(params,"ds[64]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"USAGE: /kick [playerid] [reason]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Invalid playerid!");
        format(str,sizeof(str),"Staff member %s kicked %s for %s.",GetName(playerid),GetName2(id),reason);
        SendClientMessageToAll(COLOR_RED,str);
        printf("%s",str);
        Kick(id);
    }
    return 1;
}



Re: Kick command - Patrick - 03.02.2013

Try This
pawn Код:
new KickPlayer[MAX_PLAYERS];//Global Variable

forward KickPlayer();
public KickPlayer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(KickPlayer[i] == 1)
        {
        Kick(i)
        }
    }
    return 1;
}

CMD:kick(playerid, params[])
{
    if(pInfo[playerid][Admin]>0)
    {
        new str[128],reason[64],id;
        if(sscanf(params,"ds[64]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"USAGE: /kick [playerid] [reason]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Invalid playerid!");
        format(str,sizeof(str),"Staff member %s kicked %s for %s.",GetName(playerid),GetName2(id),reason);
        SendClientMessageToAll(COLOR_RED,str);
        format(str,sizeof(str),"You have been kicked by Admin %s Reason: %s",GetName(playerid),reason);
        SendClientMessageToAll(COLOR_RED,str);
        printf("%s",str);
        SetTimer("KickPlayer",1000,0); //1000 - bans player in second || 0 - no timer repeat
        KickPlayer[id] =1;//check's the player then it will kick
    }
    return 1;
}



Re : Kick command - Mathieu371 - 04.02.2013

pawn Код:
forward @Kick(playerid);
public @Kick(playerid) return Kick(playerid);

CMD:kick(playerid, params[])
{
    if(pInfo[playerid][Admin]>0)
    {
        new str[128],reason[64],id;
        if(sscanf(params,"ds[64]",id,reason)) return SendClientMessage(playerid,COLOR_GRAY,"USAGE: /kick [playerid] [reason]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Invalid playerid!");
        format(str,sizeof(str),"Staff member %s kicked %s for %s.",GetName(playerid),GetName2(id),reason);
        SendClientMessageToAll(COLOR_RED,str);
        printf("%s",str);
        SetTimerEx("@Kick", 1000, false, "d", id);
    }
    return 1;
}
More optimised than pds2012's solution


Re: Kick command - SuperViper - 04.02.2013

Kick (and probably Ban aswell) take priority over everything so if you want to do something to a player before kicking them, it needs to be in a separate function.