The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX]
#1

Alright, so many scripters already know that with the 0.3x update, when you kick/ban someone, it's not sending the message to the player that gets kicked/banned.

Well, here's a simple, easy fix.

pawn Code:
forward UnsetKick(playerid);
public UnsetKick(playerid)
{
    Kick(playerid);
    return 1;
}

CMD:kick(playerid, params[])
{
    new string[128];
    format(string, sizeof(string), "%s has been kicked by %s, reason: %s", Name?, Name?, Reason?);
    SendClientMessageToAll(-1, string);
    SetTimerEx("UnsetKick", 500, 0, "i", playerid);
}
And the same thing goes for banning. Hope this helps.

For instance, this is what I did:
pawn Code:
forward UnsetKick(playerid);
public UnsetKick(playerid)
{
    Kick(playerid);
    return 1;
}
CMD:kick(playerid, params[])
{
    if(PI[playerid][p_Admin] >= CI[cmd_Kick])
    {
        new targetid, reason[64], string[128];
        if(sscanf(params, "us[64", targetid, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /kick [playerid] [reason]");
       
        if(!IsPlayerConnected(targetid)) return SendConnectionError(playerid);
        if(strlen(reason) <= 0) reason = "Not specified.";
       
        format(string, sizeof(string), "Admin %s has kicked %s, reason: %s", GetName(playerid), GetName(targetid), reason);
        SendClientMessageToAll(COLOR_REALRED, string);
        SetTimerEx("UnsetKick", 500, 0, "i", targetid);
    }
    else
    {
        SendPermissionError(playerid);
    }
    return 1;
}
P.S: Alternatively, you can use textdraws, as they seem to show up right before the kick/ban.
Reply
#2

Let us all pledge to put this thread's link in our signatures! Although, each function should be as dynamic as possible. Your function allows only fixed messages. Probably a message[] parameter. Cheers!
Reply
#3

Quote:
Originally Posted by Rajat_Pawar
View Post
Let us all pledge to put this thread's link in our signatures! Although, each function should be as dynamic as possible. Your function allows only fixed messages. Probably a message[] parameter. Cheers!
Just updated it to fit your needs. Enjoy.
Reply
#4

Or this.

pawn Code:
SetTimerEx("UnsetKick", GetPlayerPing(playerid), 0, "i", playerid);
Seems better.

Regardless, this should not be here, it should be in the code snippets thread.
Reply
#5

I cannot believe it. I thought of this timer fix all by myself, and come to find out... it's already been posted on the SAMP wiki... Makes me sad.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)