Cuberite Forum

Full Version: Making the door entity non-usable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Trying to get the door to be non-usable if you are trying to open another player's door if you aren't on their 'buddy' list. atm I'm just using the following code:

Code:
PrivatePlayerData = {
    54,
    64,
    61,
    71,
    193,
    194,
    195,
    196,
    197,
}

function OnPlayerUsingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType, BlockMeta)
    for k,v in pairs(PrivatePlayerData) do
        if (v == BlockType) then
            Player:SendMessageWarning("BlockType :: " .. BlockType)
            return true
        end
    end
end


It works fine with chests, the furnace and reads the ID's of the doors. but still opens them. Any help would be appreciated! Smile
Could you try the OnPlayerRightClick hook instead of the OnPlayerUsingBlock hook?
OnPlayerRightClick sadly doesn't work, tried it at first. Its missing BlockType variable, so it just gives me a nil value instead
Use this:
function OnPlayerRightClick(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ)
	if (BlockFace == BLOCK_FACE_NONE) then
		return false
	end
	local BlockType = Player:GetWorld():GetBlock(BlockX, BlockY, BlockZ)
	local BlockMeta = Player:GetWorld():GetBlockMeta(BlockX, BlockY, BlockZ)
	-- Your code
end

oh wow, why didn't i think of that.Tongue

Cheers !Big Grin
No problem Smile