2013-07-27 16:24:03 +01:00
|
|
|
function HandleKickCommand( Split, Player )
|
2013-08-11 16:00:53 +01:00
|
|
|
|
2013-07-27 16:24:03 +01:00
|
|
|
if( #Split < 2 ) then
|
2013-08-11 16:00:53 +01:00
|
|
|
SendMessage( Player, "Usage: /kick [Player] <Reason>" )
|
2013-07-27 16:24:03 +01:00
|
|
|
return true
|
|
|
|
|
end
|
2013-08-11 16:00:53 +01:00
|
|
|
|
2013-07-27 16:24:03 +01:00
|
|
|
local Reason = "You have been kicked"
|
2013-08-11 16:00:53 +01:00
|
|
|
if ( #Split > 2 ) then
|
|
|
|
|
Reason = table.concat( Split, " ", 3 )
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
2013-08-11 16:00:53 +01:00
|
|
|
|
2013-07-27 16:24:03 +01:00
|
|
|
if( KickPlayer( Split[2], Reason ) == false ) then
|
2013-08-11 16:00:53 +01:00
|
|
|
SendMessageFailure( Player, "Could not find player " .. Split[2] )
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return true
|
2013-08-11 16:00:53 +01:00
|
|
|
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- Kicks a player by name, with the specified reason; returns bool whether found and player's real name
|
2013-08-11 16:00:53 +01:00
|
|
|
function KickPlayer( PlayerName, Reason )
|
|
|
|
|
|
|
|
|
|
local RealName = ""
|
2013-07-27 16:24:03 +01:00
|
|
|
if (Reason == nil) then
|
2013-08-11 16:00:53 +01:00
|
|
|
Reason = "You have been kicked"
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
2013-08-11 16:00:53 +01:00
|
|
|
|
|
|
|
|
local FoundPlayerCallback = function( a_Player )
|
2013-07-27 16:24:03 +01:00
|
|
|
RealName = a_Player:GetName()
|
|
|
|
|
|
|
|
|
|
local Server = cRoot:Get():GetServer()
|
|
|
|
|
LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
|
|
|
|
|
Server:SendMessage("Kicking " .. RealName)
|
|
|
|
|
|
2013-08-11 16:00:53 +01:00
|
|
|
a_Player:GetClientHandle():Kick(Reason)
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
|
|
|
|
|
2013-08-11 16:00:53 +01:00
|
|
|
if not cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback ) then
|
2013-07-27 16:24:03 +01:00
|
|
|
-- Could not find player
|
2013-08-11 16:00:53 +01:00
|
|
|
return false
|
2013-07-27 16:24:03 +01:00
|
|
|
end
|
2013-08-11 16:00:53 +01:00
|
|
|
|
|
|
|
|
return true, RealName -- Player has been kicked
|
|
|
|
|
|
|
|
|
|
end
|