• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Block push players in protection zone.

OTcreator

Well-Known Member
Joined
Feb 14, 2022
Messages
503
Solutions
1
Reaction score
57
Hi,
Is there any option to block the ability to move a player when they are in a certain area, are in PZ or have a certain storage value?
The idea is , that a player makes a push on a player and moves him away from training dummy which interrupts skilling.
 
Solution
LUA:
local ec = EventCallback

function ec.onMoveCreature(player, creature, fromPosition, toPosition)
    if not player or not creature:isPlayer() then
        return true
    end
    if creature:getStorageValue(592) == 1 then
        -- What ever you want to send the player who tried to push the other player
        return false
    end
    return true
end

ec:register()

Yes
If you give player a storage anyway then u can use storage check as I did on the script to avoid the push
LUA:
local ec = EventCallback

function ec.onMoveCreature(player, creature, fromPosition, toPosition)
    if not player or not creature:isPlayer() then
        return true
    end
    if creature:getStorageValue(592) == 1 then
        -- What ever you want to send the player who tried to push the other player
        return false
    end
    return true
end

ec:register()

Yes
If you give player a storage anyway then u can use storage check as I did on the script to avoid the push
 
Solution
Figured I'd throw in the other 2 types as well, since they were asked for.
LUA:
local ec = EventCallback

function ec.onMoveCreature(player, creature, fromPosition, toPosition)
    if not player or not creature:isPlayer() then
        return true
    end
    if creature:getZone() == ZONE_PROTECTION then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
    return true
end

ec:register()
LUA:
local ec = EventCallback

local from = Position(999, 999, 7)  -- Top-left corner of the area
local to = Position(1000, 1000, 7)    -- Bottom-right corner of the area

function ec.onMoveCreature(player, creature, fromPosition, toPosition)
    if not player or not creature:isPlayer() then
        return true
    end
    if creature:getPosition():isInRange(from, to) then
        player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end
    return true
end

ec:register()
 
LUA:
local ec = EventCallback

function ec.onMoveCreature(player, creature, fromPosition, toPosition)
    if not player or not creature:isPlayer() then
        return true
    end
    
    local tile = Tile(toPosition)
    if not tile then
       return true
    end
    
    if tile:hasFlag(TILESTATE_PROTECTIONZONE) then
       player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
       return false
    end
    
    
    return true
end

ec:register()
 
  • The version of @Marko999x goes straight to the point, verify storage values.
  • The version of @Xikini, verify Zones and ranges; verifying zones is the best option, the most optimized.
  • The version of @Dakos verifies Flags of the tiles; this is the worst option if you only want to verify the protection zone.
 
  • The version of @Marko999x goes straight to the point, verify storage values.
  • The version of @Xikini, verify Zones and ranges; verifying zones is the best option, the most optimized.
  • The version of @Dakos verifies Flags of the tiles; this is the worst option if you only want to verify the protection zone.
? if it supposed to check creature tile after being pushed its the best way, maybe i missunderstood the request
 

Similar threads

Back
Top