Jfrye
Mapper, trying to learn scripting
Im using tfs 1.1 on 10.77 client. I have managed to make a fruit tree script that suits my desire. There is one problem I cant seem to figure out though, so I am asking for help.
My problem seems to be that the trees do not always transform back to id 4006. Some of the trees will stay as id 4008. Is there anything I can change to make sure that they always transform back? Also, please ignore the timer numbers, as they were just put in place to test the script.
I forgot to add, that the trees will either not transform back, or they will instantly transform back, within a second of using it. Then ofcourse, some of them will work right.
Code:
local chance = 25
local orangesAmmount = {1, 5}
local itemid = 4006
local timer = 10
function onUse(cid, item, toPosition, itemEx, fromPosition)
if item.itemid == 4006 and (math.random(100) <= chance) then
ammount = math.random(orangesAmmount[1], orangesAmmount[2])
doPlayerAddItem(cid, 2675, ammount)
doSendMagicEffect(fromPosition, CONST_ME_MAGIC_GREEN)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You harvested " .. ammount .. " " ..(ammount>1 and "oranges" or "orange") .. " from the tree.")
doTransformItem(item.uid, 4008)
addEvent(doCreateItem, os.time() + 10, itemid, toPosition)
else
doSendMagicEffect(fromPosition, CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You didn't harvest any oranges from this tree.")
addEvent(function() doTransformItem(item.uid, 4006) end, timer * 1000)
end
return true
end
My problem seems to be that the trees do not always transform back to id 4006. Some of the trees will stay as id 4008. Is there anything I can change to make sure that they always transform back? Also, please ignore the timer numbers, as they were just put in place to test the script.
I forgot to add, that the trees will either not transform back, or they will instantly transform back, within a second of using it. Then ofcourse, some of them will work right.
Last edited: