• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Depot Block (Player Outside)

Fabi Marzan

Member
Joined
Aug 31, 2020
Messages
61
Solutions
1
Reaction score
11
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
 

J.Dre

Unity Gaming LLC
Premium User
Joined
May 18, 2011
Messages
2,638
Solutions
3
Reaction score
635
Location
United States
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:
OP
OP
Fabi Marzan

Fabi Marzan

Member
Joined
Aug 31, 2020
Messages
61
Solutions
1
Reaction score
11
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".
 

Alberto Cabrera

Well-Known Member
Joined
Sep 17, 2020
Messages
74
Solutions
17
Reaction score
70
Location
México
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()
 

vexler222

Member
Joined
Apr 22, 2012
Messages
618
Solutions
13
Reaction score
23
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
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
324
Solutions
16
Reaction score
277
Location
Sweden
GitHub
forgee
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()
 
Top