kickPlayer
Client-side
Server-side
Shared
This function will kick the specified player from the server.
OOP Syntax Help! I don't understand this!
- Method: player:kick(...)
Syntax
bool kickPlayer ( player kickedPlayer, [ player/string responsiblePlayer = "Console", string reason = "" ] )
Required Arguments
- kickedPlayer: The player that will be kicked from the server.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- responsiblePlayer (default: "Console"): The player or string that is responsible for the event. Maximum 30 characters if using a string.
- reason (default: ""): The reason for the kick. Max 125 characters.
Returns
- bool: result
Returns true if the player was kicked succesfully, false if invalid arguments are specified.
Code Examples
server
This example lets a player kick anyone who has a lower level.
local function kickPlayerHandler(sourcePlayer, commandname, kickedname, ...) -- Get player element from the name local kicked = getPlayerFromName(kickedname) if (not kicked) then -- player not found outputChatBox("Player "..kickedname.." not found!", sourcePlayer) return end
-- If the client who sent the command has a higher level local reason = table.concat({...}, " ") if (hasObjectPermissionTo(sourcePlayer, "function.kickPlayer")) then -- Kick the player kickPlayer(kicked, sourcePlayer, reason) endend-- Add the "kick" command handleraddCommandHandler("kick", kickPlayerHandler)