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

TFS 1.X+ Block ITEMID to be moved out of house

CastorFlynn

Member
Joined
Aug 29, 2021
Messages
88
Reaction score
8
How could I block a specific item from being placed outside a house tile?

I have eventcallback on my TFS 1.X downgrade 8.6.
 
It's a wardrobe, not pickuable, but moveable.

Lua:
local items = {13537, 2152}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(fromPosition)
    local tile2 = Tile(toPosition)
    if tile then
        if tile:getHouse() then
            if tile2 then
                if not tile2:getHouse() then
                    if table.contains(items, item:getId()) then
                        self:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry, but you can not move this out of your house.')
                        return false
                    end
                end
            end
        end
    end
    return true
end

ec:register()

Action id 2000 on item
you can change it to any actionid u want

Oh I think I understand it wrong
it should not be pushed out of house only right?
 
Last edited:
Lua:
local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getActionId() == 2000 then
        self:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry, but you can not move this item.')
        return false
    end
    return true
end

ec:register()

Action id 2000 on item
you can change it to any actionid u want

Oh I think I understand it wrong
it should not be pushed out of house only right?
Yes, I just need a check for a specific ITEMID, so it can only be moved inside the house, not outside it.
 
Yes, I just need a check for a specific ITEMID, so it can only be moved inside the house, not outside it.

To be honest
Im not sure what would be the best solution for that
sry

this one is a example how to avoid people moving out items from house
Lua:
local items = {13537, 2152}

local ec = EventCallback

ec.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    local tile = Tile(toPosition)
    if tile then
        if not tile:getHouse() then
            if table.contains(items, item:getId()) then
                self:sendTextMessage(MESSAGE_INFO_DESCR, 'Sorry, but you can not move this out of your house.')
                return false
            end
        end
    end
    return true
end

ec:register()
 
That way it allowed it to move in and prevented it from moving out, but when trying to drag it out it gives this error in the distro.

Lua Script Error: [Event Interface]
data/events/scripts/player.luaPlayer@onMoveItem
data/global.lua:178: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: at 0x7ff6a688bb90
[C]: in function 'pairs'
data/global.lua:178: in function 'contains'
...ata\scripts\eventcallbacks\player\default_onMoveItem.lua:110: in function <...ata\scripts\eventcallbacks\player\default_onMoveItem.lua:30>
C:\server\data\scripts/lib\event_callbacks.lua:129: in function <C:\server\data\scripts/lib\event_callbacks.lua:125>
 
Back
Top