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

Weird bug..

kokokoko

Veteran OT User
Joined
Feb 4, 2008
Messages
921
Reaction score
257
Problem's bolded.

The npc wont reply when i say 'yes' after finishing the first quest and asking for quest again.

Looks like my quest2_start = 1 is bugged, but can a variable be bugged? :confused:

Code:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 		npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 		npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 				npcHandler:onThink() end
-- OTServ event handling functions end

-- Makes sure the npc reacts when you say hi, bye etc.

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!


function creatureSayCallback(cid, type, msg)

quest = getPlayerStorageValue(cid, 7007)

pos = getPlayerPosition(cid)
voc = getPlayerVocation(cid)

sorcerer = 1
druid = 2
paladin = 3
knight = 4

AXE = 0000
SWORD = 0000
CLUB = 0000

IceCityName = "Iceta"
NameOfGuy = "Raff Glenham"

msg = string.lower(msg)

		if msgcontains(msg, 'quest') or msgcontains(msg, 'help') then
				if quest < 1 then
					selfSay('While i was asleep, a rotten frost troll stole my inkewll. Now i can not write my delivery letters to\nthe resource handlers i buy my raw material from!\nThe frost troll must have given it to the\nstrongest one among them.')
					selfSay('Please bring me my inkwell from the trolls.')
						setPlayerStorageValue(cid, 7007, 1)

					elseif quest == 1 then
						if doPlayerRemoveItem(cid, 7490, 1) == 1 then
						selfSay('Thank you for bringing back my inkwell!\nAnd i haven\'t forgot about your reward!')
								doSendMagicEffect(pos, 27)

							if voc == sorcerer then
								doPlayerAddItem(cid, 2189, 1)
									setPlayerStorageValue(cid, 7007, 2)

							elseif voc == druid then
								doPlayerAddItem(cid, 2185, 1)
									setPlayerStorageValue(cid, 7007, 2)

									elseif voc == paladin then
								doPlayerAddItem(cid, 2547, 55)
									setPlayerStorageValue(cid, 7007, 2)

									elseif voc == knight then
							selfsay('Do you want an axe, a sword or a club, ' .. getPlayerName(cid) .. '?')
								talk_state = 27
						if msgcontains(msg, 'axe') and talk_state == 27 then
								doPlayerAddItem(cid, AXE)
									setPlayerStorageValue(cid, 7007, 2)

						elseif msgcontains(msg, 'sword') and talk_state == 27 then
								doPlayerAddItem(cid, SWORD)
									setPlayerStorageValue(cid, 7007, 2)

						elseif msgcontains(msg, 'club') and talk_state == 27 then
								doPlayerAddItem(cid, CLUB)
									setPlayerStorageValue(cid, 7007, 2)

								end
						else
					selfSay('Eh.. I\'m sorry. I do not have any reward for you, my friend.')
				end
							else
						selfSay('You haven\'t brought me my lost inkwell.\nI am sure their strongest member has got it!\nPlease try to find it for me.')
					end








				[B]elseif quest == 2 then
					selfSay('You helped me get my inkwell back.\nI trust you a little.\nCould you bring this letter to ' .. NameOfGuy .. ' in ' .. IceCityName .. '?')
						quest2_start = 1
			
				if msgcontains(msg, 'yes') and quest2_start == 1 then
					selfSay('Ok. Do not lose the letter. If you do, i will have to charge you if you want a second chance.')
						doPlayerAddItem(cid, 1784, 1)
					setPlayerStorageValue(cid, 7007, 3)
						end[/B]
								
		
			elseif quest == 3 then
					selfSay('You need another letter?')
				talk_state = 2


					if quest == 4 then
				selfSay('Thank you! Here. I want you to have this.')
					doPlayerAddItem(cid, 2552, 1)
					end
end
			
		elseif msgcontains(msg, 'bye') then
			selfSay('Good bye, ' .. getPlayerName(cid) .. '. Please come back soon,\ni could use some help around here.')
		end

    return 1
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Thanks in advance,

//Kokokoko
 
Here I fixed some stuff, the last part you'll have to take care of yourself...
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 		npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 		npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 				npcHandler:onThink() end
-- OTServ event handling functions end

