• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Quest Chest not working 2000-2001

Oldschool'er

Tibia since 1998'
Joined
Dec 14, 2010
Messages
2,198
Reaction score
149
Location
United States
So when i make a chest and make actionid 200 or 2001 it doesnt work, when its 2000 it just opens the box with the item in it, with 2001 is just says chest is empty, can someone help me? : S
 
For TFS 1.0

How it works: http://otland.net/threads/how-to-quests.148708/

actions.xml
Code:
<action actionid="2000" script="quests/system.lua"/>


system.lua
Code:
-- system.lua edited by Limos for TFS 0.2/1.0

local specialQuests = {
   [2001] = 30015 --Annihilator
}

local questsExperience = {
   [30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

   local storage = specialQuests[item.actionid]
   if(not storage) then
     storage = item.uid
     if(storage > 65535) then
       return false
     end
   end

   if(getPlayerStorageValue(cid, storage) > 0) then
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
     return true
   end

   local items = {}
   local reward = 0

   local size = isContainer(item.uid) and getContainerSize(item.uid) or 0
   if(size == 0) then
     reward = doCopyItem(item, false)
   else
     for i = 0, size do
       local tmp = getContainerItem(item.uid, i)
       if(tmp.itemid > 0) then
         table.insert(items, tmp)
       end
     end
   end

   size = table.maxn(items)
   if(size == 1) then
     reward = doCopyItem(items[1], true)
   end

   local result = ""
   if(reward ~= 0) then
     local ret = getItemDescriptions(reward.itemid)
     if(reward.type > 0 and isItemRune(reward.itemid)) then
       result = reward.type .. " charges " .. ret.name
     elseif(reward.type > 0 and isItemStackable(reward.itemid)) then
       result = reward.type .. " " .. ret.plural
     else
       result = ret.article .. " " .. ret.name
     end
   else
     if(size > 20) then
       reward = doCopyItem(item, false)
     elseif(size > 8) then
       reward = getThing(doCreateItemEx(1988, 1))
     else
       reward = getThing(doCreateItemEx(1987, 1))
     end
     for i = 1, size do
       local tmp = doCopyItem(items[i], true)
       if(doAddContainerItemEx(reward.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
         print("[Warning] QuestSystem:", "Could not add quest reward")
       else
         local ret = ", "
         if(i == 1) then
           ret = ""
         elseif(i == size) then
           ret = " and "
         end
         result = result .. ret
         ret = getItemDescriptions(tmp.itemid)
         if(tmp.type > 0 and isItemRune(tmp.itemid)) then
           result = result .. tmp.type .. " charges " .. ret.name
         elseif(tmp.type > 0 and isItemStackable(tmp.itemid)) then
           result = result .. tmp.type .. " " .. ret.plural
         else
           result = result .. ret.article .. " " .. ret.name
         end
       end
     end
   end

   if getPlayerFreeCap(cid) < getItemWeightByUID(reward.uid) then
     result = "You have found a reward weighing "..getItemWeightByUID(reward.uid).." oz. It is to heavy."
   elseif(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
     result = "You have found a reward, but you don't have enough space."
   else
     result = "You have found " .. result .. "."
     setPlayerStorageValue(cid, storage, 1)
     if(questsExperience[storage] ~= nil) then
       doPlayerAddExp(cid, questsExperience[storage])
     end
   end
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
   return true
end


global.lua
Code:
function doCopyItem(item, attributes)
   local attributes = attributes or false

   local ret = doCreateItemEx(item.itemid, item.type)
   if(attributes) then
     if(item.actionid > 0) then
       doSetItemActionId(ret, item.actionid)
     end
   end

   if(isContainer(item.uid) == TRUE) then
     for i = (getContainerSize(item.uid) - 1), 0, -1 do
       local tmp = getContainerItem(item.uid, i)
       if(tmp.itemid > 0) then
         doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
       end
     end
   end

   return getThing(ret)
end
 
For TFS 1.0

How it works: http://otland.net/threads/how-to-quests.148708/

actions.xml
Code:
<action actionid="2000" script="quests/system.lua"/>


system.lua
Code:
-- system.lua edited by Limos for TFS 0.2/1.0

local specialQuests = {
   [2001] = 30015 --Annihilator
}

local questsExperience = {
   [30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

   local storage = specialQuests[item.actionid]
   if(not storage) then
     storage = item.uid
     if(storage > 65535) then
       return false
     end
   end

   if(getPlayerStorageValue(cid, storage) > 0) then
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
     return true
   end

   local items = {}
   local reward = 0

   local size = isContainer(item.uid) and getContainerSize(item.uid) or 0
   if(size == 0) then
     reward = doCopyItem(item, false)
   else
     for i = 0, size do
       local tmp = getContainerItem(item.uid, i)
       if(tmp.itemid > 0) then
         table.insert(items, tmp)
       end
     end
   end

   size = table.maxn(items)
   if(size == 1) then
     reward = doCopyItem(items[1], true)
   end

   local result = ""
   if(reward ~= 0) then
     local ret = getItemDescriptions(reward.itemid)
     if(reward.type > 0 and isItemRune(reward.itemid)) then
       result = reward.type .. " charges " .. ret.name
     elseif(reward.type > 0 and isItemStackable(reward.itemid)) then
       result = reward.type .. " " .. ret.plural
     else
       result = ret.article .. " " .. ret.name
     end
   else
     if(size > 20) then
       reward = doCopyItem(item, false)
     elseif(size > 8) then
       reward = getThing(doCreateItemEx(1988, 1))
     else
       reward = getThing(doCreateItemEx(1987, 1))
     end
     for i = 1, size do
       local tmp = doCopyItem(items[i], true)
       if(doAddContainerItemEx(reward.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
         print("[Warning] QuestSystem:", "Could not add quest reward")
       else
         local ret = ", "
         if(i == 1) then
           ret = ""
         elseif(i == size) then
           ret = " and "
         end
         result = result .. ret
         ret = getItemDescriptions(tmp.itemid)
         if(tmp.type > 0 and isItemRune(tmp.itemid)) then
           result = result .. tmp.type .. " charges " .. ret.name
         elseif(tmp.type > 0 and isItemStackable(tmp.itemid)) then
           result = result .. tmp.type .. " " .. ret.plural
         else
           result = result .. ret.article .. " " .. ret.name
         end
       end
     end
   end

   if getPlayerFreeCap(cid) < getItemWeightByUID(reward.uid) then
     result = "You have found a reward weighing "..getItemWeightByUID(reward.uid).." oz. It is to heavy."
   elseif(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
     result = "You have found a reward, but you don't have enough space."
   else
     result = "You have found " .. result .. "."
     setPlayerStorageValue(cid, storage, 1)
     if(questsExperience[storage] ~= nil) then
       doPlayerAddExp(cid, questsExperience[storage])
     end
   end
   doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
   return true
end


global.lua
Code:
function doCopyItem(item, attributes)
   local attributes = attributes or false

   local ret = doCreateItemEx(item.itemid, item.type)
   if(attributes) then
     if(item.actionid > 0) then
       doSetItemActionId(ret, item.actionid)
     end
   end

   if(isContainer(item.uid) == TRUE) then
     for i = (getContainerSize(item.uid) - 1), 0, -1 do
       local tmp = getContainerItem(item.uid, i)
       if(tmp.itemid > 0) then
         doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
       end
     end
   end

   return getThing(ret)
end

sNnnUhL.png
 
Then just use the default system.lua, the one jolle posted is for TFS 0.2 (also works on TFS 1.0).
Post errors if you have them and how it's added in actions.xml.
 
i dont know where i would get it, i know in actions.xml but what do i copy? the entire actions.xml?
Always try to give more information. Posts like before where you simply say 'There are no errors.' doesn't help anyone help you.
Remember, don't get mad at us for trying to help you. We are helping you.
On that note, you can either use the [CODE[ tags [/CODE[ (reverse to close) to post the relevant information asked by limos,
Or, you can use http://pastebin.com/ , then post the url to the code pasted there.
We are here to help, however we are not by any means required to help anyone.
Try to keep positive. You'll reach a resolution soon.
 
i dont know where i would get it, i know in actions.xml but what do i copy? the entire actions.xml?
You can post the entire actions.xml (pastebin if it's to long) or just the lines for the system.lua, you can look for system.lua or 2000 with ctrl f if you can't find it.
 
its fixed thanks to all who helped! had to add 2000 to actions.xml

<action actionid="2000" event="script" value="quests/system.lua"/>
<action actionid="2001" event="script" value="quests/system.lua"/>
 
Back
Top