• 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 Lua problem: on some things the script works on others not. Can't find the problem

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 have created the following script for collecting fruits and vegetables.
Code:
    <action actionid="55555" script="tools/plants.lua"/>
All bushes or floors below the fruits/vegetables have this action id.

<-- The code itself will be added below because it's too big. -->

I can pick tomatoes, strawberries, raspberries without any problem.
But when I try picking my carrots, pumpkins, onions or garlic bulbs. Nothing happens

If anyone has an idea where I went wrong, I'd love to hear it :)

Thanks in advance.
 
Part 1 of the script:
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, 3, 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, 3, 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, 3, 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, 3, 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, 3, 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, 3, toPosition)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
     end
     end


     if getTileItemById(toPosition, 2684).uid > 0 and getTileItemById(toPosition, 804).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, 2684, 5)
        doCreatureSay(cid, "You collected 5 carrots.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 50*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 50*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 50*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 50*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 8 then
            doPlayerAddItem(cid, 2684, 4)
        doCreatureSay(cid, "You collected 4 carrots.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 40*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 40*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 40*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 40*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 19 then
            doPlayerAddItem(cid, 2684, 3)
        doCreatureSay(cid, "You collected 3 carrots.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 30*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 30*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 30*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 30*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 30 then
            doPlayerAddItem(cid, 2684, 2)
        doCreatureSay(cid, "You collected 2 carrots.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 20*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 20*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 20*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 20*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 45 then
            doPlayerAddItem(cid, 2684, 1)
        doCreatureSay(cid, "You collected a carrot.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 10*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 10*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 10*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 10*60*1000, 8843, 2, toPosition)
            end
        else
        doCreatureSay(cid, "You failed to collect any carrots.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 5*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 5*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 5*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 5*60*1000, 8843, 2, toPosition)
            end
     end
     end


     if getTileItemById(toPosition, 9114).uid > 0 and getTileItemById(toPosition, 804).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, 9114, 5)
        doCreatureSay(cid, "You collected 5 bulbs of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 50*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 50*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 50*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 50*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 8 then
            doPlayerAddItem(cid, 9114, 4)
        doCreatureSay(cid, "You collected 4 bulbs of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 40*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 40*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 40*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 40*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 19 then
            doPlayerAddItem(cid, 9114, 3)
        doCreatureSay(cid, "You collected 3 bulbs of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 30*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 30*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 30*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 30*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 30 then
            doPlayerAddItem(cid, 9114, 2)
        doCreatureSay(cid, "You collected 2 bulbs of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 20*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 20*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 20*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 20*60*1000, 8843, 2, toPosition)
            end
 
Part 2 of the script:
Code:
        elseif rand < 45 then
            doPlayerAddItem(cid, 9114, 1)
        doCreatureSay(cid, "You collected a bulb of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 10*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 10*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 10*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 10*60*1000, 8843, 2, toPosition)
            end
        else
        doCreatureSay(cid, "You failed to collect any bulbs of garlic.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 5*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 5*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 5*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 5*60*1000, 8843, 2, toPosition)
            end
     end
     end

     if getTileItemById(toPosition, 2683).uid > 0 and getTileItemById(toPosition, 804).uid > 0 then
         doRemoveItem(getTileItemById(toPosition, 2680).uid)
         doRemoveItem(getTileItemById(toPosition, 8060).uid)
        local rand = math.random(1, 2)
        if rand == 1 then
            doPlayerAddItem(cid, 2683, 1)
        doCreatureSay(cid, "You collected a pumpkin.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 25*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 25*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 25*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 25*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 25*60*1000, 8843, 2, toPosition)
            end
        else
        doCreatureSay(cid, "You failed to collect a pumkin.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 15*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 15*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 15*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 15*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 15*60*1000, 8843, 2, toPosition)
            end
     end
     end

     if getTileItemById(toPosition, 8843).uid > 0 and getTileItemById(toPosition, 804).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, 8843, 5)
        doCreatureSay(cid, "You collected 5 onions.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 50*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 50*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 50*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 50*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 8 then
            doPlayerAddItem(cid, 8843, 4)
        doCreatureSay(cid, "You collected 4 onions.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 40*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 40*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 40*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 40*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 19 then
            doPlayerAddItem(cid, 8843, 3)
        doCreatureSay(cid, "You collected 3 onions.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 30*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 30*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 30*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 30*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 30 then
            doPlayerAddItem(cid, 8843, 2)
        doCreatureSay(cid, "You collected 2 onions.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 20*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 20*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 20*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 20*60*1000, 8843, 2, toPosition)
            end
        elseif rand < 45 then
            doPlayerAddItem(cid, 8843, 1)
        doCreatureSay(cid, "You collected an onion.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 10*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 10*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 10*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 10*60*1000, 8843, 2, toPosition)
            end
        else
        doCreatureSay(cid, "You failed to collect any onions.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
            local math = math.random(1, 4)
            if math == 1 then
                    addEvent(doCreateItem, 5*60*1000, 9114, 3, toPosition)
            elseif math == 2 then
                    addEvent(doCreateItem, 5*60*1000, 2684, 3, toPosition)
            elseif math == 3 then
                    addEvent(doCreateItem, 5*60*1000, 2683, 1, toPosition)
            else
                    addEvent(doCreateItem, 5*60*1000, 8843, 2, toPosition)
            end
     end
     end

     if getTileItemById(toPosition, 8840).uid > 0 and getTileItemById(toPosition, 2771).uid > 0 then
         doRemoveItem(getTileItemById(toPosition, 8840).uid)
         doRemoveItem(getTileItemById(toPosition, 8060).uid)
        local rand = math.random(1, 50)
        if rand < 2 then
            doPlayerAddItem(cid, 8840, 5)
        doCreatureSay(cid, "You collected 5 raspberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
        elseif rand < 8 then
            doPlayerAddItem(cid, 8840, 4)
        doCreatureSay(cid, "You collected 4 raspberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
        elseif rand < 19 then
            doPlayerAddItem(cid, 8840, 3)
        doCreatureSay(cid, "You collected 3 raspberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
        elseif rand < 30 then
            doPlayerAddItem(cid, 8840, 2)
        doCreatureSay(cid, "You collected 2 raspberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
        elseif rand < 45 then
            doPlayerAddItem(cid, 8840, 1)
        doCreatureSay(cid, "You collected a raspberry.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
        else
        doCreatureSay(cid, "You failed to collect any raspberries.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 8840, 3, toPosition)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
     end
     end
 
Part 3 of the script:
Code:
     if getTileItemById(toPosition, 2685).uid > 0 and getTileItemById(toPosition, 2773).uid > 0 then
         doRemoveItem(getTileItemById(toPosition, 2685).uid)
         doRemoveItem(getTileItemById(toPosition, 8060).uid)
        local rand = math.random(1, 50)
        if rand < 2 then
            doPlayerAddItem(cid, 2685, 5)
        doCreatureSay(cid, "You collected 5 tomatoes.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 50*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 50*60*1000, 8060, 1, toPosition)
        elseif rand < 8 then
            doPlayerAddItem(cid, 2685, 4)
        doCreatureSay(cid, "You collected 4 tomatoes.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 40*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 40*60*1000, 8060, 1, toPosition)
        elseif rand < 19 then
            doPlayerAddItem(cid, 2685, 3)
        doCreatureSay(cid, "You collected 3 tomatoes.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 30*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 30*60*1000, 8060, 1, toPosition)
        elseif rand < 30 then
            doPlayerAddItem(cid, 2685, 2)
        doCreatureSay(cid, "You collected 2 tomatoes.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 20*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 20*60*1000, 8060, 1, toPosition)
        elseif rand < 45 then
            doPlayerAddItem(cid, 2685, 1)
        doCreatureSay(cid, "You collected a tomato.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 10*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 10*60*1000, 8060, 1, toPosition)
        else
        doCreatureSay(cid, "You failed to collect any tomatoes.", TALKTYPE_ORANGE_1)
            addEvent(doCreateItem, 5*60*1000, 2685, 3, toPosition)
            addEvent(doCreateItem, 5*60*1000, 8060, 1, toPosition)
     end
     end
     return TRUE
end
 
Wrong ids.
~~
if getTileItemById(toPosition, 2684).uid > 0 and getTileItemById(toPosition, 804).uid > 0 then
doRemoveItem(getTileItemById(toPosition, 2680).uid)​
 
Changed it, but that doesn't fix it.

Also tried to just make it like this
Code:
     if getTileItemById(toPosition, 2684).uid > 0 and getTileItemById(toPosition, 804).uid > 0 then
         doRemoveItem(getTileItemById(toPosition, 2684).uid)
         doRemoveItem(getTileItemById(toPosition, 8060).uid)
end
And when I used it, it didn't remove the items. So is there a difference that I set the action id into a ground tile instead of an object like a bush?
 
You can add print or a textmessage under the if statement to see if it's loading.
If it isn't, you can look if any of the itemids with getTileItemById are not found.
 
No msg.
Code:
     if getTileItemById(toPosition, 2684).uid > 0 and getTileItemById(toPosition, 804).uid > 0 then
        doCreatureSay(cid, "Test", TALKTYPE_ORANGE_1)
Code:
     if getTileItemById(toPosition, 804).uid > 0 then
        doCreatureSay(cid, "Test", TALKTYPE_ORANGE_1)
Code:
     if getTileItemById(toPosition, 2684).uid > 0 then
        doCreatureSay(cid, "Test", TALKTYPE_ORANGE_1)
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getTileItemById(toPosition, 9114).uid > 0 and getTileItemById(toPosition, 804).uid > 0 then
    print("script call1")
     end
     return TRUE
end

Nothing in console. Also nothing if i delete one of the 2 parts (both ways).
 
Is the actionid correct?
I assume you also don't get the print message in your console if you add it under function onUse.
 
Yea, the action id is correct since it's the same I use for the strawberry bushes etc and they are in the same script and they do work perfectly.
 
I mean in the map, if the problem is with the ground, you can also add an invisible item under the carrots, for example ID 1548, then add the actionid to that.
 
Tested it and it still doesn't work :s

Putted a real bush under it and it works so it seems like the invisible item needs to have certain requirements met before it works.
 
Last edited:
An invisible item with same stats as a plant does not work (blocking, always on top, not moveable and minimap colour 12)
A blank item with same stats as a plant does not work (blocking, always on top, not moveable, minimap colour 12 and the same sprite as one of the working bushes)
An item with a sprite with stats (not moveable and lookthrough) does not work. (stone, item id: 3622)
An item with a sprite with stats (not moveable and blocking) does not work. (lilly pad, item id: 2755)
An item with a sprite with stats (not moveable, blocking and minimap colour 12) does not work. (rose bush, item id:2766)
An item with a sprite with stats (blocking, hasheight, useable) does not work. (trough, item id:1775)
An item with a sprite with stats (blocking, always on top, not moveable and minimap colour 86) does work. (stone, item id: 3607)
An item with a sprite with stats (blocking, always on top, not moveable, block projectile, minimap colour 186 and top order 2) does work. (brick wall, item id: 1028)

Changed the sprite of the brick wall from 1273 to 465 (which is an invisible sprite) and it still does work.
Changed the top order from 2 to 0 and it does not work anymore.
Set the top order back to 2 and removed block projectile and it works again.
Removed blocking and it still works (only getting a debug and crashing the client when walking on the tile now).
Removed always on top and it does not work anymore (but it also doesn't debug anymore).
Set blocking back and it does not work.
Set always on top back and removed the minimap colour and it works.
(Minimap colour seems to be irrelevant and locked to the sprite since changing it doesn't have any effect ingame)
Set looktrough and it sill works.


So What I conclude from all this is that it needs to be an item which is actually registered within the tibia.dat and not just a blank item from which the sprite can be removed/changed to something invisible and it has to keep the top order from the existing item. Further it needs to be a blocking and always on top item. (not sure if moveable has to be activated but it's needed for this action anyway). At last the item can be made lookthrough so there is no need to change its description within the items.xml file.
 
Back
Top