Action Quest Chests on Steroids TFS 1.2

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,540
Best answers
35
Reaction score
376
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:

wafuboe

Intermediate OT User
Joined
Dec 24, 2010
Messages
824
Best answers
2
Reaction score
13
oh yea this is the one going to test it :0

got this error hmm TFS 1.3

 
Last edited by a moderator:

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,098
Best answers
484
Reaction score
2,739
add a comma after
Lua:
storage = {15000, 5, 5}
 

liqeen

Member
Joined
Nov 26, 2014
Messages
96
Best answers
0
Reaction score
4
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
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,098
Best answers
484
Reaction score
2,739
change
Lua:
if player:getStorageValue(chest) ~= nil then
to
Lua:
if player:getStorageValue(chest) ~= -1 then
 

liqeen

Member
Joined
Nov 26, 2014
Messages
96
Best answers
0
Reaction score
4
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>
 

eldoots

New Member
Joined
Jun 6, 2019
Messages
1
Best answers
0
Reaction score
0
Bump?

#can anyone confirm if is it working?
 
Top