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

Solved Not allowing bags inside other bags.

Forgot this, D:

Try it now:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
  if toPosition.x == CONTAINER_POSITION then
     if item:isContainer() then
       if toPosition.y >= 64 then
         local container = self:getContainerById(toPosition.y-64)
         local moveToItem = container:getItem(toPosition.z)
         if container:getId() == 2000 or (moveToItem and moveToItem:getId() == 2000) then
           self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't move this item there.")
           return false
         end
       else
         local moveToItem = self:getSlotItem(toPosition.y)
         if moveToItem and moveToItem:getId() == 2000 then
           self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't move this item there.")
           return false
         end
       end
     end
  end
  return true
end

Change everywhere there its 2000 :p

I just figured it out by myself, please let me know if my code is broken or will cause me problems somehow :p

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    if toPosition.x == CONTAINER_POSITION and toPosition.y >= 64 then
        if item:isContainer() then
            local container = self:getContainerById(toPosition.y-64)
            if container:getId() == 9775 then
                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't place bags inside this item.")
                return false
            end
        end
    end
    -------------------------------------
    local moveItem = self:getSlotItem(CONST_SLOT_AMMO)
        if toPosition.y == CONST_SLOT_AMMO then
        if item:isContainer() then
            local container = self:getContainerById(toPosition.y-64)
            if item:getId() == 9775 and moveItem == nil then
            return true
            else
                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't place bags inside this item.")
                return false
            end
        end
    end           
       
    -------------------------------------
    return true
end
 
Forgot this, D:

Try it now:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
  if toPosition.x == CONTAINER_POSITION then
     if item:isContainer() then
       if toPosition.y >= 64 then
         local container = self:getContainerById(toPosition.y-64)
         local moveToItem = container:getItem(toPosition.z)
         if container:getId() == 2000 or (moveToItem and moveToItem:getId() == 2000) then
           self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't move this item there.")
           return false
         end
       else
         local moveToItem = self:getSlotItem(toPosition.y)
         if moveToItem and moveToItem:getId() == 2000 then
           self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't move this item there.")
           return false
         end
       end
     end
  end
  return true
end

Change everywhere there its 2000 :p

nevermind my previous comment, yours works flawlessly and mine still has ways to be abused lol
 
I just figured it out by myself, please let me know if my code is broken or will cause me problems somehow :p

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    if toPosition.x == CONTAINER_POSITION and toPosition.y >= 64 then
        if item:isContainer() then
            local container = self:getContainerById(toPosition.y-64)
            if container:getId() == 9775 then
                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't place bags inside this item.")
                return false
            end
        end
    end
    -------------------------------------
    local moveItem = self:getSlotItem(CONST_SLOT_AMMO)
        if toPosition.y == CONST_SLOT_AMMO then
        if item:isContainer() then
            local container = self:getContainerById(toPosition.y-64)
            if item:getId() == 9775 and moveItem == nil then
            return true
            else
                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't place bags inside this item.")
                return false
            end
        end
    end          
      
    -------------------------------------
    return true
end
Yes it will work, mine is a little bit generic but yours wont bug
 
Back
Top