Kick
From SA-MP Wiki
(Difference between revisions)
Revision as of 19:36, 31 January 2014 Smithy (Talk | contribs) ← Previous diff |
Revision as of 20:53, 31 January 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 61: | Line 61: | ||
[[pt:Kick]] | [[pt:Kick]] | ||
[[de:Kick]] | [[de:Kick]] | ||
+ | [[fr:Kick]] | ||
[[it:Kick]] | [[it:Kick]] | ||
[[nl:Kick]] | [[nl:Kick]] | ||
[[ru:Kick]] | [[ru:Kick]] |
Revision as of 20:53, 31 January 2014
Description:
Kicks a player from the server. They will have to quit the game and re-connect if they wish to continue playing.
(playerid)
playerid | The ID of the player to kick. |
Return Values:
This function does not return any specific values.
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/kickme", true) == 0) { //Kicks the player who the executed this command Kick(playerid); return 1; } return 0; }
Important | As of SA-MP 0.3x, any action taken directly before Kick() (such as sending a message with SendClientMessage) will not reach the player. A timer must be used to delay the kick. |
The following code snippet shows a way of displaying a message for the player before they are kicked:
//In order to display a message (eg. reason) for the player before the connection is closed you have to use a timer to create a delay. This delay needs only to be a few milliseconds long, but this example uses a full second just to be on the safe side. forward KickPublic(playerid); public KickPublic(playerid) { Kick(playerid); } stock KickWithMessage(playerid, color, message[]) { SendClientMessage(playerid, color, message); SetTimerEx("KickPublic", 1000, false, "d", playerid); // Delay of 1 second before kicking the player so he receives the message } public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/kickme", true) == 0) { //Kicks the player who the executed this command KickWithMessage(playerid, 0xFF0000FF, "You have been kicked."); return 1; } return 0; } //by Kye
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- Ban: Ban a player from playing on the server.
- BanEx: Ban a player with a custom reason.