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

Lua Reward Chest

curruwilliam

Hello =]
Joined
Apr 22, 2014
Messages
124
Reaction score
2
Hello

Someone passes me script action of reward quest TFS 1.2

Being able to do several chests in a single script with different storages and equal

up
 
Last edited by a moderator:
Code:
local chests = {
    [45868] = {itemid = 22398, count = 1},
    [45869] = {itemid = 22401, count = 1},
    [45870] = {itemid = 22404, count = 1},
    [45871] = {itemid = 22410, count = 1},
    [45872] = {itemid = 22416, count = 1},
    [45873] = {itemid = 22419, count = 1},
    [45874] = {itemid = 22422, count = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if chests[item.uid] then
        if player:getStorageValue(45875) == 1 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'It\'s empty.')
            return true
        end

        local chest = chests[item.uid]
        local itemType = ItemType(chest.itemid)
        if itemType then
            local article = itemType:getArticle()
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. (#article > 0 and article .. ' ' or '') .. itemType:getName() .. '.')
        end

        player:addItem(chest.itemid, chest.count)
        player:setStorageValue(45875, 1)
    end

    return true
end
 
Back
Top