• 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 Advanced quest chests 1.x

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,877
Solutions
51
Reaction score
594
If you read any post in this thread you would know that you needed to change this on line 19

if questChests[questChest].minLevel => playerLevel thento
if questChests[questChest].minLevel >= playerLevel then
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
If you read any post in this thread you would know that you needed to change this on line 19

if questChests[questChest].minLevel => playerLevel thento
if questChests[questChest].minLevel >= playerLevel then
[Warning - Event::checkScript] Can not load script: scripts/quest_chests.lua
data/actions/scripts/quest_chests.lua:19: 'then' expected near '='
addet youre script still dosent work.....
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
ficed the prev error but now i got this one.... :(
[Warning - Event::checkScript] Can not load script: scripts/quest_chests.lua
data/actions/scripts/quest_chests.lua:58: 'then' expected near '='
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
Lua:
-- This function will capitalize the first letter of every word.
function capAll(str)
    local newStr = ""; wordSeparate = string.gmatch(str, "([^%s]+)")
    for v in wordSeparate do
        v = v:gsub("^%l", string.upper)
        if newStr ~= "" then
            newStr = newStr.." "..v
        else
            newStr = v
        end
    end
    return newStr
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
   -----------------------------------------------------------------------------------
   -- 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.")
       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
   end
   -----------------------------------------------------------------------------------
   -- Add in any cooldowns/storages --
   -----------------------------------------------------------------------------------
   player:setStorageValue(questChest, 1)
   return true
end

this is my quest_chests.lua
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,877
Solutions
51
Reaction score
594
You probably put the wrong id in or the mount is bugged and cant be used in the action script.
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,877
Solutions
51
Reaction score
594
In my experience i've noticed some mounts are bugged and can only be added to an account a certain way. Maybe it was just me, but I found this for many mounts and outfits.
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
533
ITs great to see people using this script and helping each other =) are all problems resolved now?
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
ITs great to see people using this script and helping each other =) are all problems resolved now?
seems like a sweet script! but the chest wont add mount first time i click dosent say shit,s econd to infinity it says "this chest is emty" i use 2000 as action id on the chest...
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
533
seems like a sweet script! but the chest wont add mount first time i click dosent say shit,s econd to infinity it says "this chest is emty" i use 2000 as action id on the chest...
show me the chest config bit.

the bit where you add the mount and items etc
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
show me the chest config bit.

the bit where you add the mount and items etc
if you scroll up its there :) removed this part "
  1. -- This function will capitalize the first letter of every word.
  2. function capAll(str)
  3. local newStr = ""; wordSeparate = string.gmatch(str, "([^%s]+)")
  4. for v in wordSeparate do
  5. v = v:gsub("^%l", string.upper)
  6. if newStr ~= "" then
  7. newStr = newStr.." "..v
  8. else
  9. newStr = v
  10. end
  11. end
  12. return newStr
  13. end"
 

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
278
Reaction score
12
if you scroll up its there :) removed this part "
  1. -- This function will capitalize the first letter of every word.
  2. function capAll(str)
  3. local newStr = ""; wordSeparate = string.gmatch(str, "([^%s]+)")
  4. for v in wordSeparate do
  5. v = v:gsub("^%l", string.upper)
  6. if newStr ~= "" then
  7. newStr = newStr.." "..v
  8. else
  9. newStr = v
  10. end
  11. end
  12. return newStr
  13. end"
is this code correcT? (BUMP)
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,877
Solutions
51
Reaction score
594
Going to repost this.... I updated the code and tested it to support:

1. Quest Status chests (can only be opened at a certain point in a quest)
2. Key required chests
3. Multiple item rewards, mounts, and addons.

Lib code
Code:
questChests = {
--Main example--
   [500] = {
        questStorage = 10000,
        questStatus = 5,
        questMsg_success = "You have found the item now go do blah blah blah",
        questMsg_fail = "You are not ready to open this chest. Go do blah blah blah",
        levelReq = 40,
        keyReq = 2143,
        expReward = 10000,
        item_reward = {
        [1] = {itemid = 1111, count = 1},
        [2] = {itemid = 1111, count = 1}
        },
        outfit_reward = {
        [1] = {male = 111, female = 111, addons = 0}
        },
        addon_reward = {
        [1] = {male = 111, female = 111, addons = 1}
        },
        mount_reward = {
        [1] = {mountId = 1}
        }
       
   },
  --Example 2--
   [2000] = {
        item_reward = {
        [1] = {itemid = 1988, count = 1},
        [2] = {itemid = 2461, count = 1},
        [3] = {itemid = 2467, count = 1},
        [4] = {itemid = 2649, count = 1},
        [5] = {itemid = 2643, count = 1},
        [6] = {itemid = 2173, count = 1},
        [7] = {itemid = 2120, count = 1},
        [8] = {itemid = 2512, count = 1},
        [9] = {itemid = 2382, count = 1},
        [10] = {itemid = 2554, count = 1}
        }
   }
   
   
}

