• 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 Vocation based addon

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
I am attempting to make a quest chest to give a player addons based on vocation. The chest opens, gives the storage ID. No addon rewarded. No errors on console. Using tfs 1.2, how bad am I off?

Code:
local storage = 15485

local outfits = {
    {138,3}, -- 1
    {148,3}, -- 2
    {137,3}, -- 3
    {139,3}  -- 4
}

local msg = ''
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(storage) < 1 then
        for vocId, items in ipairs(outfits) do
            if player:getVocation():getBase():getId() == vocId then
                for i = 1, #items do
                    --add players addon based on Vocation/sex (player:addItem(items[i]))
                    doPlayerAddOutfit(items[i])
                end
                msg = "Yay, free shit!"
            end
        end
        player:setStorageValue(storage, 1)
    else
        msg = "chest is empty."
    end
    player:sendTextMessage(MESSAGE_INFO_DESCR, msg)
    return true
end
 
I assumed the 3 in the outfits table is the addon number:

Code:
local outfits = {
    {138,3}, -- 1
    {148,3}, -- 2
    {137,3}, -- 3
    {139,3}  -- 4
}

local msg = ''
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(storage) < 1 then
        local outfit = outfits[player:getVocation():getBase():getId()]
        player:addOutfitAddon(outfit[1], outfit[2])
        msg = "Yay, free shit!"
        player:setStorageValue(storage, 1)
    else
        msg = "chest is empty."
    end
    player:sendTextMessage(MESSAGE_INFO_DESCR, msg)
    return true
end
 
Something like this I assume. Thanks

Code:
local storage = 15485

local outfits = {
    {female = 138, male = 130, addon = 3}, -- 1
    {female = 148, male = 144, addon = 3}, -- 2
    {female = 137, male = 129, addon = 3}, -- 3
    {female = 139, male = 131, addon = 3}  -- 4
}

local msg = ''
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(storage) < 1 then
        local outfit = outfits[player:getVocation():getBase():getId()]
        player:addOutfitAddon(outfit.female, outfit.addon)
        player:addOutfitAddon(outfit.male, outfit.addon)
        msg = "Yay, free shit!"
        player:setStorageValue(storage, 1)
    else
        msg = "chest is empty."
    end
    player:sendTextMessage(MESSAGE_INFO_DESCR, msg)
    return true
end
 
Last edited:

Similar threads

Back
Top