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

Talk with npc, key word starts a quest (with quest log)

Creon01001

New Member
Joined
Aug 20, 2011
Messages
10
Reaction score
0
Tibia is focused a lot on quest's and npc's, and I wanted to put that into a server.

So the title of the thread kinda says what I want. I would like to have this npc that will give you a quest when you say a keyword.

Example:
Code:
You: Hi
NPC: Hello, how can I help you?
You: Job
NPC: blah blah blah
You: quest (or any word)
...and then once you say whatever the word is, you get a new quest in your quest log.

Thanks in advance!
 
There is no such function for that, but I might know how to do it if you know how to add a quest to the quest log manually and you tell me ;)
 
Just make an NPC that sets a storage after saying "quest(or any word)" then go to data/XML/quests.xml and read the example.
 
There you are, replace STORAGEVALUEID with the storage value id and add the required code to quests.xml and you're done ;)
Code:
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end

local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end

local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end

local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v)) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		removeFocus(cid)
	end
end

function onCreatureSay(cid, type, msg)
	if((msg == "hi") and not (isFocused(cid))) then
		selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, true)
		selfSay("Do you want to see my {wares}?", cid)
		addFocus(cid)
	elseif((isFocused(cid)) and (msg == "mission" or msg == "quest")) then
		selfSay("Your quest log has been updated!", cid)
		doCreatureSetStorage(cid, STORAGEVALUEID, 1)
	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("Goodbye!", cid, true)
		closeShopWindow(cid)
		removeFocus(cid)
	end
end

function onThink()
	for i, focus in pairs(focuses) do
		if(not isCreature(focus)) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end
 
Back
Top