Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,394
- Solutions
- 68
- Reaction score
- 1,065
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
Action script
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.
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: