Player::kick: Difference between revisions

From RAGE Multiplayer Wiki
(Cleaned up, added an example.)
m (Replaced HTML with template)
Line 11: Line 11:


== Examples ==
== Examples ==
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{ServersideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<pre>
<pre>
mp.events.addCommand('kick', (player, target) => {
mp.events.addCommand('kick', (player, target) => {
Line 22: Line 21:
});
});
</pre>
</pre>
</div>
}}


==See Also==
==See Also==
{{Player_block}}
{{Player_block}}

Revision as of 11:15, 26 October 2018

Kicks a player from the server.

Syntax

player.kick(reason);

Parameters

  • reason: String (This message does not show up for the player being kicked)

Examples

Server-Side
mp.events.addCommand('kick', (player, target) => {
	let newTarget = mp.players.at(target);
	if(!target || isNaN(target)) return player.outputChatBox("Syntax: /kick [playerID]");
	if(newTarget === null) return player.outputChatBox("There is no player online with the ID given.")
	newTarget.outputChatBox("You have been kicked from the server.");
	newTarget.kick('Kicked.');
});

See Also