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

[How-to] Quests

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,019
Solutions
1
Reaction score
1,029
Location
United States
FIRST OF ALL: This is for 0.3/0.4!

A tutorial on quests is probably long missing, so here we go, let's make one!
All of this will be based on the quest system that is compatible with Remere's Map-Editor, so there will be no new scripts that you need to add.

Simple Quest
This is just a basic quest, where if you click a chest, you get a prize.

Open your map in Remere's Map-Editor:
Then, right-click the quest chest, click Properties, you will see a new window containing the actionID, uniqueID, and a bunch of black squares.

In actionID, you must put 2000 (unless you know what you're doing).
In uniqueID, you put any number that has not been used in other things (hence unique), such as storage values (must be between 1000 and 65535).
To insert an item for the quest, click one of the black squares and then type the item name and click OK, then click OK again to finish adding the quest.

Here is an example:

vitEr.png


As you can see, the actionID is 2000 (it always should be 2000 for every quest).
The uniqueID is a random number I picked, in this case, I chose 12345 (cannot be used anywhere else).
Then I clicked the first black square and typed "boots of haste" and clicked OK. Tada, we're done!

============================================================================================================================================

Pick-only-one-item Quest
Have you ever done the Annihilator in Tibia? Know how you can't take all the prizes? You can only choose one prize.
Well, let's learn how to make one of these quests in a very simple way!

Go to data/actions/quests/system.lua:

Look for something like this at the top of the file:
Lua:
local specialQuests = {
	[2001] = 30015 --Annihilator
}
To add a new quest, you need to add a new line in this table:
Lua:
local specialQuests = {
	[2001] = 30015, --Annihilator
        [2002] = 12000 --New quest
}
Note: we added [2002] = 12000 --New quest following a comma(,).
[2002] = the actionID of the quest
12000 = the storage value of the quest
Note: both of these numbers can not be used again for other things, they are unique!

Now go to data/actions/actions.xml:

You need to add a new line for every quest you make using system.lua:
Lua:
<action actionid="2002" event="script" value="quests/system.lua"/>
Note: the actionID here must be the same actionID of the new quest you added in system.lua.

Now open your map in Remere's Map-Editor:
Then, right-click the quest chest, click Properties, then in actionID, you have to put in the same actionID you put in system.lua and actions.xml (in this case, it would be 2002).
Then leave uniqueID as 0, you do not need to use this.
Then select a black square and type in the name of the prize and click OK.
Repeat this for all the other chests in the quest (they all must have the same actionID).

Here is an example:

WgZaP.png


As you can see, the actionID for all the chests is 2002 (all the chests in the quest must have the same actionID).
The uniqueID is 0, you do not need to use this.
Then I clicked the first black square and typed the name of the item and clicked OK.


GOOD LUCK AND HOPE THIS HELPS!
ALL QUESTIONS AND PROBLEMS, POST HERE, I WILL TRY MY BEST TO HELP!
 
Last edited:
How can i change the required level of a quest :D ??

This can't be done using the map-editor, so you have to use a separate script for that. However, you could use a level door around the chests and whatnot, but it'll look sloppy.
You could probably find these scripts here on this forum, if not, make a request for them and maybe someone will make it.
I could make it, but I'm just being too lazy right now, will make it sometime in the future. (all you need to do is just add 1 line)
 
I always set the action id: 2000 And the same unique id for all the boxes, example 10000,
it has the same effect but less "scripting"
 
thanks for re-making this one. when you've been away from otserver for 2 years and coming back you need some refreshed tutorials like this. haha.

rep+
 
actually theres an easier way to do this

actionID = 2000 = quest or box with an item that will be given only once

uniqueID = from 10000-60000

you can use a similar id for your quests in case of several items as a reward and you want to pick 1 so if its poi for example

all the chest will be actionID = 2000 and all the rewards that can be only pick once or just 1 chest from all of them give them the same unique id


so 3 boxes :

actionID = 2000 = boh
actionID = 20001
actionID = 2000 = dsm
actionID = 20001
actionID = 2000 = royal helmet
actionID = 20001


it will only take 1 of those chests, i hope i make my self clear, no more scripting needed
 
actually theres an easier way to do this

actionID = 2000 = quest or box with an item that will be given only once

uniqueID = from 10000-60000

you can use a similar id for your quests in case of several items as a reward and you want to pick 1 so if its poi for example

all the chest will be actionID = 2000 and all the rewards that can be only pick once or just 1 chest from all of them give them the same unique id


so 3 boxes :

actionID = 2000 = boh
actionID = 20001
actionID = 2000 = dsm
actionID = 20001
actionID = 2000 = royal helmet
actionID = 20001


it will only take 1 of those chests, i hope i make my self clear, no more scripting needed

Yes, then you're gonna get annoying warnings that popup in your console.
It'll tell you that you have multiple similar uniqueIDs in the map.
This way is possible and works, but it is not the correct way to do it.
 
Yes, then you're gonna get annoying warnings that popup in your console.
It'll tell you that you have multiple similar uniqueIDs in the map.
This way is possible and works, but it is not the correct way to do it.

that might explain the unique id errors on my console <_<, didnt knew it but it does work LOLmight change it, ty for solving that doubt
 
I found that you need to duplicate the systems file (rename your duplicates) and run the extra scripts.
When I tried to add 2 extra quests to the system file alone, the quests all bugged.

I followed it to a T, didn't work.
So I made systemtwo and systemthree, put the actionID's in it etc, and worked perfectly.

Example of what I have:
(Using TFS 0.4)

Actions.xml
Code:
	<action actionid="2001" event="script" value="quests/system.lua"/>
	<action actionid="2002" event="script" value="quests/systemtwo.lua"/>
	<action actionid="2003" event="script" value="quests/systemthree.lua"/>

Systemthree.xml
Code:
local specialQuests = {
	[2003] = 12015 --Armors,
}

local questsExperience = {
	[12015] = 100000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF, cid)
		return true
	end

	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.uid)
		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.uid)
				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 " .. 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

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
	return true
end

Not sure if anyone else had this problem, but yeah. Chest boxes before I did this just opened up with their items inside, not actually give one.
 
Last edited:
You do not need to make multiple systems...
You're doing it wrong, I bet. It's working totally fine for me.
 
I've never had an issue with this, but in the latest versions of TFS, this quest system is removed. Adding the old "system.lua" doesn't seem to work. I'm not doing it wrong, trust me.

Is there a new system that has replaced this one?
 
Oh I see, you're using 0.2.
Hrmm.. I don't know how the system works there. I've always used 0.3 and 0.4, they have the system.
 
Back
Top