From d09db0f1126058584eafd7460e679e88715c898f Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 26 Nov 2015 23:02:29 +0100 Subject: [PATCH] Fixed banning for death in hardcore mode. Fixes #159. --- banlist.lua | 2 +- functions.lua | 11 +++-------- ondeath.lua | 7 ------- onkilling.lua | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 16 deletions(-) delete mode 100644 ondeath.lua create mode 100644 onkilling.lua diff --git a/banlist.lua b/banlist.lua index c03a7b1..58bc94b 100644 --- a/banlist.lua +++ b/banlist.lua @@ -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") diff --git a/functions.lua b/functions.lua index 27a7fbc..5da5cfe 100644 --- a/functions.lua +++ b/functions.lua @@ -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 ) diff --git a/ondeath.lua b/ondeath.lua deleted file mode 100644 index 4f3837e..0000000 --- a/ondeath.lua +++ /dev/null @@ -1,7 +0,0 @@ -function OnKilling(Victim, Killer) - if Victim:IsPlayer() then - CheckHardcore(Victim) - end - - return false -end diff --git a/onkilling.lua b/onkilling.lua new file mode 100644 index 0000000..09da43b --- /dev/null +++ b/onkilling.lua @@ -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 + + + +