Ban message not showing up
#1

I was wondering how to make the ban or kick message show up for the banned/kicked guy at the time of action?
Because many people are complaining about not seeing the kick reason.
For example this is the ban command
pawn Код:
CMD:ban(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] >= 3) {
            new PID; //define the playerid we wanna ban
            new reason[64]; //the reason, put into a string
            new str[128]; //a new message string
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)

            if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");

            format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
        SendClientMessageToAll(COLOR_RED, str); //send that message to all
        Ban(PID); //Ban the playerid we've defined

        }
        else //if he has not got the permissions
        {
            SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
        }
        return 1;
    }
How can I add something like a timer?
Reply
#2

it has being made so you cant!
run a timer with a few ms after the message it sure will work.
Reply
#3

You need to delay your ban....

pawn Код:
new bool:Banning[MAX_PLAYERS];

OnPlayerDisconnect(playerid)
{
    Banning[playerid] = false;
}

stock BanDelay(playerid, delay=1000)
{
    Banning[playerid] = true;
    SetTimerEx("IssueBan", delay, false, "i", playerid);
}

forward IssueBan(playerid);
public IssueBan(playerid)
{
    if(Banning[playerid])
    {
        Banning[playerid] = false;
        Ban(playerid);
     }
}
This way you won't possibly get any wrongful bans if a player logs out and other logs in before the timer is complete.
Reply
#4

Yeah i was too slow, can delete....
Reply
#5

nvm.. xD always late.
Reply
#6

@edzis84 - Read my reply of why that could potentially lead to a false ban.
Reply
#7

Thank you all for your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)