Eduardo170
Well-Known Member
I've been create a ChestSystem.
The only problem is
You have found a chest weighing 69636000 oz it's too heavy.
This happen in alls chests.
The only problem is
You have found a chest weighing 69636000 oz it's too heavy.
This happen in alls chests.
Code:
<action uniqueid="28886" script="chestSystem.lua" />
<action uniqueid="28888" script="chestSystem.lua" />
<action uniqueid="28887" script="chestSystem.lua" />
Code:
local config = {
[28886] = {rewards = 2326, count= 1, storage = 28501},
[28888] = {rewards = 5803, count= 1, storage = 28500},
[28887] = {rewards = 2160, count= 50, storage = 28502},
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local chests = config[item.uid]
local playerCap = player:getFreeCapacity()
local itemType = ItemType(item.itemid)
local itemWeight = itemType:getWeight()
if player:getStorageValue(chests.storage) == -1 then
if playerCap >= itemWeight then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. itemType:getName() .. '.')
player:addItem(chests.rewards, chests.count)
player:setStorageValue(chests.storage, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. itemType:getName() .. ' weighing ' .. itemWeight ..' oz it\'s too heavy.')
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
end
return true
end
Last edited: