• 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.2 One reward of quest

Webo

Otland 4ever
Joined
Oct 20, 2013
Messages
621
Solutions
10
Reaction score
229
Location
Warsaw
problem. As I am doing 4 case with the same id that I can take the prize each.

issue two. Items to put in the box in the game gets something
ceb4a6a03c28484a994a6c1883f2748f.png
 
post script?
if you want players to only get one you have to set a storage value and check for it onuse
 
Item from the quest gets so:
4ec6936f9a164c7690d456d9e69d28f1.png
If you're talking about pits of inferno then you have to add this

data/actions/actions.xml
Code:
    <action actionid="10544" script="quests/system.lua" />

data/actions/scripts/quests/system.lua
Code:
local specialQuests = {
    [2215] = Storage.AnnihilatorDone,
    [2016] = Storage.DreamersChallenge.Reward,
    [10544] = Storage.PitsOfInferno.WeaponReward,
    [12513] = Storage.thievesGuild.Reward,
    [12374] = Storage.WrathoftheEmperor.mainReward,
    [26300] = Storage.SvargrondArena.RewardGreenhorn,
    [27300] = Storage.SvargrondArena.RewardScrapper,
    [28300] = Storage.SvargrondArena.RewardWarlord
}

local questsExperience = {
    [2217] = 1 -- dummy values
}

local questLog = {
    [9130] = Storage.hiddenCityOfBeregar.DefaultStart
}

local tutorialIds = {
    [50080] = 5,
    [50082] = 6,
    [50084] = 10,
    [50086] = 11
}

local hotaQuest = {12102, 12103, 12104, 12105, 12106, 12107}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = specialQuests[item.actionid]
    if not storage then
        storage = item.uid
        if storage > 65535 then
            return false
        end
    end

    if player:getStorageValue(storage) > 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.')
        return true
    end

    local items, reward = {}
    local size = item:isContainer() and item:getSize() or 0
    if size == 0 then
        reward = item:clone()
    else
        local container = Container(item.uid)
        for i = 0, container:getSize() - 1 do
            items[#items + 1] = container:getItem(i):clone()
        end
    end

    size = #items
    if size == 1 then
        reward = items[1]:clone()
    end

    local result = ''
    if reward then
        local ret = ItemType(reward.itemid)
        if ret:isRune() then
            result = ret:getArticle() .. ' ' ..  ret:getName() .. ' (' .. reward.type .. ' charges)'
        elseif ret:isStackable() and reward:getCount() > 1 then
            result = reward:getCount() .. ' ' .. ret:getPluralName()
        elseif ret:getArticle() ~= '' then
            result = ret:getArticle() .. ' ' .. ret:getName()
        else
            result = ret:getName()
        end
    else
        if size > 20 then
            reward = Game.createItem(item.itemid, 1)
        elseif size > 8 then
            reward = Game.createItem(1988, 1)
        else
            reward = Game.createItem(1987, 1)
        end

        for i = 1, size do
            local tmp = items[i]
            if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then
                print('[Warning] QuestSystem:', 'Could not add quest reward to container')
            end
        end
        local ret = ItemType(reward.itemid)
        result = ret:getArticle() .. ' ' .. ret:getName()
    end

    if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
        local weight = reward:getWeight()
        if player:getFreeCapacity() < weight then
            player:sendCancelMessage(string.format('You have found %s weighing %.2f oz. You have no capacity.', result, (weight / 100)))
        else
            player:sendCancelMessage('You have found ' .. result .. ', but you have no room to take it.')
        end
        return true
    end

    if questsExperience[storage] then
        player:addExperience(questsExperience[storage], true)
    end

    if questLog[storage] then
        player:setStorageValue(questLog[storage], 1)
    end

    if tutorialIds[storage] then
        player:sendTutorial(tutorialIds[storage])
        if item.uid == 50080 then
            player:setStorageValue(Storage.RookgaardTutorialIsland.SantiagoNpcGreetStorage, 3)
        end
    end

    if isInArray(hotaQuest, item.uid) then
        if player:getStorageValue(Storage.TheAncientTombs.DefaultStart) ~= 1 then
            player:setStorageValue(Storage.TheAncientTombs.DefaultStart, 1)
        end
    end

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. result .. '.')
    player:setStorageValue(storage, 1)
    return true
end

the 3 chests of which you only can choose 1 reward do need to have action id 10544
 
@undead mage
Code:
data/actions/scripts/quests/system.lua:2: attempt to index global 'Storage' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/quests/system.lua:2: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/quests/system.lua
 
@undead mage
Code:
data/actions/scripts/quests/system.lua:2: attempt to index global 'Storage' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/actions/scripts/quests/system.lua:2: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/quests/system.lua
you dont have the storage lib that he has so idk why he posted that without the lib lol
 
Back
Top