• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua TFS 1.2 onMoveItem

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,461
Solutions
68
Reaction score
1,123
I am trying to make it so players cant put bags inside other bags. There is only 1 bag they can put other bags in.

I have everything working but when I try to move a backpack onto the ground or move it anywhere but on my person it doesnt register me moving it....Here is the code:

Code:
if isInArray(bags, item:getId()) and isInArray(bags, toCylinder:getId()) then
        self:sendCancelMessage('You cannot put bags inside bags.')
        return false
    end
 
Solution
So the problem was:

item:getId()

Apparently you cannot use getId() in this instance. I changed to item.itemid and it fixed everything.

Here is the code

LUA:
local bags = {1998, 1988}
if isInArray(bags, item.itemid) and isInArray(bags, toCylinder.itemid) then
        self:sendCancelMessage('You cannot put bags inside bags.')
        return false
end
It means that he cant move backpacks
i know.
i'm wondering what it tells him when he tries to move it and what he means by not registering, the way he worded it makes it sound like the function isn't being executed at all for some reason which is why im questioning it
 
Code:
if toPosition.x == CONTAINER_POSITION then
    local containerId = toPosition.y - 64
    local container = self:getContainerById(containerId)    
    if not container then
        return true
    end
 
    local ITEM_BAG = 1987    
    if container:getId() == ITEM_BAG and item:getId() == ITEM_BAG then
        self:sendCancelMessage('You cannot put bags inside bags.')
        return false
    end
end

This should prevent putting bag into bag, but you still can insert bag into bag when the bag is not open and it is in your main or other backpack slot(also if you got bags in corpse then you can insert bag to corpse bag).
I have no idea how to check toposition slot in container.
 
So the problem was:

item:getId()

Apparently you cannot use getId() in this instance. I changed to item.itemid and it fixed everything.

Here is the code

LUA:
local bags = {1998, 1988}
if isInArray(bags, item.itemid) and isInArray(bags, toCylinder.itemid) then
        self:sendCancelMessage('You cannot put bags inside bags.')
        return false
end
 
Solution
Back
Top