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

Action Quest Chests on Steroids TFS 1.2

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,329
Solutions
68
Reaction score
1,007
Strutz made a good script for this but I noticed there were some things people wanted implemented that he never got around to.

What you can do with this:
-Anni like chests
-Quest required chests
-Level required chests
-Item rewards
-Random item rewards
-Exp rewards
-Outfit/addon rewards
-Mount rewards


Lib file
Lua:
--[[
Key Information:
unique - If this is true then the chest will block other chests from being used.
uidChests - If the player has used any chests with these uid's then it cannot be opened.
itemRandom - If this is true the player will receive one of the items specified in the items table randomly otherwise he will recieve all of them.
level_req - This level is required to open the chest.
quest - If this is true it will check to see if the players storage is the correct value before giving rewards.
storage - This is the quest storage and value which is required for the chest to give rewards. It is not used if: quest = false
storage - the 3rd value in this can be used to change the players storage value of the quest if required.
]]--
chestRewards = {
    [2000] = {unique = true, uidChests = {2001, 2002, 2003}, itemRandom = false, level_req = 10, quest = false, storage = {15000, 5, 5}
            items = {{1111, 1}, {1111, 1}}, --Itemid, amount--
            exp = 20000,
            outfit = {"Citizen", 216, 217, 3, true}, --outfit name/male id/female id/addons/if this is true it will give all addons 1-3 Otherwise it will only give the specific addon--
            mount = {"Black Sheep", 20}
            text = "You cannot open this chest until you do..." --This is only used if the chest is quest required.--
            }
    --[2004] --
}

