SA-MP Forums Archive
The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] (/showthread.php?tid=437892)



The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - zDivine - 17.05.2013

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.


Re: The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - RajatPawar - 17.05.2013

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!


Re: The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - zDivine - 17.05.2013

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.


Re: The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - CodyCummings - 17.05.2013

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.


Re: The known kick/ban bug (not sending message with kick/ban) for 0.3x [FIX] - zDivine - 17.05.2013

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.