Kick command
#1

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;
}
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)