Impossible to prevent bucket item use
#5
local sql = "SELECT towns.town_id, towns.nation_id, towns.town_permissions FROM townChunks INNER JOIN towns ON townChunks.town_id = towns.town_id WHERE chunkX = ? AND chunkZ = ? AND world = ?";
    local parameters = {math.floor(BlockX / 16), math.floor(BlockZ / 16), Player:GetWorld():GetName()};
    local town = ExecuteStatement(sql, parameters)[1];

    if not (town) then --The item is used on a block that is not part of a town, so it's allowed
        return false;
    else
        if (town[1] == GetPlayerTown(Player:GetUUID())) then
            allowed = CheckPermission(town[3], RESIDENTITEMUSE);
        else
            if (town[2] == GetPlayerNation(Player:GetUUID())) then
                allowed = CheckPermission(town[3], ALLYITEMUSE);
            else
                allowed = CheckPermission(town[3], OUTSIDERITEMUSE);
            end
        end

        if (allowed == true) then
            if (ItemToString(Player:GetEquippedItem()) == "lighter") then
                local sql = "SELECT towns.town_id, towns.town_fire_enabled FROM towns INNER JOIN townChunks ON towns.town_id = townChunks.town_id WHERE townChunks.chunkX = ? AND townChunks.chunkZ = ? AND townChunks.world = ?";
                local parameters = {math.floor(BlockX / 16), math.floor(BlockZ / 16), Player:GetWorld():GetName()};
                local town = ExecuteStatement(sql, parameters)[1];

                if (town and town[2] == 0) then --If fire is disabled in this town, prevent the player from starting a fire
                    return true; --Prevent item use
                else
                    return false; --Allow item use
                end
            else
                return false; --Allow item use
            end
        else
            return true; --Prevent item use
        end
    end
The CheckPermission function returns either true or false depending on if it's allowed or not.
Reply
Thanks given by:


Messages In This Thread
RE: Impossible to prevent bucket item use - by PureTryOut - 09-10-2016, 06:26 AM



Users browsing this thread: 2 Guest(s)