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

Lua Making Quests / Items

Breakdown

Be good, or be good at it
Joined
Feb 5, 2009
Messages
334
Reaction score
9
Okay so in TFS (latest) i made a quest chest.

Added 2000 as actionID on the chest, and used 2160 as uniqueID on the chest. 2160 because thats one crystal coin which i want to be the reward. However when i go ingame, and click the chest it doesnt award the coin, it awards a chest. Yes, an actual quest chest.

Do i need to add anything to actions.xml? Help please.

Also item editing, i added this :
Code:
		<attribute key="healthGain" value="200"/>
		<attribute key="healthTicks" value="1500"/>
		<attribute key="absorbPercentFire" value="5"/>

to a shield, however when i go ingame it doesnt add the 200 health. Even stuff like :
Code:
		<attribute key="skillShield" value="10"/>
		<attribute key="magiclevelpoints" value="5"/>

Doesnt add up ingame, does anyone have any idea why?
 
Did you put item inside the chest?

to check if it works properly you can do the following things:
create a chest, put crystal coin inside
then /attr actionid 2000 uniqueid XXXX
and then chceck if it works (not with your GM character, but normal)
 
Im using "OTMapEditor" not remere's. Im using "OTMapEditor" cause remeres isnt available for latest tibia release.
 
o.0 sure it is.
The latest servers still use the 8.40 .otbm format because there was no sprites added in 8.41 or 8.42.


As for your problem you don't understand the new quest system yet.

First: Create a quest chest or any container.

Second: Add the item(s) you want as the reward inside the chest.

Third: Set the action id to 2000

Fourth: Set the unique id to any number (it will be used as the storage value for the quest)
 
O.O Wowowow didn't know that :p

Anyways, still doesn't take away from the fact that all the latest releases for 8.41/8.42 protocol still use the 8.40 .otbm format. :p
 
Okay, downloaded Remere's Map Editor, added tibia dat / spr to the folder. When i start the map editor, it says it cannot locate the spr / dat for tibia 8.40, so i downloaded tibia client 8.40. Placed that spr / dat into the folder, yet again it says it cannot find tibia 8.40 spr / dat ...
 
When it says that you need to click "browse" (not sure exactly what it says) in the message and navigate to the folder that the 8.4 tibia.spr and tibia.dat is located in.
 
What TFS are you using?

And

Also item editing, i added this :
Code:
		<attribute key="healthGain" value="200"/>
		<attribute key="healthTicks" value="1500"/>
		<attribute key="absorbPercentFire" value="5"/>

to a shield, however when i go ingame it doesnt add the 200 health. Even stuff like :
Code:
		<attribute key="skillShield" value="10"/>
		<attribute key="magiclevelpoints" value="5"/>

Doesnt add up ingame, does anyone have any idea why?

You need to check movements.xml and add both items there.

So if you want a shield (or any equipment piece) to have special attributes in game, you need to add the attributes in items.xml and the itemID in movements.xml for the server to "recognize" them.

Example:
Lets say you want a shield with itemID 1337 to be usable for lvl 50+ knights, this is what you would add in movements.xml:

Code:
	<movevent event="Equip" itemid="1337" slot="shield" level="50" function="onEquipItem">
		<vocation name="Knight"></vocation>
		<vocation name="Elite Knight" showInDescription="0"></vocation>
	</movevent>
	<movevent event="DeEquip" itemid="1337" slot="shield" function="onDeEquipItem"></movevent>

So just now do it with the ones you want for your server, also notice it must be both Equip and DeEquip.

Should work.

Cheers.
 
Finally got remere's map editor to work, but its the samething. I entered 2000 as the actionID on a chest, added the items in the container, and made the uniqueID 6000. Went ingame, clicked the chest, and the reward was a chest ...nothing in it.
 
Finally got remere's map editor to work, but its the samething. I entered 2000 as the actionID on a chest, added the items in the container, and made the uniqueID 6000. Went ingame, clicked the chest, and the reward was a chest ...nothing in it.

