I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).
I'm making it possible to pluck fruits from certain trees but running into a problem when I want the trees to transform back after x times to be full with fruits again.
Any help is welcome.
Thanks in advance.
I'm making it possible to pluck fruits from certain trees but running into a problem when I want the trees to transform back after x times to be full with fruits again.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.itemid == 4006 then
local rand = math.random(1, 50)
if rand < 2 then
doTransformItem(itemEx.uid, 4008)
doPlayerAddItem(cid, 2675, 5)
doCreatureSay(cid, "You collected 5 oranges.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 50000)
elseif rand < 8 then
doTransformItem(itemEx.uid, 4008)
doPlayerAddItem(cid, 2675, 4)
doCreatureSay(cid, "You collected 4 oranges.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 40000)
elseif rand < 19 then
doTransformItem(itemEx.uid, 4008)
doPlayerAddItem(cid, 2675, 3)
doCreatureSay(cid, "You collected 3 oranges.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 30000)
elseif rand < 30 then
doTransformItem(itemEx.uid, 4008)
doPlayerAddItem(cid, 2675, 2)
doCreatureSay(cid, "You collected 2 oranges.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 20000)
elseif rand < 45 then
doTransformItem(itemEx.uid, 4008)
doPlayerAddItem(cid, 2675, 1)
doCreatureSay(cid, "You collected 1 orange.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 10000)
else
doTransformItem(itemEx.uid, 4008)
doCreatureSay(cid, "You failed to collect any oranges.", TALKTYPE_ORANGE_1)
addEvent(transformBack, 5000)
end
end
end
Any help is welcome.
Thanks in advance.