• 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!

Quest chest error?

Powtreeman

Member
Joined
Sep 26, 2011
Messages
400
Reaction score
6
Location
USA
I am trying to make a quest reward but all it says when I click on the chest is You found a hawser. wtf is a hawser?
I found out the hawser is a RAW item. It just places it on the ground under me when I use the chest.
 
Last edited:
A hawser is the name of a rope part of a ship.
I assume you are using TFS 0.2 and you are trying to add action id 2000 and a random unique id to the chest which is for the 0.3 system.lua. TFS 0.2 uses a script quest.lua which works only with unique ids and chest ids.
If you want to use the system.lua you can add this script to actions.xml

XML:
<action actionid="2000" script="quests/system.lua"/>

system.lua
LUA:
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 == 2) then
					ret = " and "
				elseif(i == 1) then
					ret = ""
				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(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
		result = "You have found a reward. It is too heavy or you have not 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

If you want to use the chests with id 1740, 1747 till 1749, then remove this from actions.xml
XML:
<action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>
 
<actions>
<!-- Quests -->
<action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>
<action uniqueid="30015" script="quests/annihilator.lua"/>

is what I already have but what do I put in the properties of each chest?
 
Last edited:
Both scripts make it able to add the quest items in Remere. It's just that the quest.lua from 0.2 works a little different then the system.lua from 0.3. With the quest.lua the unique id is both the storage and the item, with the system.lua the item is the one you add in the chest and the unique id is only for the storage.
 
Alright I think I got it but how do I add more than 1 item? I mean I set the reward to be a backpack and set items in it but when I load it, it only gives me an empty backpack.
 
Im still not getting it.
Im trying to use regular 1740 chests and I put plate armor plate legs and some other stuff in them.
I removed <action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>
like you said.
Now the items appear in the chest but are not given as a reward and they respawn everytime I turn the server back on.
 
Did you added the system.lua in actions.xml and in the right folder? and did you added action id 2000 in the chest with an unique id?
Or do you get any errors in your console?
 
This is for the quest.lua, a script you won't need if you are using the system.lua
XML:
<action itemid="1740" script="quests/quests.lua"/>
<action fromid="1747" toid="1749" script="quests/quests.lua"/>
The reason for removing this is if you're using the system.lua with those chests it will conflict with the quest.lua script.

Be sure you added this in actions.xml
XML:
<action actionid="2000" script="quests/system.lua"/>
And that you have the system.lua script in folder quests in actions with the name system.
For in Remere be sure you have action id 2000 and an unique id in the chest.

Else, check if you get any errors in your console (The thing you start you server with).
 
BUMP
But what if I dont have the "docopyitem" func?

-------------------------------------------------
Which I dont :-(
 
It's tested on TFS 0.2.15 (Mystic Spirit) client 9.8-9.86
Code:
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(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
     result = "You have found a reward weighing " .. getItemWeightByUID(reward.uid) .. " oz. It is too heavy or you have not 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
Newer version with item result message fix when there are 3+ items in the chest.

If you get errors, post them.
And how did you added it in actions.xml and in the map?

Do you have other scripts that are using the same itemid(chests), actionid or uniqueid?
 
If you use the system.lua script, you only have to add the items in the chest, add actionid 2000 and an uniqueid. This is alot more easy then creating a new script or editing a script for every new chest.
 
Back
Top