2012-01-26 17:44:37 -05:00
|
|
|
function HandleBanCommand( Split, Player )
|
|
|
|
if( #Split < 2 ) then
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] <Reason>" )
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local Reason = "You have been banned"
|
|
|
|
if( #Split > 2 ) then
|
|
|
|
Reason = table.concat(Split, " ", 3)
|
|
|
|
end
|
2012-10-11 10:30:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
if( BanPlayer(Split[2], Reason) == false ) then
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
|
|
|
|
return true
|
|
|
|
end
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2012-10-11 10:30:28 -04:00
|
|
|
return true
|
|
|
|
end
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2013-06-29 11:30:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function BanPlayer(PlayerName, Reason)
|
|
|
|
-- Ban the player in the banned.ini:
|
|
|
|
BannedPlayersIni:SetValueB("Banned", PlayerName, true)
|
|
|
|
BannedPlayersIni:WriteFile()
|
|
|
|
|
|
|
|
-- Kick the player:
|
|
|
|
if (Reason == nil) then
|
2012-10-11 10:30:28 -04:00
|
|
|
Reason = "You have been banned"
|
|
|
|
end
|
2013-06-29 11:30:05 -04:00
|
|
|
local Success = KickPlayer(PlayerName, Reason)
|
|
|
|
if (not(Success)) then
|
|
|
|
return false;
|
2012-10-11 10:30:28 -04:00
|
|
|
end
|
|
|
|
|
2013-06-29 11:30:05 -04:00
|
|
|
LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") ");
|
|
|
|
local Server = cRoot:Get():GetServer();
|
|
|
|
Server:SendMessage("Banned " .. PlayerName);
|
2012-10-11 10:30:28 -04:00
|
|
|
|
2012-01-26 17:44:37 -05:00
|
|
|
return true
|
|
|
|
end
|