Player::kick: Difference between revisions
m (category) |
No edit summary |
||
| Line 1: | Line 1: | ||
{{ServersideCode|}} | |||
==Description== | |||
Kicks a player from the server. | Kicks a player from the server. | ||
== Syntax == | |||
{{JSContainer| | |||
==Syntax== | |||
<pre> | <pre> | ||
player.kick(reason); | player.kick(reason); | ||
</pre> | </pre> | ||
{{Parameters}} | |||
*'''reason:''' string | |||
*'''reason''' | |||
== | ==Example== | ||
<pre> | <pre> | ||
mp.events.addCommand('kick', (player, target) => { | mp.events.addCommand('kick', (player, target) => { | ||
| Line 21: | Line 23: | ||
</pre> | </pre> | ||
}} | }} | ||
{{CSharpContainer| | |||
==Syntax== | |||
<pre> | |||
player.Kick(reason); | |||
</pre> | |||
{{Parameters}} | |||
*'''reason:''' string (optional) | |||
== | ==Example== | ||
{ | <pre> | ||
[Command("kick")] | |||
public void KickCommand(Player player, string reason) | |||
{ | |||
player.Kick(reason); | |||
} | |||
</pre> | |||
}} | |||
[[Category: | [[Category:Entity API]] | ||
Revision as of 13:01, 13 October 2022
Server-Side
Description
Kicks a player from the server.
JavaScript Syntax
Syntax
player.kick(reason);
Parameters
- reason: string
Example
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.');
});
C# Syntax
Syntax
player.Kick(reason);
Parameters
- reason: string (optional)
Example
[Command("kick")]
public void KickCommand(Player player, string reason)
{
player.Kick(reason);
}