• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Annihilator Reward, not working.

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
Im trying to do 1 chest that gives a reward depending on vocation but it is giving me "end" errors in console at line 27.

ANNIHILATOR REWARD
Code:
function onUse(cid, item, frompos, item2, topos)
    if item.uid == 2007 then
        if getPlayerStorageValue(cid, 2007) == -1 then
        if getPlayerVocation(cid) == 1 or 5 then
            doPlayerSendTextMessage(cid, 22, "You found the sorcerer reward.")
            doPlayerAddItem(cid, ####, 1)
            setPlayerStorageValue(cid, 2007, 1)
        elseif getPlayerVocation(cid) == 2 or 6 then
            doPlayerSendTextMessage(cid, 22, "You found the druid reward.")
            doPlayerAddItem(cid, ####, 1)
            setPlayerStorageValue(cid, 2007, 1)
        elseif getPlayerVocation(cid) == 3 or 7 then
            doPlayerSendTextMessage(cid, 22, "You found the paladin reward.")
            doPlayerAddItem(cid, ####, 1)
            setPlayerStorageValue(cid, 2007, 1)
        elseif getPlayerVocation(cid) == 4 or 8 then
            doPlayerSendTextMessage(cid, 22, "You found the knight reward.")
            doPlayerAddItem(cid, ####, 1)
            setPlayerStorageValue(cid, 2007, 1)
        else
            doPlayerSendTextMessage(cid, 22, "It is empty.")
        end
    else
        return 0
    end
        return 1
    end

Am I missing ends?


If this is any help, here is the base quest I modified:
Code:
function onUse(cid, item, frompos, item2, topos)
    if item.uid == 2002 then
        if getPlayerStorageValue(cid, 2002) == -1 then
            doPlayerSendTextMessage(cid, 22, "You found a heavy machete.")
            doPlayerAddItem(cid, 2442, 1)
            setPlayerStorageValue(cid, 2002, 1)
        else
            doPlayerSendTextMessage(cid, 22, "It is empty.")
        end
    else
        return 0
    end
        return 1
    end



Thanks in advance.
/zeeb
 
Add end above the first else, atm there are 3 if statements but only 2 ends to close it (third end is to close function onUse)
You can also do it like this.
Code:
local vocitems = {
   [{1, 5}] = {text = "You found the sorcerer reward.", itemid = 2160},
   [{2, 6}] = {text = "You found the druid reward.", itemid = 2160},
   [{3, 7}] = {text = "You found the paladin reward.", itemid = 2160},
   [{4, 8}] = {text = "You found the knight reward.", itemid = 2160}
}

function onUse(cid, item, frompos, item2, topos)
     if getPlayerStorageValue(cid, 2007) == -1 then
         for voc, x in pairs(vocitems) do
             if isInArray(voc, getPlayerVocation(cid)) == TRUE then
                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, x.text)
                 doPlayerAddItem(cid, x.itemid, 1)
                 setPlayerStorageValue(cid, 2007, 1)
                 return TRUE
             end
         end
     else
         doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty.")
     end
     return TRUE
end
 
Last edited:
Back
Top