Skip to content

Commit

Permalink
Merge pull request #160 from mc-server/FixHardcoreBan
Browse files Browse the repository at this point in the history
Fixed banning for death in hardcore mode.
  • Loading branch information
madmaxoft committed Nov 27, 2015
2 parents 0838838 + d09db0f commit acff3c8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion banlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end

--- Adds the specified player to the banlist, with the specified ban reason
-- Resolves the player UUID, if needed, but only through cache, not to block
local function AddPlayerToBanlist(a_PlayerName, a_Reason, a_BannedBy)
function AddPlayerToBanlist(a_PlayerName, a_Reason, a_BannedBy)
-- Check params:
assert(type(a_PlayerName) == "string")
assert(type(a_BannedBy) == "string")
Expand Down
11 changes: 3 additions & 8 deletions functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,9 @@ function ReturnColorFromChar(char)

end

function CheckHardcore(Victim)
if cRoot:Get():GetServer():IsHardcore() then
if Victim:IsPlayer() == true then
BannedPlayersIni:SetValueB( "Banned", tolua.cast(Victim, "cPlayer"):GetName(), true )
BannedPlayersIni:WriteFile( "banned.ini" )
end
end
end




-- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player
function TeleportToPlayer( a_SrcPlayer, a_DstPlayerName, a_TellDst )
Expand Down
7 changes: 0 additions & 7 deletions ondeath.lua

This file was deleted.

24 changes: 24 additions & 0 deletions onkilling.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

-- onkilling.lua

-- Implements the OnKilling hook handler that effectively implements the hardcore mode of the server





--- Handler for the HOOK_KILLING hook
-- If the server is in hardcore mode, bans the killed player
function OnKilling(a_Victim, a_Killer)
if (a_Victim:IsPlayer()) then
if (cRoot:Get():GetServer():IsHardcore()) then
AddPlayerToBanlist(a_Victim:GetName(), "Killed in hardcore mode", "Server-Core")
end
end

return false
end




0 comments on commit acff3c8

Please sign in to comment.