Action Code
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player = Player(player)
    chest = questChests[item:getAttribute('uid')]
    if not chest then return true end
   
    --------------Check if player has already opened the chest-----
    if player:getStorageValue(item:getAttribute('uid')) == 1 then
        return player:sendCancelMessage("The chest is empty.")
    end
   
    --------------Check if player has quest status-----------------
    if chest.storage and chest.status then
        if player:getStorageValue(chest.storage) ~= chest.status then
            return player:sendCancelMessage(chest.questMsg_fail)
        end
    end
   
    ---------------Check if player has level requirement------------
    if chest.levelReq then
        if player:getLevel() < chest.levelReq then
            return player:sendCancelMessage("You must be level "..chest.levelReq.. " to open this chest.")
        end
    end
   
    --------------Check if player has key required-------------------
    if chest.keyReq then
        if player:getItemCount(chest.keyReq) < 1 then
            return player:sendCancelMessage("This chest requires a key to open.")
        end
    end
   
    ------------Give player EXP reward-------------------------------
    if chest.expReward then
        player:addExperience(chest.expReward, true)
    end
   
    ------------Give player reward items---------------------
    if chest.item_reward then
        for i = 1, #chest.item_reward do
            player:addItem(chest.item_reward[i].itemid, chest.item_reward[i].count, 1)
        end
    end
   
    ------------Give player outfit reward--------------------
    if chest.outfit_reward then
        for i = 1, #chest.outfit_reward do
            if player:getSex() == 0 then
                player:addOutfit(chest.outfit_reward[i].female, chest.outfit_reward[i].addons)
            else
                player:addOutfit(chest.outfit_reward[i].male, chest.outfit_reward[i].addons)
            end
        end
    end
   
    -----------Give player addon reward-----------------------
    if chest.addon_reward then
        for i = 1, #chest.addon_reward do
            if player:getSex() == 0 then
                if chest.addon_reward.addons == 1 then
                    player:addOutfitAddon(chest.addon_reward[i].female, 1)
                else
                    player:addOutfitAddon(chest.addon_reward[i].female, 1)
                    player:addOutfitAddon(chest.addon_reward[i].female, 2)
                end
            else
                if chest.addon_reward.addons == 1 then
                    player:addOutfitAddon(chest.addon_reward[i].male, 1)
                else
                    player:addOutfitAddon(chest.addon_reward[i].male, 1)
                    player:addOutfitAddon(chest.addon_reward[i].male, 2)
                end
            end
        end
    end
   
    ----------Give player mount reward--------------------------
    if chest.mount_reward then
        for i = 1, #chest.mount_reward do
            player:addMount(chest.mount_reward.mountId)
        end
    end
   
    if chest.questStatus then
        player:setStorageValue(chest.questStorage, chest.questStatus + 1)
    end
   
    player:sendCancelMessage("You have recieved your reward.")
    player:setStorageValue(item:getAttribute('uid'), 1)
    return false
end
 

Schwarzbeere

BraveOnline Developer
Joined
Feb 16, 2017
Messages
68
Reaction score
3
Location
Germany
Okay, I need help once again :D

Got 2 questions:
1. how to reward a key for example with number 3900?
2. how to reward a backpack und put something inside?

Thanks buddies :)
 

Eve

New Member
Joined
Jul 1, 2007
Messages
19
Reaction score
1
I'm getting this error when I use chest. No rewards.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quest_chests.lua:onUse
data/actions/scripts/quest_chests.lua:31: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/actions/scripts/quest_chests.lua:31: in function <data/actions/scripts/quest_chests.lua:14>
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,370
Solutions
6
Reaction score
533
I'm getting this error when I use chest. No rewards.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quest_chests.lua:onUse
data/actions/scripts/quest_chests.lua:31: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/actions/scripts/quest_chests.lua:31: in function <data/actions/scripts/quest_chests.lua:14>
try this

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -----------------------------------------------------------------------------------
    -- 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.")
        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(mount)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have unlocked the "..mountName.." mount.")
        end
    end
    -----------------------------------------------------------------------------------
    -- Add in any cooldowns/storages --
    -----------------------------------------------------------------------------------
    player:setStorageValue(questChest, 1)
    return true
end
 

Eve

New Member
Joined
Jul 1, 2007
Messages
19
Reaction score
1
Now this:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/quest_chests.lua:onUse
data/actions/scripts/quest_chests.lua:18: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/actions/scripts/quest_chests.lua:18: in function <data/actions/scripts/quest_chests.lua:1>

TFS 1.2 if it matter.
 
Top