diff --git a/Plugins/Core/onblockplace.lua b/Plugins/Core/onblockplace.lua index 45d9a082..64ab5492 100644 --- a/Plugins/Core/onblockplace.lua +++ b/Plugins/Core/onblockplace.lua @@ -1,5 +1,3 @@ -local BlockData = {} - function OnBlockPlace( Block, Player ) -- dont check if the direction is in the air @@ -12,8 +10,39 @@ function OnBlockPlace( Block, Player ) if( Y >= 128 or Y < 0 ) then return true end + + local CheckCollision = function( Player ) + -- drop the decimals, we only care about the full block X,Y,Z + local PlayerX = math.floor(Player:GetPosX(), 0) + local PlayerY = math.floor(Player:GetPosY(), 0) + local PlayerZ = math.floor(Player:GetPosZ(), 0) - BlockData = Block + local BlockX = Block.m_PosX + local BlockY = Block.m_PosY + local BlockZ = Block.m_PosZ + + -- player height is 2 blocks, so we check the position and then offset it up one + -- so they can't place a block on there face + + local collision = false + if Block.m_Direction == 0 then if PlayerY == BlockY-2 and PlayerX == BlockX and PlayerZ == BlockZ then collision = true end end + if Block.m_Direction == 1 then if PlayerY == BlockY+1 and PlayerX == BlockX and PlayerZ == BlockZ then collision = true end end + + if Block.m_Direction == 2 then if PlayerY == BlockY and PlayerX == BlockX and PlayerZ == BlockZ-1 then collision = true end end + if Block.m_Direction == 2 then if PlayerY+1 == BlockY and PlayerX == BlockX and PlayerZ == BlockZ-1 then collision = true end end + + if Block.m_Direction == 3 then if PlayerY == BlockY and PlayerX == BlockX and PlayerZ == BlockZ+1 then collision = true end end + if Block.m_Direction == 3 then if PlayerY+1 == BlockY and PlayerX == BlockX and PlayerZ == BlockZ+1 then collision = true end end + + if Block.m_Direction == 4 then if PlayerY == BlockY and PlayerX == BlockX-1 and PlayerZ == BlockZ then collision = true end end + if Block.m_Direction == 4 then if PlayerY+1 == BlockY and PlayerX == BlockX-1 and PlayerZ == BlockZ then collision = true end end + + if Block.m_Direction == 5 then if PlayerY == BlockY and PlayerX == BlockX+1 and PlayerZ == BlockZ then collision = true end end + if Block.m_Direction == 5 then if PlayerY+1 == BlockY and PlayerX == BlockX+1 and PlayerZ == BlockZ then collision = true end end + + return collision + end + if( Player:GetWorld():ForEachPlayer( CheckCollision ) == false ) then return true else @@ -24,36 +53,4 @@ function OnBlockPlace( Block, Player ) return false -end - -function CheckCollision( Player ) - -- drop the decimals, we only care about the full block X,Y,Z - local PlayerX = math.floor(Player:GetPosX(), 0) - local PlayerY = math.floor(Player:GetPosY(), 0) - local PlayerZ = math.floor(Player:GetPosZ(), 0) - - local BlockX = BlockData.m_PosX - local BlockY = BlockData.m_PosY - local BlockZ = BlockData.m_PosZ - - -- player height is 2 blocks, so we check the position and then offset it up one - -- so they can't place a block on there face - - local collision = false - if BlockData.m_Direction == 0 then if PlayerY == BlockY-2 and PlayerX == BlockX and PlayerZ == BlockZ then collision = true end end - if BlockData.m_Direction == 1 then if PlayerY == BlockY+1 and PlayerX == BlockX and PlayerZ == BlockZ then collision = true end end - - if BlockData.m_Direction == 2 then if PlayerY == BlockY and PlayerX == BlockX and PlayerZ == BlockZ-1 then collision = true end end - if BlockData.m_Direction == 2 then if PlayerY+1 == BlockY and PlayerX == BlockX and PlayerZ == BlockZ-1 then collision = true end end - - if BlockData.m_Direction == 3 then if PlayerY == BlockY and PlayerX == BlockX and PlayerZ == BlockZ+1 then collision = true end end - if BlockData.m_Direction == 3 then if PlayerY+1 == BlockY and PlayerX == BlockX and PlayerZ == BlockZ+1 then collision = true end end - - if BlockData.m_Direction == 4 then if PlayerY == BlockY and PlayerX == BlockX-1 and PlayerZ == BlockZ then collision = true end end - if BlockData.m_Direction == 4 then if PlayerY+1 == BlockY and PlayerX == BlockX-1 and PlayerZ == BlockZ then collision = true end end - - if BlockData.m_Direction == 5 then if PlayerY == BlockY and PlayerX == BlockX+1 and PlayerZ == BlockZ then collision = true end end - if BlockData.m_Direction == 5 then if PlayerY+1 == BlockY and PlayerX == BlockX+1 and PlayerZ == BlockZ then collision = true end end - - return collision end \ No newline at end of file diff --git a/Plugins/Core/playerlist.lua b/Plugins/Core/playerlist.lua index 63990e82..f06dfed8 100644 --- a/Plugins/Core/playerlist.lua +++ b/Plugins/Core/playerlist.lua @@ -1,7 +1,9 @@ -local PlayerTable = {} - function HandlePlayerListCommand( Split, Player ) - PlayerTable = {} + + local PlayerTable = {} + local AppendToTable = function( Player ) + table.insert(PlayerTable, Player:GetName() ) + end Player:GetWorld():ForEachPlayer( AppendToTable ) local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")" @@ -9,8 +11,4 @@ function HandlePlayerListCommand( Split, Player ) Player:SendMessage( table.concat(PlayerTable, " ") ) return true -end - -function AppendToTable( Player ) - table.insert(PlayerTable, Player:GetName() ) end \ No newline at end of file diff --git a/Plugins/Core/web_playerlist.lua b/Plugins/Core/web_playerlist.lua index 62ccb1d4..ed6b7667 100644 --- a/Plugins/Core/web_playerlist.lua +++ b/Plugins/Core/web_playerlist.lua @@ -1,6 +1,3 @@ -local PlayerHTML = "" -local PlayerNum = 0 - function HandleRequest_PlayerList( Request ) local World = cRoot:Get():GetWorld() local Content = "" @@ -19,25 +16,21 @@ function HandleRequest_PlayerList( Request ) Content = Content .. "
Connected Players: " .. World:GetNumPlayers() .. "
" Content = Content .. "" .. PlayerNum .. ". | " + Content = Content .. "" .. Player:GetName() .. " | " + Content = Content .. "Kick | " + Content = Content .. "
None |