From f746d17424a071c15fd5b92bc521ce832ba15a07 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 4 Jun 2013 21:05:33 +0000 Subject: ProtectionAreas: Actual protection is now working, areas are hard-coded (10,10) - (20,20) git-svn-id: http://mc-server.googlecode.com/svn/trunk@1557 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- MCServer/Plugins/ProtectionAreas/HookHandlers.lua | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'MCServer/Plugins/ProtectionAreas/HookHandlers.lua') diff --git a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua index 4f1e3755e..d0748a8a4 100644 --- a/MCServer/Plugins/ProtectionAreas/HookHandlers.lua +++ b/MCServer/Plugins/ProtectionAreas/HookHandlers.lua @@ -21,7 +21,7 @@ end function OnDisconnect(a_Player, a_Reason) -- Remove the player's cProtectionArea object -- TODO: What if there are two players with the same name? need to check - g_PlayerAreas[a_Player:GetName()] = nil; + g_PlayerAreas[a_Player:GetUniqueID()] = nil; -- If the player is a VIP, they had a command state, remove that as well g_CommandStates[a_Player:GetUniqueID()] = nil; @@ -34,10 +34,12 @@ end; function OnPlayerJoined(a_Player) - -- Create a new cProtectionArea for this player - g_PlayerAreas[a_Player:GetName()] = cPlayerAreas:new(); - - -- TODO: Load the protection areas for this player + -- Create a new cPlayerAreas object for this player + local PlayerName = a_Player:GetName(); + local PlayerID = a_Player:GetUniqueID(); + if (g_PlayerAreas[PlayerID] == nil) then + g_PlayerAreas[PlayerID] = g_Storage:LoadPlayerAreas(PlayerName); + end; return false; end @@ -63,8 +65,13 @@ function OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, return true; end; - -- TODO: Check the player areas to see whether to disable this action + -- Check the player areas to see whether to disable this action + local Areas = g_PlayerAreas[a_Player:GetUniqueID()]; + if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockY, a_BlockZ)) then + return true; + end + -- Allow interaction return false; end @@ -89,8 +96,13 @@ function OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, return true; end; - -- TODO: Check the player areas to see whether to disable this action + -- Check the player areas to see whether to disable this action + local Areas = g_PlayerAreas[a_Player:GetUniqueID()]; + if not(Areas:CanInteractWithBlock(a_BlockX, a_BlockY, a_BlockZ)) then + return true; + end + -- Allow interaction return false; end -- cgit v1.2.3