-- Makes sure the npc reacts when you say hi, bye etc.

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!


function creatureSayCallback(cid, type, msg)

	quest = getPlayerStorageValue(cid, 7007)

	pos = getPlayerPosition(cid)

	sorcerer = {1, 5}
	druid = {2, 6}
	paladin = {3, 7}
	knight = {4, 8}

	AXE = 0000
	SWORD = 0000
	CLUB = 0000

	IceCityName = "Iceta"
	NameOfGuy = "Raff Glenham"

	msg = string.lower(msg)

	if msgcontains(msg, 'quest') or msgcontains(msg, 'help') then
		if quest < 1 then
			selfSay('While I was asleep, a rotten frost troll stole my inkewll. Now I can not write my delivery letters to\nthe resource handlers I buy my raw material from!\nThe frost troll must have given it to the\nstrongest one among them.')
			selfSay('Please bring me my inkwell from the trolls.')
			setPlayerStorageValue(cid, 7007, 1)

		elseif quest == 1 then
			[COLOR="Red"][B]if doPlayerRemoveItem(cid, 7490, 1) == 1 then[/B][/COLOR]
				selfSay('Thank you for bringing back my inkwell!\nAnd i haven\'t forgot about your reward!')
				doSendMagicEffect(pos, 27)

				if isVocation(cid, sorcerer) then
					doPlayerAddItem(cid, 2189, 1)
					setPlayerStorageValue(cid, 7007, 2)

				elseif isVocation(cid, druid) then
					doPlayerAddItem(cid, 2185, 1)
					setPlayerStorageValue(cid, 7007, 2)

				elseif isVocation(cid, paladin) then
					doPlayerAddItem(cid, 2547, 55)
					setPlayerStorageValue(cid, 7007, 2)

				[COLOR="red"][B]elseif isVocation(cid, knight) then[/B][/COLOR]
					selfsay('Do you want an axe, a sword or a club, ' .. getPlayerName(cid) .. '?')
					if msgcontains(msg, 'axe') then
						doPlayerAddItem(cid, AXE)
						setPlayerStorageValue(cid, 7007, 2)

					elseif msgcontains(msg, 'sword') then
						doPlayerAddItem(cid, SWORD)
						setPlayerStorageValue(cid, 7007, 2)

					elseif msgcontains(msg, 'club') then
						doPlayerAddItem(cid, CLUB)
						setPlayerStorageValue(cid, 7007, 2)

					end
				else
					selfSay('Eh.. I\'m sorry. I do not have any reward for you, my friend.')
				end
			else
				selfSay('You haven\'t brought me my lost inkwell.\nI am sure their strongest member has got it!\nPlease try to find it for me.')
			end
		elseif quest == 2 then
			selfSay('You helped me get my inkwell back.\nI trust you a little.\nCould you bring this letter to ' .. NameOfGuy .. ' in ' .. IceCityName .. '?')
			quest2_start = 1

			if msgcontains(msg, 'yes') then
				selfSay('Ok. Do not lose the letter. If you do, i will have to charge you if you want a second chance.')
				doPlayerAddItem(cid, 1784, 1)
				setPlayerStorageValue(cid, 7007, 3)
			end


		elseif quest == 3 then
			selfSay('You need another letter?')
			talk_state = 2


		elseif quest == 4 then
			selfSay('Thank you! Here. I want you to have this.')
			doPlayerAddItem(cid, 2552, 1)
		end

	elseif msgcontains(msg, 'bye') then
		selfSay('Good bye, ' .. getPlayerName(cid) .. '. Please come back soon,\ni could use some help around here.')
	end

	return TRUE
end

function isVocation(cid, t)
	return isInArray(t, getPlayerVocation(cid)) == TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This means it will remove the item all the times of a knight until he say axe, sword or w/e
 
Last edited:
@up

Eh, you sure this works with all servers? I'm using FerOTS(I can't use SQL servers cuz of my stupid router(dont know its name..)

EDIT:
Same shit.. :(

Code:
NPC: I trust you a little. Could you bring this letter to Raff Glenham in Iceta?

God [16850: yes
--blank--
 
Last edited:
Back
Top