oshrigames
Active Member
Check out the one I released a couple days ago its more optimized than this.
can you derect me into your optimized code please?
Check out the one I released a couple days ago its more optimized than this.
can you derect me into your optimized code please?
Lua Script Error: [Action Interface]
data/actions/scripts/monzera/multichests.lua:onUse
data/actions/scripts/monzera/multichests.lua:17: attempt to index global 'questChests' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/monzera/multichests.lua:17: in function <data/actions/scripts/monzera/multichests.lua:1>
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
Old post but dont understand the error. @strutZ
Code:Lua Script Error: [Action Interface] data/actions/scripts/monzera/multichests.lua:onUse data/actions/scripts/monzera/multichests.lua:17: attempt to index global 'questChests' (a nil value) stack traceback: [C]: in function '__index' data/actions/scripts/monzera/multichests.lua:17: in function <data/actions/scripts/monzera/multichests.lua:1>
questChests = {
---------------------------------------------------------
-- Example Quest Box 1
---------------------------------------------------------
[2000] = {
minLevel = 50,
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},
},
},
},
Your error is due to the fact you haven't loaded the other lib file.
Hello my friend, is there a possibility to modify this script so that I can choose the prizes that each vocation will receive and the items have the name of the player who made the quest recorded in their description?Been awhile since I have posted something here so I'm going to release my advanced quest chest
What does it do?
A quest chest that can hold rewards in the shape of an Item, Experience, Outfit or a addon!
Features
- Easy config
- Can add level requirements for chests
- Supports Item Rewards
- Supports Experience Rewards
- Supports Outfit Rewards
- Supports Addon Rewards
- Supports Mount Rewards
This system currently supports up to 100 chests. o add more simply up the "touid" in the actions.xml line.
Installation
data/global.lua
Lua:dofile('data/lib/quest_chests.lua')
data/lib/quest_chests.lua
Lua:questChests = { --------------------------------------------------------- -- Example Quest Box 1 --------------------------------------------------------- [2000] = { minLevel = 50, 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/actions/actions.xml
Lua:<action fromuid="2000" touid="2100" script="quest_chests.lua" />
data/actions/scripts/quest_chests.lua
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(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
It is definitely possible.Hello my friend, is there a possibility to modify this script so that I can choose the prizes that each vocation will receive and the items have the name of the player who made the quest recorded in their description?
could you modify and share? I would love to use this systemIt is definitely possible.
I literally got triggered by this message.It is definitely possible.
Lmao what I do?I literally got triggered by this message.
The future is now, old man. - Action - Advanced quest system for tfs 1.3 (https://otland.net/threads/advanced-quest-system-for-tfs-1-3.274305/)
[5010] = {
questStorage = 10000,
questStatus = 5,
questMsg_success = "Woho!",
questMsg_fail = "Nope, still weak!",
levelReq = 150,
expReward = 10000,
item_reward = {
[1] = {itemid = 8900, count = 1},
[2] = {itemid = 2195, count = 1}
}
},
--Example 2--
[5011] = {
questStorage = 10000,
questStatus = 5,
questMsg_success = "Woho!",
questMsg_fail = "Nope, still weak!",
levelReq = 150,
expReward = 10000,
item_reward = {
[1] = {itemid = 2517, count = 1},
[2] = {itemid = 2195, count = 1}
}
}
}
if chest.expReward then
player:addExperience(chest.expReward, true)
end
if chest.vocation then
if not table.contains(chest.vocation.id, player:getVocation():getId()) then
return player:sendCancelMessage("Your vocation cannot open this chest.")
end
end
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainExperience
data/events/scripts/player.lua:206: attempt to index local 'source' (a nil value)
stack traceback:
[C]: in function '__index'
data/events/scripts/player.lua:206: in function <data/events/scripts/player.lua:205>
[C]: in function 'addExperience'
data/actions/scripts/quest_chests.lua:57: in function <data/actions/scripts/quest_chests.lua:15>
function Player:onGainExperience(source, exp, rawExp) -- 205 line
if source:isMonster() then
local bonusExperience = source:getMonsterLevel() * 5
if source:getMonsterLevel() > 0 and bonusExperience > 1 then
exp = exp * bonusExperience
end
end
if rewardType == "experience" then
local amount = questChests[questChest].items[i].amount
player:addExperience(amount) -- 57 LINE
player:say(amount.." EXP gained!", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(nil)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You gained "..amount.." experience points.")
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
Lua Script Error: [Main Interface]
data/global.lua
data/lib/questchests.lua:7: '}' expected (to close '{' at line 2) near 'levelReq'
stack traceback:
[C]: at 0x7ff65a5f3700
[C]: in function 'dofile'
data/global.lua:4: in main chunk
[Warning - ScriptingManager::loadScriptSystems] Can not load data/global.lua
Lua:Lua Script Error: [Main Interface] data/global.lua data/lib/questchests.lua:7: '}' expected (to close '{' at line 2) near 'levelReq' stack traceback: [C]: at 0x7ff65a5f3700 [C]: in function 'dofile' data/global.lua:4: in main chunk [Warning - ScriptingManager::loadScriptSystems] Can not load data/global.lua