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

[TFS 1.3] Advanced quest chests

beenii

Active Member
Joined
Jul 26, 2010
Messages
488
Solutions
1
Reaction score
32
System by strutZ with a small modification to do anahi type quest
4 chest 1 reward.

Features
  • Easy config
  • Can add level requirements for chests
  • Supports Item Rewards
  • Supports Experience Rewards
  • Supports Outfit Rewards
  • Supports Addon Rewards
  • Supports Mount Rewards
  • Supports Anihi Quest (4 Chest only select 1 Chest)

This system currently supports up to 100 chests. o add more simply up the change 2000, 2100 in data/scripts/actions/quest_chests.lua

add
in data/lib/lib.lua
Lua:
dofile('data/lib/quest_chests.lua')


data/lib/quest_chests.lua
Lua:
questChests = {
    ---------------------------------------------------------
   -- Example Quest Box 1
   ---------------------------------------------------------
   [2000] = {
       minLevel = 50,
       storageUnique = 2000,
       items = {
           [1] = {type = "item", item = 2160, count = 1},
           [2] = {type = "experience", amount = 20000},
           [3] = {type = "outfit", name = "assassin", femaleId = 156, maleId = 152},
           [4] = {type = "addon", outfit = "nobleman", addonNumber = 1, femaleId = 140, maleId = 132},
           [5] = {type = "mount", mountName = "Orc", mountId = 20},
       },
   },
 
     ---------------------------------------------------------
   -- Example Quest Box 2 like anihi 2 reward only select 1
   ---------------------------------------------------------
   [2001] = {
       minLevel = 50,
       storageUnique = 2001, -- put same storage for only select 1 reward
       items = {
           [1] = {type = "item", item = 2160, count = 1},
           [2] = {type = "experience", amount = 20000},
           [3] = {type = "outfit", name = "assassin", femaleId = 156, maleId = 152},
           [4] = {type = "addon", outfit = "nobleman", addonNumber = 1, femaleId = 140, maleId = 132},
           [5] = {type = "mount", mountName = "Orc", mountId = 20},
       },
   },
    [2002] = {
       minLevel = 50,
       storageUnique = 2001, -- put same storage for only select 1 reward
       items = {
           [1] = {type = "item", item = 2160, count = 1},
           [2] = {type = "experience", amount = 20000},
           [3] = {type = "outfit", name = "assassin", femaleId = 156, maleId = 152},
           [4] = {type = "addon", outfit = "nobleman", addonNumber = 1, femaleId = 140, maleId = 132},
           [5] = {type = "mount", mountName = "Orc", mountId = 20},
       },
   }
 
 
}


data/scripts/actions/quest_chests.lua
Lua:
function capAll(str)
    return (str:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end))
end

local advanceChest = Action()

function advanceChest.onUse(player, item, fromPosition, itemEx, toPosition)
   -----------------------------------------------------------------------------------
   -- Local Variables --
   -----------------------------------------------------------------------------------
   local questChest = item:getUniqueId()
   -----------------------------------------------------------------------------------
   -- Check if player has already opened box --
   -----------------------------------------------------------------------------------
   if player:getStorageValue(questChest) == 1 then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is empty.")
       toPosition:sendMagicEffect(10)
       return true
   end
 
   local storageOne = questChests[questChest].storageUnique
   -----------------------------------------------------------------------------------
   -- Check if player has already opened box multiple chest only 1 reward --
   -----------------------------------------------------------------------------------
   if player:getStorageValue(storageOne) == 1 then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The chest is empty.")
       toPosition:sendMagicEffect(10)
       return true
   end 
 
   -----------------------------------------------------------------------------------
   -- Check if player meets level requirment
   -----------------------------------------------------------------------------------
   local playerLevel = player:getLevel()
   local minLevel = questChests[questChest].minLevel
   if questChests[questChest].minLevel => playerLevel then
       player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to be level "..minLevel.." to open this chest.")
       return true
   end
   -----------------------------------------------------------------------------------
 
   -- Give rewward if player has not yet opened box --
 
   -----------------------------------------------------------------------------------
   for i = 1, #questChests[questChest].items do
       local rewardType = questChests[questChest].items[i].type
       -----------------------------------------------------------------------------------
       -- Item Type Reward --
       -----------------------------------------------------------------------------------
       if rewardType == "item" then
           local item = questChests[questChest].items[i].item
           local count = questChests[questChest].items[i].count
           player:addItem(item, count)
           player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You earned ["..count.."x] "..capAll(getItemName(item)))
       end
       -----------------------------------------------------------------------------------
       -- Experience Type Reward --
       -----------------------------------------------------------------------------------
       if rewardType == "experience" then
           local amount = questChests[questChest].items[i].amount
           player:addExperience(amount)
           player:say(amount.." EXP gained!", TALKTYPE_MONSTER_SAY)
           player:getPosition():sendMagicEffect(CONST_ME_STUN)
           player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained "..amount.." experience points.")
       end
       -----------------------------------------------------------------------------------
       -- Outfit Type Reward --
       -----------------------------------------------------------------------------------
       if rewardType == "outfit" then
           local outfitName = questChests[questChest].items[i].name
           local maleOutfit = questChests[questChest].items[i].maleId
           local femaleOutfit = questChests[questChest].items[i].femaleId
           if player:getSex() == 0 then
               player:addOutfit(femaleOutfit)
           else
               player:addOutfit(maleOutfit)
           end
           player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained the "..outfitName.." outfit.")
       end
       -----------------------------------------------------------------------------------
       -- Addon Type Reward --
       -----------------------------------------------------------------------------------
       if rewardType == "addon" then
           local outfitName = questChests[questChest].items[i].outfit
           local addon = questChests[questChest].items[i].addonNumber
           local maleAddon = questChests[questChest].items[i].maleId
           local femaleAddon = questChests[questChest].items[i].femaleId
           if player:getSex() == 0 then
               player:addOutfitAddon(femaleAddon, addon)
           else
               player:addOutfitAddon(maleAddon, addon)
           end
           if addon == 1 then
               player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained the first "..outfitName.." outfit addon.")
           elseif addon == 2 then
               player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained the second "..outfitName.." outfit addon.")
           elseif addon == 3 then
               player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained the third "..outfitName.." outfit addon.")
           end
       end
       -----------------------------------------------------------------------------------
       -- Mount Type Reward --
       -----------------------------------------------------------------------------------
       if rewardType == "mount" then
           local mountName = questChests[questChest].items[i].mountName
           local mountId = questChests[questChest].items[i].mountId
           player:addMount(mountId)
           player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have unlocked the "..mountName.." mount.")
       end

            
 
 
   -----------------------------------------------------------------------------------
   -- Add in any cooldowns/storages --
   -----------------------------------------------------------------------------------
   player:setStorageValue(questChest, 1)
   player:setStorageValue(storageOne, 1)
   return true
end
end

for i = 2000, 2100 do
    advanceChest:uid(i)
end

advanceChest:register()


It is a very useful system, since it has a simple organization, I hope my contribution will serve you.
 
Last edited:

ImaG

Member
Joined
Aug 16, 2017
Messages
30
Reaction score
9
Location
Poland
GitHub
ImaGus01v
Lua Script Error: [Test Interface]
data/actions/scripts/questchests.lua
data/actions/scripts/questchests.lua:5: attempt to call global 'Action' (a nil value)
stack traceback:
[C]: in function 'Action'
data/actions/scripts/questchests.lua:5: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/questchests.lua
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
7,005
Solutions
256
Reaction score
1,994
Location
Norway
GitHub
Znote
Modification in data/lib/lib.lua is not neccesary, you can just change the path of data/lib/quest_chests.lua file to data/scripts/lib/quest_chests.lua, Revscriptsys will load files in data/scripts/lib/ as lib files automatically.
 
OP
OP
beenii

beenii

Active Member
Joined
Jul 26, 2010
Messages
488
Solutions
1
Reaction score
32
Modification in data/lib/lib.lua is not neccesary, you can just change the path of data/lib/quest_chests.lua file to data/scripts/lib/quest_chests.lua, Revscriptsys will load files in data/scripts/lib/ as lib files automatically.
thanks for letting me know, i will modify
 

Crest

New Member
Joined
Mar 25, 2008
Messages
11
Reaction score
2
Location
Poland
I want make it for multiple reward from chest, what I need to edit to do it? Example I want from one chest itemid - 2160 and 10k exp.

I'm using tfs 1.4 for 8.6 version
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
I want make it for multiple reward from chest, what I need to edit to do it? Example I want from one chest itemid - 2160 and 10k exp.

I'm using tfs 1.4 for 8.6 version
Lua:
[2000] = {
    minLevel = 50,
    storageUnique = 2000,
    items = {
        [1] = {type = "item", item = 2160, count = 1},
        [2] = {type = "experience", amount = 10000},
    },
},
 

VagosClubTM

Member
Joined
Aug 16, 2019
Messages
121
Reaction score
15
Location
Chile
Lua:
[2000] = {
    minLevel = 50,
    storageUnique = 2000,
    items = {
        [1] = {type = "item", item = 2160, count = 1},
        [2] = {type = "experience", amount = 10000},
    },
},
Hello bro, I hope you are well, you know I am looking for a tfs 1.4 script to be able to create normal quests, and not use the ones that come in the quests folder, also a script so that when you right-click it, it creates a creature, but that has to require level to be able to use it. It would be of great help thanks <3 you are the best
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Hello bro, I hope you are well, you know I am looking for a tfs 1.4 script to be able to create normal quests, and not use the ones that come in the quests folder
The thread you're in is for creating normal quest chests/items?
If this isn't what you want, you'll have to explain better.
also a script so that when you right-click it, it creates a creature, but that has to require level to be able to use it.
You should create your own thread for this.
The main reason is so people in the future will be able to find it more easily, and I might not have the time/experience/inclination to create every request someone makes, so making your own thread will allow other people to help you.

