ramsaii
New Member
- Joined
- Mar 1, 2008
- Messages
- 5
- Reaction score
- 0
I'm having a problem in a script I have written. It allows you to cut down trees, and then transforms the tree into a brough. I want the tree to respawn after a set amount of time, however I'm having a problem with my addEvent function. I am pretty sure I am using it correctly:
Ok, for some reason it doesn't call the onTime function at all, so "Got here." never gets displayed over my characters head. I know some code is unnecessary, I just haven't cleaned it up yet. What am I doing wrong? Thanks in advance for all input.
Code:
function onUse(cid, item, frompos, item2, topos)
if item2.itemid == 2707 or item2.itemid == 2708 or item2.itemid == 2701 or item2.itemid == 2702 or item2.itemid == 2703 or item2.itemid == 2706 then
axeskill = getPlayerSkill(cid,3)
formula = axeskill /200+0.85* math.random()
playerPos = getCreaturePosition(cid)
if formula > 0.70 then
doSendMagicEffect(topos,3)
doPlayerAddItem(cid,5901,1)
doPlayerAddSkillTry(cid,3,2)
doPlayerSendTextMessage(cid,22,"You have successfully chopped down the tree!")
elseif formula < 0.30 then
addEvent(onTime,1000,a)
doTransformItem(item2.uid,2770)
doDecayItem(item2.uid)
doSendMagicEffect(topos,2)
doPlayerSendTextMessage(cid,22,"You destroyed the tree!")
doPlayerAddSkillTry(cid,3,1)
else
doSendMagicEffect(topos,2)
doPlayerAddSkillTry(cid,3,1)
doPlayerSendTextMessage(cid,22,"You failed at chopping down the tree.")
end
end
treeDecay = math.random()
if treeDecay < 0.90 then
doDecayItem(item2.uid)
end
end
function onTime(a)
doPlayerSendTextMessage(cid,22,"Got here.")
end
Ok, for some reason it doesn't call the onTime function at all, so "Got here." never gets displayed over my characters head. I know some code is unnecessary, I just haven't cleaned it up yet. What am I doing wrong? Thanks in advance for all input.
Last edited by a moderator: