• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved if remove item = activate timer + spawn item.

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

I'm trying to make some bushes with strawberry's. The idea is comparable to the blueberry bushes.
What I'm trying to make is a bush which will start with an item on it at server start. Once this item (a couple strawberry's) is removed a timer will start and after the timer runs out an item will be placed again. Once it is removed again, restart the whole script. (note that no one can put items on the bush)

Thanks in advance.
 
Like this?
Bn22dZya.png

You can add an actionid to the bush or ground and add id 8046 so people can't take them from the bush.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getTileItemById(toPosition, 2680).uid > 0 and getTileItemById(toPosition, 2767).uid > 0 then
         doPlayerAddItem(cid, 2680, 3)
         doRemoveItem(getTileItemById(toPosition, 2680).uid)
         doRemoveItem(getTileItemById(toPosition, 8046).uid)
         addEvent(doCreateItem, 5000, 2680, 3, toPosition)
         addEvent(doCreateItem, 5000, 8046, 1, toPosition)
     end
     return TRUE
end
 
Works like a charm :)

Just one more thing.

Is it possible to make the script check on action id instead of unique id because i keep getting these errors in my console.
[14/08/2014 13:54:28] Duplicate uniqueId 55555


Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getTileItemById(toPosition, 2680).uid > 0 and getTileItemById(toPosition, 4010).uid > 0 then
         doRemoveItem(getTileItemById(toPosition, 2680).uid)
         doRemoveItem(getTileItemById(toPosition, 8060).uid)
        local rand = math.random(1, 50)
        if rand < 2 then
            doPlayerAddItem(cid, 2680, 5)
        doCreatureSay(cid, "You collected 5 strawberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
        elseif rand < 8 then
            doPlayerAddItem(cid, 2680, 4)
        doCreatureSay(cid, "You collected 4 strawberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
        elseif rand < 19 then
            doPlayerAddItem(cid, 2680, 3)
        doCreatureSay(cid, "You collected 3 strawberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
        elseif rand < 30 then
            doPlayerAddItem(cid, 2680, 2)
        doCreatureSay(cid, "You collected 2 strawberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
        elseif rand < 45 then
            doPlayerAddItem(cid, 2680, 1)
        doCreatureSay(cid, "You collected a strawberry.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
        else
        doCreatureSay(cid, "You failed to collect any strawberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 2680, 4, toPosition)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
     end
     end
     return TRUE
end
 
Yes, you should use actionid instead of uniqueid. Uniqueids can only be used 1x, so for scripts like this, use actionid.
 
Back
Top