• 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!

TFS 1.1 Quest help

Tibia Rox

Member
Joined
Feb 4, 2009
Messages
1,181
Reaction score
9
Location
U.S.A
I'm trying to add a function so that when a player uses an item (like a chest) and they dont have any capacity or they don't have any space in their backpack then they get denied the reward and sent a message. I've looked around a bit but nothing fits what I'm trying to do.

Code:
NOT_CLEARED = -1
CLEARED = 1
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local chest = 5001 -- The chest UID / Unique ID.
    --local moneyReward = 70000 -- The amount of money.
    --local xpReward = 7000 -- The amount of xp.
    local questName = "Treasure Island Quest" -- The name of the quest.
    if item.uid == chest then
        local p = Player(cid)
        isCleared = p:getStorageValue(chest)
        if isCleared == NOT_CLEARED then
            p:addItem(10532, 1)
            p:addItem(9971, 3)
            p:addItem(2148, 78)
            p:addItem(24115, 1)
            p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You look through the chest and find a bejeweled ship's telescope, 3 gold ingots, and a boss token. You also pick up some gold coins scattered about.")
            --p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You've earned 7k for completing the " .. questName .. ".")
            --p:addMoney(moneyReward)
            --p:addExperience(xpReward)
            p:setStorageValue(chest, CLEARED)
        else
            p:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This chest is empty.")
        end
    end
    return true
end
 
Back
Top