Kick
From SA-MP Wiki
This function can be used to kick a player who currently is in your server.
(playerid)
| playerid | The ID of the player you want to kick. |
| Returns | This function doesn't return a specific value |
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 Note: As of SA-MP 0.3x, any message sent to the player with SendClientMessage before Kick() will not be displayed for them. |
The following code snippet shows a way of displaying a message for the player before he is being kicked:
//In order to display a message (eg. reason) for the player before the connection is closed you have to use a delay: forward KickPublic(playerid); public KickPublic(playerid) { Kick(playerid); } stock KickWithMessage(playerid, color, message[]) { SendClientMessage(playerid, color, message); SetTimerEx("KickPublic", 1000, 0, "d", playerid); //Delay of 1 second before kicking the player so he recieves 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.
