local cfirst = {
pickId = 2553
storage = 1500
action = 1500
reward = 2152
}
local csecond = {
storage = 1501
itemid = xxxx
action = 1501
toPos = Position(1000,1000,7)
days = 1
}
local cthird = {
useid = xxxx
storage = 1502
fromid = 1738
toid = 2250
reward = 2152
timer = 10
}
local firstrewardtype = ItemType(cfirst.reward)
local thirdrewardtype = ItemType(cthird.reward)
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerCap = player:getCapacity()
if item:getId() == cfirst.pickId and target:getActionId() == cfirst.action then
if player:getStorageValue(cfirst.storage) ~= 1 then
if playerCap > firstrewardtype:getCapacity() then
player:addItem(cfirst.reward, 1)
player:setStorageValue(cfirst.storage,1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR,"You dug up a "..firstrewardtype:getName().." but weighing "..firstrewardtype:getCapacity().." it is too heavy.")
end
else
return false
end
elseif item:getId() == csecond.itemid and target:getActionId() == csecond.action then
if player:getStorageValue(csecond.storage) > os.time() then
player:sendTextMessage(MESSAGE_INFO_DESCR,"You can only do this once per day.")
return false
else
player:teleportTo(csecond.toPos)
player:setStorageValue(csecond.storage, os.time() + csecond.days * 24 * 60 * 60)
end
elseif item:getId() == cthird.useid and target:getActionId() == cthird.action then
if player:getStorageValue(cthird.storage) ~= 1 then
if playerCap > thirdrewardtype:getCapacity() then
target:transform(cthird.toid)
player:addItem(cthird.reward,1)
player:setStorageValue(cthird.storage,1)
addEvent(function()
target:transform(cthird.fromid)
end,cthird.timer*1000)
else
player:sendTextMessage(MESSAGE_INFO_DESCR,"You found a "..thirdrewardtype:getName().." but weighing "..thirdrewardtype:getCapacity().." it is too heavy.")
return false
end
end
end
return true
end