2012-01-26 17:44:37 -05:00
|
|
|
function HandleKickCommand( Split, Player )
|
|
|
|
if( #Split < 2 ) then
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] <Reason>" )
|
|
|
|
return true
|
|
|
|
end
|
2012-08-22 19:05:12 -04:00
|
|
|
|
2012-10-11 10:30:28 -04:00
|
|
|
local Reason = "You have been kicked"
|
|
|
|
if( #Split > 2 ) then
|
|
|
|
Reason = table.concat(Split, " ", 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
if( KickPlayer( Split[2], Reason ) == false ) then
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function KickPlayer( PlayerName, Reason )
|
|
|
|
local RealName = ""
|
2012-08-22 19:05:12 -04:00
|
|
|
local FoundPlayerCallback = function( OtherPlayer )
|
2012-10-11 10:30:28 -04:00
|
|
|
if( Reason == nil ) then
|
|
|
|
Reason = "You have been kicked"
|
2012-08-22 19:05:12 -04:00
|
|
|
end
|
2012-10-11 10:30:28 -04:00
|
|
|
|
|
|
|
RealName = OtherPlayer:GetName()
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2012-08-22 19:05:12 -04:00
|
|
|
local Server = cRoot:Get():GetServer()
|
2012-10-11 10:30:28 -04:00
|
|
|
LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
|
|
|
|
Server:SendMessage( "Kicking " .. RealName )
|
2012-08-22 19:05:12 -04:00
|
|
|
|
|
|
|
local ClientHandle = OtherPlayer:GetClientHandle()
|
|
|
|
ClientHandle:Kick( Reason )
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
|
|
|
|
2012-10-11 10:30:28 -04:00
|
|
|
if( cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback ) == false ) then
|
|
|
|
return false -- could not find player
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
2012-10-11 10:30:28 -04:00
|
|
|
|
|
|
|
return true, RealName -- player should be kicked now
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|