• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [TFS 1.0] Simple quest template with money and xp as reward.

Jack Parsons

Member
Joined
Mar 8, 2016
Messages
32
Reaction score
12
Location
São Paulo State, Brazil
I've developed a simple quest, and I'd like to share it as a template for you (Perhaps it'll be useful to someone).

Code:
NOT_CLEARED = -1
CLEARED = 1
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local chest = 2500 -- The chest UID / Unique ID.
    local moneyReward = 70000 -- The amount of money.
    local xpReward = 7000 -- The amount of xp.
    local questName = "Witch Coven" -- The name of the quest.
    if item.uid == chest then
        local p = Player(cid)
        isCleared = p:getStorageValue(chest)
        if isCleared == NOT_CLEARED then
            p:sendTextMessage(MESSAGE_INFO_DESCR, "You've earned 7k for completing the " .. questName .. " Quest.")
            p:addMoney(moneyReward)
            p:addExperience(xpReward)
            p:setStorageValue(chest, CLEARED)
        else
            p:sendTextMessage(MESSAGE_INFO_DESCR, "The chest is empty.")
        end
    end
    return true
end

You just have to change the chest unique ID (That you've inserted in the map editor), the amount of money for the reward, the amount of XP and the name of the quest (The name of my quest is "Witch Coven", and I'm leaving it there to serve as an example). It's really really simple.

Of course.. don't forget to add the actionid inside actions.xml:

Code:
<action actionid="500" script="quests/witchcoven.lua"/>
 
Should work for 1.0 - 1.2
Code:
local chest = {
    [2500] = {
        storage = 2000,
        money = 70000, -- The amount of money.
        experience = 7000, -- The amount of xp.
        rewardMsg = "You've earned 7k for completing the Witch Coven Quest.",
        emptyMsg = "The chest is empty."
    }
}

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local player = type(cid) == 'number' and Player(cid) or cid
    if chest[item.uid] then
        if player:getStorageValue(chest[item.uid].storage) == -1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, chest[item.uid].rewardMsg)
            player:addMoney(chest[item.uid].money)
            player:addExperience(chest[item.uid].experience)
            player:setStorageValue(chest[item.uid].storage, 1)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, chest[item.uid].emptyMsg)
        end
    end
    return true
end
 
Back
Top