viking
Member
- Joined
- Aug 20, 2015
- Messages
- 323
- Reaction score
- 22
Hello,
I'm trying to do when the player trying to put more than 10 items in the same sqm, not be possible. But it is giving me error (nil value in line 227).
Help?
Script:
Code in Events/Scripts/Player.lua:
I'm trying to do when the player trying to put more than 10 items in the same sqm, not be possible. But it is giving me error (nil value in line 227).
Help?
Script:
Code in Events/Scripts/Player.lua:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
if toPosition.x == CONTAINER_POSITION then
local cid = toPosition.y - 64 -- container id
local container = self:getContainerById(cid)
if not container then
return true
end
local tileCount = Tile(toPosition):getItemCount()
if tileCount > 10 then
self:sendCancelMessage('Sorry, not possible.')
return false
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