Tried to open the chest with a normal character?

GMs can't open chests, at least not in my server.
 
Try replacing your actions/scripts/quests/system.lua with this:
LUA:
local specialQuests = {
	[2001] = 30015 --Annihilator
}

local questsExperience = {
	[30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
		return TRUE
	end

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

	local result = "It is empty."
	if(getPlayerStorageValue(cid, storage) <= 0) then
		local items = {}
		local reward = 0

		local size = isContainer(item.uid) == TRUE 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

		if(reward ~= 0) then
			local ret = getItemDescriptions(reward.uid)
			if(reward.type > 0 and isItemRune(reward.itemid) == TRUE) then
				result = reward.type .. " charges " .. ret.name
			elseif(reward.type > 0 and isItemStackable(reward.itemid) == TRUE) then
				result = reward.type .. " " .. ret.plural
			else
				result = ret.article .. " " .. ret.name
			end
		else
			result = ""
			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.uid)
					if(tmp.type > 0 and isItemRune(tmp.itemid) == TRUE) then
						result = result .. tmp.type .. " charges " .. ret.name
					elseif(tmp.type > 0 and isItemStackable(tmp.itemid) == TRUE) 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 " .. getItemWeight(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])
				doSendAnimatedText(getCreaturePosition(cid), questsExperience[storage], TEXTCOLOR_WHITE)
			end
		end
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
	return TRUE
end
(for 0.3.4)
 
Yah I have partly a similar problem hehe, when I click on a quest chest it awards the chest with the items inside it. So theres usually tons of chests clogging up quest areas and stuff, really a pain in the *ss
 
Try replacing your actions/scripts/quests/system.lua with this:
LUA:
local specialQuests = {
	[2001] = 30015 --Annihilator
}

local questsExperience = {
	[30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) == TRUE) then
		return TRUE
	end

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

	local result = "It is empty."
	if(getPlayerStorageValue(cid, storage) <= 0) then
		local items = {}
		local reward = 0

		local size = isContainer(item.uid) == TRUE 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

		if(reward ~= 0) then
			local ret = getItemDescriptions(reward.uid)
			if(reward.type > 0 and isItemRune(reward.itemid) == TRUE) then
				result = reward.type .. " charges " .. ret.name
			elseif(reward.type > 0 and isItemStackable(reward.itemid) == TRUE) then
				result = reward.type .. " " .. ret.plural
			else
				result = ret.article .. " " .. ret.name
			end
		else
			result = ""
			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.uid)
					if(tmp.type > 0 and isItemRune(tmp.itemid) == TRUE) then
						result = result .. tmp.type .. " charges " .. ret.name
					elseif(tmp.type > 0 and isItemStackable(tmp.itemid) == TRUE) 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 " .. getItemWeight(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])
				doSendAnimatedText(getCreaturePosition(cid), questsExperience[storage], TEXTCOLOR_WHITE)
			end
		end
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
	return TRUE
end
(for 0.3.4)

I did that, but it still awarded the chest. I dont know why it wont get fixed.
 
[04/05/2009 19:06:36] Lua Script Error: [Action Interface]
[04/05/2009 19:06:36] data/actions/scripts/quests/system.lua:onUse

[04/05/2009 19:06:36] data/actions/scripts/quests/system.lua:10: attempt to call global 'getPlayerCustomFlagValue' (a nil value)
[04/05/2009 19:06:36] stack traceback:
[04/05/2009 19:06:36] data/actions/scripts/quests/system.lua:10: in function <data/actions/scripts/quests/system.lua:9>


It says that in in the CMD when I tries to open a quest chest.. I tried with some diffrent system.lua's and still the same.. Im using the new TFS mystic spirit server.. please halp :(
 
That script is for 0.3x

As for breakdown, make sure your lib folder is up to date for the correct server version you are using. Most important is your function.lua.
 
Back
Top