• 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!

Depot Block (Player Outside)

Fabi Marzan

Well-Known Member
Joined
Aug 31, 2020
Messages
135
Solutions
6
Reaction score
66
Greetings, I was trying to make a function that objects cannot be thrown in the deposit while outside an SQM.

I have the scripts but it doesn't work for me.

Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
local depotIds = {2589, 2590, 2591}
    local positionUnderDepot = {
        Position(positionPlayer.x, positionPlayer.y, positionPlayer.z), -- SQM DEPOT
    }
    
local depotLocked = true

if depotLocked and isInArray(depotIds, depotBlock) and isInArray(positionUnderDepot, fromPosition) then
        local depotBlock = Tile(toPosition):getTopDownItem():getItemById()
        self:sendCancelMessage("You can't throw items inside the depot while outside.")
        return false
end
    return true
end

A picture of context:

Screenshot_22.png
Screenshot_21.png
 
Lua:
local blocked = 1205 -- action id of item
local e = EventCallback
function e.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile then
        for _, v in pairs(tile:getItems()) do
            if v:getActionId() == blocked then
                return false
            end
        end
    end
    return true
end

e:register(-1)

Simply add the actionId to the depot box and you will not be able to throw items on them.
 
Last edited:
Lua:
local blocked = 1205 -- action id of item
local event = EventCallback
function event.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile then
        for _, v in pairs(tile:getItems()) do
            if v:getActionId() == blocked then
                return false
            end
        end
    end
    return true
end

event:register(-1)

Simply add the actionId to the depot box and you will not be able to throw items on them.
It doesn't work for me, I also see that it is to block throwing objects in the ID... my idea was to make it not allow throwing objects in the depot if you are outside. For example: if you are in front of the depot, you can drop items into it, but if you are not near the depot you will get a message such as "you cannot drop items out of the depot".
 
Lua:
local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile and tile:getItemByType(ITEM_TYPE_DEPOT) then
        if math.abs(toPosition.x - self:getPosition().x) > 1 or math.abs(toPosition.y - self:getPosition().y) > 1 then
            self:getPosition():sendMagicEffect(CONST_ME_POFF, self)
            return RETURNVALUE_NOTPOSSIBLE
        end
    end

    return RETURNVALUE_NOERROR
end

ec:register()
 
Lua:
local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile and tile:getItemByType(ITEM_TYPE_DEPOT) then
        if math.abs(toPosition.x - self:getPosition().x) > 1 or math.abs(toPosition.y - self:getPosition().y) > 1 then
            self:getPosition():sendMagicEffect(CONST_ME_POFF, self)
            return RETURNVALUE_NOTPOSSIBLE
        end
    end

    return RETURNVALUE_NOERROR
end

ec:register()
Hey, i was tested it and, still i can throw items on depot. I see magic effect on character, but Item be throwed on depot
 
As Xikini said return value can only be true or false.

Here is my take.
Lua:
local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile and tile:hasFlag(TILESTATE_DEPOT) and self:getPosition():getDistance(toPosition) > 1 then
        return false
    end

    return true
end

ec:register()
 
Back
Top