Action script
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local chest = item:getUniqueId()
    local REWARD = chestRewards[chest]
   
    if not REWARD then return true end
   
    if player:getStorageValue(chest) ~= nil then
        return player:sendCancelMessage("It is empty.")
    end
   
    if REWARD.unique then
        for i, v in pairs(REWARD.uidChests) do
            if player:getStorageValue(REWARD.uidChests[v]) ~= nil then
                return player:sendCancelMessage("It is empty.")
            end
        end
    end
   
    if CHEST.quest then
        if player:getStorageValue(REWARD.storage[1]) < REWARD.storage[2] then return player:sendCancelMessage(REWARD.text) end
    end
   
    if player:getLevel() < REWARD.level_req then return player:sendCancelMessage("You must be level "..REWARD.level_req.." to open this.") end
   
    if REWARD.exp then
        player:addExperience(REWARD.exp)
    end
   
    if REWARD.items then
        if REWARD.itemRandom then
            local rand = items[math.random(1, #items)]
            local ITEM = player:addItem(rand[1], rand[2])
            local itemType = ItemType(ITEM)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You found: "..rand[2].." "..itemType:getName().." inside the chest!")
        else
        local text = "You have found: "
        for i = 1, #REWARD.items do
            local ITEM = player:addItem(REWARD.items[i][1], REWARD.items[i][2])
            local itemType = ItemType(ITEM)
            text = text..""..REWARD.items[i][2].." "..itemType:getName()..", "
        end
        text = text.."inside the chest."
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, text)
        end
    end
   
    if REWARD.outfit then
        if REWARD.outfit[5] then
            if player:getSex() == 0 then
                player:addOutfit(REWARD.outfit[3])
                for i = 1, REWARD.outfit[4] do
                    player:addOutfitAddon(REWARD.outfit[3], i)
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            else
                player:addOutfit(REWARD.outfit[2])
                for i = 1, REWARD.outfit[4] do
                    player:addOutfitAddon(REWARD.outfit[2], i)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
                end
            end
        else
            if player:getSex() == 0 then
                player:addOutfit(REWARD.outfit[3])
                player:addOutfitAddon(REWARD.outfit[3], REWARD.outfit[4])
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            else
                player:addOutfit(REWARD.outfit[2])
                player:addOutfitAddon(REWARD.outfit[2], REWARD.outfit[4])
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            end
        end
    end
   
    if REWARD.mount then
        player:addMount(REWARD.mount[2])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved the "..REWARD.mount[1].." mount.")
    end
   
    if REWARD.storage[3] and REWARD.quest then
        player:setStorageValue(REWARD.storage[1], REWARD.storage[3])
    end
    player:setStorageValue(chest, 1)
return true
end

If you need more information on how to use this:
Action - Advanced quest chests 1.x

Edit: unique = true tells the script to check all the uidChests and make sure they haven't been used already.
 
Last edited by a moderator:
oh yea this is the one going to test it :0

got this error hmm TFS 1.3

2lnvjm9.png
 
Last edited by a moderator:
add a comma after
Lua:
storage = {15000, 5, 5}
It works but i have another problem, when im trying to grab the loot from chest, it tells me that the chest is empty but i never took the prizes
 
change
Lua:
if player:getStorageValue(chest) ~= nil then
to
Lua:
if player:getStorageValue(chest) ~= -1 then
 
change
Lua:
if player:getStorageValue(chest) ~= nil then
to
Lua:
if player:getStorageValue(chest) ~= -1 then
Now i get smth like this
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quest_chests.lua:onUse
data/actions/scripts/quest_chests.lua:12: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: at 0x7ff75d31ac40
        [C]: in function 'pairs'
        data/actions/scripts/quest_chests.lua:12: in function <data/actions/scripts/quest_chests.lua:1>
 
Sorry it took me so long to get back on this guys. Have been busy for a while... If anyone is wanting to use this still.

LIB
Code:
--[[
Key Information:
unique - If this is true then the chest will block other chests from being used.
uidChests - If the player has used any chests with these uid's then it cannot be opened.
itemRandom - If this is true the player will receive one of the items specified in the items table randomly otherwise he will recieve all of them.
level_req - This level is required to open the chest.
quest - If this is true it will check to see if the players storage is the correct value before giving rewards.
storage - This is the quest storage and value which is required for the chest to give rewards. It is not used if: quest = false
storage - the 3rd value in this can be used to change the players storage value of the quest if required.
]]--
chestRewards = {
    [2000] = {unique = true, uidChests = {2001, 2002, 2003}, itemRandom = false, level_req = 10, quest = false, storage = {15000, 5, 5},
            items = {{1111, 1}, {1111, 1}}, --Itemid, amount--
            exp = 20000,
            outfit = {"Citizen", 216, 217, 3, true}, --outfit name/male id/female id/addons/if this is true it will give all addons 1-3 Otherwise it will only give the specific addon--
            mount = {"Black Sheep", 20},
            text = "You cannot open this chest until you do..." --This is only used if the chest is quest required.--
            }
    --[2004] --
}

ACTIONSCRIPT
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local CHEST = item:getUniqueId()
    local REWARD = chestRewards[CHEST]
   
    if not REWARD then return true end
   
    if player:getStorageValue(CHEST) ~= nil then
        return player:sendCancelMessage("It is empty.")
    end
   
    if REWARD.unique then
        for i, v in ipairs(REWARD.uidChests) do
            if player:getStorageValue(REWARD.uidChests[v]) ~= nil then
                return player:sendCancelMessage("It is empty.")
            end
        end
    end
   
    if REWARD.quest then
        if player:getStorageValue(REWARD.storage[1]) < REWARD.storage[2] then return player:sendCancelMessage(REWARD.text) end
    end
   
    if player:getLevel() < REWARD.level_req then return player:sendCancelMessage("You must be level "..REWARD.level_req.." to open this.") end
   
    if REWARD.exp then
        player:addExperience(REWARD.exp)
    end
   
    if REWARD.items then
        if REWARD.itemRandom then
            local rand = math.random(1, #REWARD.items)
            local ADDITEM = REWARD.items[rand][1]
            local ADDAMOUNT = math.random(1, #REWARD.items[rand][2])
            local ITEM = player:addItem(ADDITEM, ADDAMOUNT)
            local itemType = ItemType(ITEM)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You found: "..ADDAMOUNT.." "..itemType:getName().." inside the chest!")
        else
        local text = "You have found: "
        for i = 1, #REWARD.items do
            local ITEM = player:addItem(REWARD.items[i][1], REWARD.items[i][2])
            local itemType = ItemType(ITEM)
            text = text..""..REWARD.items[i][2].." "..itemType:getName()..", "
        end
        text = text.."inside the chest."
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, text)
        end
    end
   
    if REWARD.outfit then
        if REWARD.outfit[5] then
            if player:getSex() == 0 then
                player:addOutfit(REWARD.outfit[3])
                for i = 1, REWARD.outfit[4] do
                    player:addOutfitAddon(REWARD.outfit[3], i)
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            else
                player:addOutfit(REWARD.outfit[2])
                for i = 1, REWARD.outfit[4] do
                    player:addOutfitAddon(REWARD.outfit[2], i)
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
                end
            end
        else
            if player:getSex() == 0 then
                player:addOutfit(REWARD.outfit[3])
                player:addOutfitAddon(REWARD.outfit[3], REWARD.outfit[4])
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            else
                player:addOutfit(REWARD.outfit[2])
                player:addOutfitAddon(REWARD.outfit[2], REWARD.outfit[4])
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have received the "..REWARD.outfit[1].." outfit.")
            end
        end
    end
   
    if REWARD.mount then
        player:addMount(REWARD.mount[2])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved the "..REWARD.mount[1].." mount.")
    end
   
    if REWARD.storage[3] and REWARD.quest then
        player:setStorageValue(REWARD.storage[1], REWARD.storage[3])
    end
    player:setStorageValue(CHEST, 1)
return true
end
 
Last edited:
Is it working for TFS 1.3?

i don't have any problems in console but if i trying to open the chest i get the message: It is empty.

map editor settings.png
 
Last edited:
Back
Top