ivvanek
New Member
- Joined
- Mar 24, 2009
- Messages
- 113
- Reaction score
- 3
I have inspired with the following thread:
TFS 1.X+ - QUEST SCRIPT REQUEST (https://otland.net/threads/quest-script-request.270272/#post-2605953)
and
I have on my map editor many chests and other containers with
I have trying with this scripts, i make a file
quests2.lua:
added to
And when i click on the chest it will give me a chest to my backpack, when clicking on skeleton body to get reward i get skeleton body in my backpack too...
What's wrong?
TFS 1.X+ - QUEST SCRIPT REQUEST (https://otland.net/threads/quest-script-request.270272/#post-2605953)
and
TFS 1.X+ - Quest Chest 10.98 TFS 1.3 PROBLEM
Hello Otlands people! i have write a code so all my chest on the server that have actionid "2000" and random unique id will be rewarded when they open the chest. But the problem is i dont get any error in the console and it will only open the chest. I hope anyone could help me with a clean code...
otland.net
I have on my map editor many chests and other containers with
actionid=2000
and itemid reward uniqueid=1789
(for example) and when i open chests with actionid=2000
for reward i get chest (it depends which cointainter is reward box)I have trying with this scripts, i make a file
actions/scripts/quests.lua
quests2.lua:
Code:
local specialQuests = {
[2001] = 30015 --Annihilator
}
local questsExperience = {
[30015] = 10000
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local storage = specialQuests[item:getActionId()]
if not storage then
storage = item:getUniqueId()
if storage > 65535 then
return false
end
end
if player:getStorageValue(storage) > 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
return true
end
local itemType = ItemType(item:getId())
local container = Container(item.uid)
local playerCap = player:getFreeCapacity() / 100
local items = {}
local rewardWeight = 0
if itemType:isContainer() == true then
items = container:getItems()
rewardWeight = items[2]
if playerCap < rewardWeight then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. items[1][1]:getArticle() .. ' ' .. items[1][1]:getName() .. ' weighing ' .. rewardWeight .. ' oz it\'s too heavy.')
return true
end
items = items[1]
size = table.maxn(items)
if size == 1 then
local item = items[1]
local count = item:getCount()
local rewardContainer = Container(item.uid)
if rewardContainer ~= nil then
bag = player:addItem(item:getId(), 1)
local rewardItems = rewardContainer:getItems()[1]
for i = 1, #rewardItems do
bag:addItem(rewardItems[i]:getId(), rewardItems[i]:getCount())
end
else
player:addItem(item:getId(), count)
end
player:setStorageValue(storage, 1)
if count > 1 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. count .. ' ' .. item:getPluralName() .. '.')
else
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. item:getName() .. '.')
end
end
end
return true
end
added to
actions.xml
Code:
<action itemid="2000" script="quests/quests2.lua" />
<action itemid="2001" script="quests/quests2.lua" />
And when i click on the chest it will give me a chest to my backpack, when clicking on skeleton body to get reward i get skeleton body in my backpack too...
What's wrong?
Last edited: