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

onMoveItem Depot or Inbox

yoiker

Member
Joined
Jan 21, 2012
Messages
194
Solutions
1
Reaction score
9
Good afternoon, in advance thanks for viewing my post because I thought this was no solution had not taken the time to ask for help because I want to do I can not, I get error ami way attempt to unite... Now I explain:

This I found on Github TheForgottenServer Pull requests; "Minimalist solution to #1753"

https://github.com/otland/forgottenserver/pull/1891/files

The item that stopped decaying on logout (bug), will return to decay after being taken out of depot or inbox

The bug which the addresses (the truth is not whether or not work) but I like to know I'm not the only one this happens. I wanted someone could help me to unite what he puts with mine...

This is my onMoveItem

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
   if item:getActionId() == NOT_MOVEABLE_ACTION then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end
 
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 26052 then
        self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end

   if toPosition.x ~= CONTAINER_POSITION then
       return true
   end

   if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
       local itemType, moveItem = ItemType(item:getId())
       if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
           moveItem = self:getSlotItem(CONST_SLOT_RIGHT)
       elseif itemType:getWeaponType() == WEAPON_SHIELD and toPosition.y == CONST_SLOT_RIGHT then
           moveItem = self:getSlotItem(CONST_SLOT_LEFT)
           if moveItem and bit.band(ItemType(moveItem:getId()):getSlotPosition(), SLOTP_TWO_HAND) == 0 then
               return true
           end
       end

       if moveItem then
           local parent = item:getParent()
           if parent:getSize() == parent:getCapacity() then
               self:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_CONTAINERNOTENOUGHROOM))
               return false
           else
               return moveItem:moveTo(parent)
           end
       end
   end
 
   if toPosition.x == CONTAINER_POSITION then
       local containerId = toPosition.y - 64
       local container = self:getContainerById(containerId)    
       if not container then
           return true
       end

       -- Do not let the player insert items into either the Reward Container or the Reward Chest
       local itemId = container:getId()    
       if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then
           self:sendCancelMessage('Sorry, not possible.')
           return false
       end

       -- The player also shouldn't be able to insert items into the boss corpse    
       local tile = Tile(container:getPosition())
       for _, item in ipairs(tile:getItems()) do
           if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 and item:getName() == container:getName() then
               self:sendCancelMessage('Sorry, not possible.')
               return false
           end
       end
   end

   -- Do not let the player move the boss corpse.
   if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end

    return true
end

I wish someone could unite what that person published on Github with mine, I'd appreciate it ;D

Sorry for my bad English xd
 
Last edited:
Lucky you, as I am the author of that pull request! hahaha
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
   if item:getActionId() == NOT_MOVEABLE_ACTION then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end

   if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 26052 then
       self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
       return false
   end

   local fc_parent_name = fromCylinder:isItem() and fromCylinder:getTopParent():getName() or ""
   local tc_parent_name = toCylinder:isItem() and toCylinder:getTopParent():getName() or ""
   if toCylinder ~= fromCylinder and tc_parent_name ~= fc_parent_name then
       if fc_parent_name == "depot chest" or fc_parent_name == "your inbox" then
           if item:hasAttribute(ITEM_ATTRIBUTE_DECAYSTATE) then
               item:decay()
           end
       end
   end

   if toPosition.x ~= CONTAINER_POSITION then
       return true
   end

   if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
       local itemType, moveItem = ItemType(item:getId())
       if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
           moveItem = self:getSlotItem(CONST_SLOT_RIGHT)
       elseif itemType:getWeaponType() == WEAPON_SHIELD and toPosition.y == CONST_SLOT_RIGHT then
           moveItem = self:getSlotItem(CONST_SLOT_LEFT)
           if moveItem and bit.band(ItemType(moveItem:getId()):getSlotPosition(), SLOTP_TWO_HAND) == 0 then
               return true
           end
       end

       if moveItem then
           local parent = item:getParent()
           if parent:getSize() == parent:getCapacity() then
               self:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_CONTAINERNOTENOUGHROOM))
               return false
           else
               return moveItem:moveTo(parent)
           end
       end
   end

   if toPosition.x == CONTAINER_POSITION then
       local containerId = toPosition.y - 64
       local container = self:getContainerById(containerId)
       if not container then
           return true
       end

       -- Do not let the player insert items into either the Reward Container or the Reward Chest
       local itemId = container:getId()
       if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then
           self:sendCancelMessage('Sorry, not possible.')
           return false
       end

       -- The player also shouldn't be able to insert items into the boss corpse
       local tile = Tile(container:getPosition())
       for _, item in ipairs(tile:getItems()) do
           if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 and item:getName() == container:getName() then
               self:sendCancelMessage('Sorry, not possible.')
               return false
           end
       end
   end

   -- Do not let the player move the boss corpse.
   if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end

   return true
end
 
Lucky you, as I am the author of that pull request! hahaha
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
   if item:getActionId() == NOT_MOVEABLE_ACTION then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end

   if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 26052 then
       self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
       return false
   end

   local fc_parent_name = fromCylinder:isItem() and fromCylinder:getTopParent():getName() or ""
   local tc_parent_name = toCylinder:isItem() and toCylinder:getTopParent():getName() or ""
   if toCylinder ~= fromCylinder and tc_parent_name ~= fc_parent_name then
       if fc_parent_name == "depot chest" or fc_parent_name == "your inbox" then
           if item:hasAttribute(ITEM_ATTRIBUTE_DECAYSTATE) then
               item:decay()
           end
       end
   end

   if toPosition.x ~= CONTAINER_POSITION then
       return true
   end

   if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
       local itemType, moveItem = ItemType(item:getId())
       if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
           moveItem = self:getSlotItem(CONST_SLOT_RIGHT)
       elseif itemType:getWeaponType() == WEAPON_SHIELD and toPosition.y == CONST_SLOT_RIGHT then
           moveItem = self:getSlotItem(CONST_SLOT_LEFT)
           if moveItem and bit.band(ItemType(moveItem:getId()):getSlotPosition(), SLOTP_TWO_HAND) == 0 then
               return true
           end
       end

       if moveItem then
           local parent = item:getParent()
           if parent:getSize() == parent:getCapacity() then
               self:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_CONTAINERNOTENOUGHROOM))
               return false
           else
               return moveItem:moveTo(parent)
           end
       end
   end

   if toPosition.x == CONTAINER_POSITION then
       local containerId = toPosition.y - 64
       local container = self:getContainerById(containerId)
       if not container then
           return true
       end

       -- Do not let the player insert items into either the Reward Container or the Reward Chest
       local itemId = container:getId()
       if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then
           self:sendCancelMessage('Sorry, not possible.')
           return false
       end

       -- The player also shouldn't be able to insert items into the boss corpse
       local tile = Tile(container:getPosition())
       for _, item in ipairs(tile:getItems()) do
           if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 and item:getName() == container:getName() then
               self:sendCancelMessage('Sorry, not possible.')
               return false
           end
       end
   end

   -- Do not let the player move the boss corpse.
   if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2^31 - 1 then
       self:sendCancelMessage('Sorry, not possible.')
       return false
   end

   return true
end

Well I do not I imagined hahaha, but there is an error in this line;
Code:
local fc_parent_name = fromCylinder:isItem() and fromCylinder:getTopParent():getName() or ""

Player@onMoveItem 'fromCylinder'

You have a solution?

EDIT:
When I try to launch the item to the soil or the error rate depot, and when I try to pick the same
 
Last edited:
Curious, never knew it was possible for fromCylinder to be nil, could you give me step by step of what you're doing so I can reproduce this here?
 
Back
Top