Hey!
I've been trying to get a plum tree script to work, where you basically either use or use with a tool on a plum tree to harvest a randomized(1-4) amount of plums.
What I've come across is the following:
This is an orange tree version of it, but I can easily replace it with a plum tree. The problem occurs when I click repeatedly, since it'll give me an unlimited amount of plums. How do I set a cooldown on this?
The second script I found was:
This also works if I alter it, but it'll only give me one(since I don't know what I need to write to make it randomized). It also applies to all plum trees, meaning if I use one tree and I get a plum I can't use any other plum tree on the server.
An answer to either one of those questions would be answered with a big hug.
Thanks!
I've been trying to get a plum tree script to work, where you basically either use or use with a tool on a plum tree to harvest a randomized(1-4) amount of plums.
What I've come across is the following:
Code:
function onUse(cid, item, frompos, item2, topos)
doTransformItem(item.uid,4008)
doPlayerAddItem(cid,2675,math.random(5))
doDecayItem(item.uid)
return 1
end
This is an orange tree version of it, but I can easily replace it with a plum tree. The problem occurs when I click repeatedly, since it'll give me an unlimited amount of plums. How do I set a cooldown on this?
The second script I found was:
Code:
local cfg = {
palm_id = 1234,
coconut_id = 2345,
count = 10, -- How many coconuts?
minutes = 120, -- How many minutes before you can use the palm again?
storage = 3456,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == cfg.palm_id then
if getPlayerStorageValue(cid, cfg.storage) <= os.time() then
doPlayerAddItem(cid, cfg.coconut_id, cfg.count)
setPlayerStorageValue(cid, cfg.storage, os.time() + (cfg.minutes * 60 * 1000))
end
end
return true
end
This also works if I alter it, but it'll only give me one(since I don't know what I need to write to make it randomized). It also applies to all plum trees, meaning if I use one tree and I get a plum I can't use any other plum tree on the server.
An answer to either one of those questions would be answered with a big hug.
Thanks!