• 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 [1.2] Action script not giving items...

Caduceus

Unknown Member
Joined
May 10, 2010
Messages
321
Solutions
2
Reaction score
24
Server Version: TFS 1.2

Script is sending the 'msg', setting my storage value to 3, but not giving the items. I am getting no errors to go on.


script
Code:
local storage = 45552

local vocations = {
    [1] = {items = {2662, 2653, 5918}},
    [2] = {items = {2662, 2653, 5918}},
    [3] = {items = {2458, 2464, 2648}},
    [4] = {items = {2457, 2463, 2647}},
    [9] = {items = {2457, 2463, 2647}} 
}

local msg = ''
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(storage) == 2 then
        local vocId = vocations[player:getVocation():getBase():getId()]
                player:addItem(vocId.items)
                msg = "You have found some useful gear!"
                player:setStorageValue(storage, 3)
    else
        msg = "chest appears to be locked."
        print (item)
    end
    player:sendTextMessage(MESSAGE_INFO_DESCR, msg)
    return true
end
 
I made it through my phone, but you should loop through the items table to get the items id
Code:
local config = {
    storage = 45552,
    reward = {
        [1] = {2662, 2653, 5918},
        [2] = {2662, 2653, 5918},
        [3] = {2458, 2464, 2648},
        [4] = {2457, 2463, 2647},
        [9] = {2457, 2463, 2647}
    }
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.storage) == 2 then
        local vocation = player:getVocation():getBase():getId()
        for i = 1, #config.reward[vocation]
            player:addItem(config.reward[vocation][i], 1)
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found some items.")
        player:setStorageValue(config.storage, 3)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The chest is empty.")
    end
    return true
end
 
Back
Top