From 0433de9955d500c6ab8b6819e4f64c06a7317f98 Mon Sep 17 00:00:00 2001 From: faketruth Date: Thu, 11 Oct 2012 14:30:28 +0000 Subject: Core: made ban and kick functions accessible to other plugins Core: fixed banning and whitelisting in OnLogin git-svn-id: http://mc-server.googlecode.com/svn/trunk@947 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/Core/kick.lua | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'MCServer/Plugins/Core/kick.lua') diff --git a/MCServer/Plugins/Core/kick.lua b/MCServer/Plugins/Core/kick.lua index ce8bd7a31..5004c8c2f 100644 --- a/MCServer/Plugins/Core/kick.lua +++ b/MCServer/Plugins/Core/kick.lua @@ -4,26 +4,39 @@ function HandleKickCommand( Split, Player ) return true end + 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 = "" local FoundPlayerCallback = function( OtherPlayer ) - local Reason = "You have been kicked" - if( #Split > 2 ) then - Reason = table.concat(Split, " ", 3) + if( Reason == nil ) then + Reason = "You have been kicked" end + + RealName = OtherPlayer:GetName() local Server = cRoot:Get():GetServer() - LOGINFO( Player:GetName() .. " is kicking " .. OtherPlayer:GetName() .. " ( "..Reason..") " ) - Server:SendMessage( "Kicking " .. OtherPlayer:GetName() ) + LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " ) + Server:SendMessage( "Kicking " .. RealName ) local ClientHandle = OtherPlayer:GetClientHandle() ClientHandle:Kick( Reason ) end - if( cRoot:Get():FindAndDoWithPlayer( Split[2], FoundPlayerCallback ) == false ) then - Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] ) - return true + if( cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback ) == false ) then + return false -- could not find player end - - - - return true + + return true, RealName -- player should be kicked now end \ No newline at end of file -- cgit v1.2.3