On that front, go make a thread here, and I'll post the script there for you.
It would be of great help thanks <3 you are the best
Appreciate it.
 

VagosClubTM

Member
Joined
Aug 16, 2019
Messages
121
Reaction score
15
Location
Chile
The thread you're in is for creating normal quest chests/items?
If this isn't what you want, you'll have to explain better.

You should create your own thread for this.
The main reason is so people in the future will be able to find it more easily, and I might not have the time/experience/inclination to create every request someone makes, so making your own thread will allow other people to help you.

On that front, go make a thread here, and I'll post the script there for you.

Appreciate it.
Of course I mean a normal chest, that is, you go and press the chest and it gives you some objects, more than anything it is that. so I can create missions on the map. It would be a great help and right now I will create the thread and tag you if it is not a hassle.
 

Crest

New Member
Joined
Mar 25, 2008
Messages
11
Reaction score
2
Location
Poland
Lua:
[2000] = {
    minLevel = 50,
    storageUnique = 2000,
    items = {
        [1] = {type = "item", item = 2160, count = 1},
        [2] = {type = "experience", amount = 10000},
    },
},
Ye, I try it before I post here, but its don't work for me, I get only one crystal coin and nothing more. It can be problem with quest system? I'm using orginal from tfs 1.4 downgraded to 8.6 version in TFS-1.4-Downgrades-8.60\data\actions\scripts\quests:

Lua:
local annihilatorReward = {2421, 2400, 2431, 2494}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.uid <= 1250 or item.uid >= 30000 then
        return false
    end

    local itemType = ItemType(item.uid)
    if itemType:getId() == 0 then
        return false
    end

    local itemWeight = itemType:getWeight()
    local playerCap = player:getFreeCapacity()
    if table.contains(annihilatorReward, item.uid) then
        if player:getStorageValue(PlayerStorageKeys.annihilatorReward) == -1 then
            if playerCap >= itemWeight then
                if item.uid == 1990 then
                    player:addItem(1990, 1):addItem(2326, 1)
                else
                    player:addItem(item.uid, 1)
                end
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. '.')
                player:setStorageValue(PlayerStorageKeys.annihilatorReward, 1)
                player:addAchievement("Annihilator")
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        end
    elseif player:getStorageValue(item.uid) == -1 then
        if playerCap >= itemWeight then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. '.')
            player:addItem(item.uid, 1)
            player:setStorageValue(item.uid, 1)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
        end
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end
    return true
end
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Ye, I try it before I post here, but its don't work for me, I get only one crystal coin and nothing more. It can be problem with quest system? I'm using orginal from tfs 1.4 downgraded to 8.6 version in TFS-1.4-Downgrades-8.60\data\actions\scripts\quests:

Lua:
local annihilatorReward = {2421, 2400, 2431, 2494}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.uid <= 1250 or item.uid >= 30000 then
        return false
    end

    local itemType = ItemType(item.uid)
    if itemType:getId() == 0 then
        return false
    end

    local itemWeight = itemType:getWeight()
    local playerCap = player:getFreeCapacity()
    if table.contains(annihilatorReward, item.uid) then
        if player:getStorageValue(PlayerStorageKeys.annihilatorReward) == -1 then
            if playerCap >= itemWeight then
                if item.uid == 1990 then
                    player:addItem(1990, 1):addItem(2326, 1)
                else
                    player:addItem(item.uid, 1)
                end
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. '.')
                player:setStorageValue(PlayerStorageKeys.annihilatorReward, 1)
                player:addAchievement("Annihilator")
            else
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
            end
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        end
    elseif player:getStorageValue(item.uid) == -1 then
        if playerCap >= itemWeight then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. '.')
            player:addItem(item.uid, 1)
            player:setStorageValue(item.uid, 1)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a ' .. itemType:getName() .. ' weighing ' .. itemWeight .. ' oz it\'s too heavy.')
        end
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end
    return true
end
The script you posted has nothing to do with this thread.
The script in this thread is a stand-alone system. It's not meant to be incorporated into other scripts.

The basic idea is that you put a UniqueId on a chest in your map editor

Then create a new table entry in data/lib/quest_chests.lua, that tells the server what reward you get from that chest.

Just step 1, step 2. Done.

---
If you need help with the script you posted, open up a new thread in Support.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
if questChests[questChest].minLevel => playerLevel then
On line 36 is a minor error. change => to <
return true
end
end
Lines 119-121 are slightly scuffed.
With the return true being inside of the loop, only 1 reward will be given, instead of all in the table.

change for
Lua:
    end
    return true
end

That should solve your issue @Crest
 
Top