Cuberite Forum
Making the door entity non-usable - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Making the door entity non-usable (/thread-2460.html)



Making the door entity non-usable - JonnyBoy0719 - 06-04-2016

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


RE: Making the door entity non-usable - NiLSPACE - 06-04-2016

Could you try the OnPlayerRightClick hook instead of the OnPlayerUsingBlock hook?


RE: Making the door entity non-usable - JonnyBoy0719 - 06-04-2016

OnPlayerRightClick sadly doesn't work, tried it at first. Its missing BlockType variable, so it just gives me a nil value instead


RE: Making the door entity non-usable - NiLSPACE - 06-04-2016

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




RE: Making the door entity non-usable - JonnyBoy0719 - 06-04-2016

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

Cheers @NiLSPACE !Big Grin


RE: Making the door entity non-usable - NiLSPACE - 06-04-2016

No problem Smile