Player::kick: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Cleaned up, added an example.)
Line 1: Line 1:
This function kicks a player.
__NOTOC__
Kicks a player from the server.


==Syntax==
== Syntax ==
<syntaxhighlight lang="javascript">
<pre>
player.kick(String reason);
player.kick(reason);
</syntaxhighlight>
</pre>
 
=== Parameters ===
*'''reason''': {{RageType|String}} (This message does not show up for the player being kicked)
 
== Examples ==
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<pre>
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.');
});
</pre>
</div>


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

Revision as of 12:42, 29 September 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