Hello,
need some help with advanced quest script from here.
I add all of .lua files to correct folders, add uid in map editor, tfs don't show any error in console but when I want from one chest get item and some exp it didn't work. I get only item, nothing more.
Here is my .lua
and one more from scripts/actions/quest_chests.lua
Any idea why this script didn't work?
need some help with advanced quest script from here.
I add all of .lua files to correct folders, add uid in map editor, tfs don't show any error in console but when I want from one chest get item and some exp it didn't work. I get only item, nothing more.
Here is my .lua
Lua:
questChests = {
---------------------------------------------------------
-- Example Quest Box 1
---------------------------------------------------------
[20007] = {
storageUnique = 2108,
items = {
[1] = {type = "item", item = 2160, count = 1},
},
},
[20000] = {
storageUnique = 2000,
items = {
[1] = {type = "item", item = 2434, count = 1},
[2] = {type = "experience", amount = 10000},
},
},
}
and one more from 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
-- Give rewward if player has not yet opened box --
-----------------------------------------------------------------------------------
for i = 1, #questChests[questChest].items do
local rewardType = questChests[questChest].items.type
-----------------------------------------------------------------------------------
-- Item Type Reward --
-----------------------------------------------------------------------------------
if rewardType == "item" then
local item = questChests[questChest].items.item
local count = questChests[questChest].items.count
player:addItem(item, count)
player:say("You have found ["..count.."x] "..capAll(getItemName(item)), TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have found ["..count.."x] "..capAll(getItemName(item)))
end
-----------------------------------------------------------------------------------
-- Experience Type Reward --
-----------------------------------------------------------------------------------
if rewardType == "experience" then
local amount = questChests[questChest].items.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.name
local maleOutfit = questChests[questChest].items.maleId
local femaleOutfit = questChests[questChest].items.femaleId
if player:getSex() == 0 then
player:addOutfit(femaleOutfit)
else
player:addOutfit(maleOutfit)
end
player:say("You have found "..outfitName.." outfit.", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have found "..outfitName.." outfit.")
end
-----------------------------------------------------------------------------------
-- Addon Type Reward --
-----------------------------------------------------------------------------------
if rewardType == "addon" then
local outfitName = questChests[questChest].items.outfit
local addon = questChests[questChest].items.addonNumber
local maleAddon = questChests[questChest].items.maleId
local femaleAddon = questChests[questChest].items.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 have found the first "..outfitName.." outfit addon.")
elseif addon == 2 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have found the second "..outfitName.." outfit addon.")
elseif addon == 3 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have found the third "..outfitName.." outfit addon.")
end
end
-----------------------------------------------------------------------------------
-- Mount Type Reward --
-----------------------------------------------------------------------------------
if rewardType == "mount" then
local mountName = questChests[questChest].items.mountName
local mountId = questChests[questChest].items.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 = 20000, 21000 do
advanceChest:uid(i)
end
advanceChest:register()
Any idea why this script didn't work?
Last edited: