SA-MP Forums Archive
About Kick(playerid) - 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: About Kick(playerid) (/showthread.php?tid=501140)



About Kick(playerid) - Gilmar - 16.03.2014

Hi, I have a simple question about the Kick(playerid).
I made this function:
Код:
stock KickPlayer(playerid, kickedby, reason[])
{
	new string[256];
	format(string, sizeof(string), "You've been kicked by %s. Reason: %s\n", GetName(playerid), reason);
	SendClientMessage(kickedby, COLOR_RED, string);
	return Kick(kickedby);
}
and I called this function on some OnPlayerCommandText code.
Why when I use the function I can't see the SendCliendMessage? It displays just the "Server close the connection." message, why? How can I fix that?


Re: About Kick(playerid) - Calabresi - 16.03.2014

You have to use a timer to kick the player out, it's one of the SA-MP's bugs.


Re: About Kick(playerid) - CuervO - 16.03.2014

Most likely you're being kicked before the message is sent, you can fix that by using a timer to actually Kick the player (SetTimerEx) with a delay of a second or so.

EDIT: ninja'd


Re: About Kick(playerid) - Abagail - 16.03.2014

Use a timer.
pawn Код:
stock KickPlayer(playerid, kickedby, reason[])
{
    new string[256];
    format(string, sizeof(string), "You've been kicked by %s. Reason: %s\n", GetName(playerid), reason);
    SendClientMessage(kickedby, COLOR_RED, string);
    return SetTimerEx("Kick", 5000, false, "i",kickedby);
}



Re: About Kick(playerid) - Gilmar - 16.03.2014

Ok, thanks! I tried with a delay of a 1 sec. Another question: the timer delay can be shorter than 1 second?


Re: About Kick(playerid) - Abagail - 16.03.2014

Well, why would you make a timer that's less than 1 second? What's the purpose of this?


Re: About Kick(playerid) - Gilmar - 16.03.2014

Just to make the kick faster.


Re: About Kick(playerid) - Jessyy - 16.03.2014

1. Took me only 15 minutes to figure out what you did ...whay?... in your code var. "kickedby" - is the person you trying to kick... when i read "kickedby" i think is the admin not the player...
2. I hope that when you test the function alone "responsiblePlayer & kickedPlayer" they will have the same id (responsiblePlayer == kickedPlayer)

Код:
/*
 * KickPlayer
 * responsiblePlayer	The player that is responsible for the event
 * kickedPlayer		The player that will be kicked from the server
 * reason		The reason for the kick
 */
stock KickPlayer(responsiblePlayer, kickedPlayer, reason[])
{
	new string[256];
	format(string, sizeof(string), "You've been kicked by %s. Reason: %s\n", GetName(responsiblePlayer), reason);
	SendClientMessage(kickedPlayer, COLOR_RED, string);
	
	return Kick(kickedPlayer);
}



Re: About Kick(playerid) - Calabresi - 16.03.2014

Quote:
Originally Posted by Gilmar
Посмотреть сообщение
Ok, thanks! I tried with a delay of a 1 sec. Another question: the timer delay can be shorter than 1 second?
Yeah, it can. 300ms is enough if I'm not remembering wrong.