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

Lua [NPC] Issue with message NOT containing a word

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
629
Location
Canada
Code:
if(msgcontains(msg, 'honour') and storage == 8) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 4
	elseif(not(msgcontains(msg, 'honour')) and storage == 8) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 5
end

I want to make it so if they say the word honour, it sets talkState to 4 and asks if it's their final answer. That works if the elseif isn't there. If they say anything other than honour, I want it to do the same but with talkState as 5. I can't get the elseif to work. Is there like a msgnotcontains sorta command?
 
Lua:
if storage == 8 then
	selfSay('Is that your final answer?', cid)
	talkState[cid] = msgcontains(msg, 'honour') and 4 or 5
end
 
Doesn't work. Maybe it'd help if you had more of the script. The whole mission is:
Code:
---------------------------------------------------------

--Mission 4--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 18) then
		selfSay('This task is a riddle. It won\'t be as easy as the first one. I don\'t give options - I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
		setPlayerStorageValue(cid,135,19)
	elseif(msgcontains(msg, 'mission') and storage == 19) then
		selfSay('I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
	end
---------------------------------------------------------
	if(msgcontains(msg, 'honour') and storage == 19) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 4
	elseif(not(msgcontains(msg, 'honour')) and storage == 19) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 5
	end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
		setPlayerStorageValue(cid,135,20)
		doPlayerAddExperience(cid,25000)
		doSendAnimatedText(pos, "25000", COLOR_WHITE)
		selfSay('Correct. The second rule is that honour defeats all other forces. Your skills are strong in all areas. I reward you. You may ask for another {mission}.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,7574,-1)
		setPlayerStorageValue(cid,136,1)
		selfSay('Honour defeats all other forces. That is the second rule. Your poor listening skills and honour have made me lose my {sabre} again. Now, go find it again. Your {rank} has gone down as well. You will get it back after you find my {sabre} again.', cid)
		talkState[talkUser] = 0
	end
 
what if you just throw in an else instead?
Lua:
	if(msgcontains(msg, 'honour') and storage == 19) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 4
	else
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 5
	end
 
if I use an else then it applies to the rest of the script so every time I say something it says 'Is that your final answer?'

edit:
19:39 RazorBlade [91]: mission
19:39 Bill the Assassin: This task is a riddle. It won't be as easy as the first one. I don't give options - I'm swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.
19:39 Bill the Assassin: Is that your final answer?
19:40 RazorBlade [91]: rank
19:40 Bill the Assassin: Is that your final answer?
19:40 Bill the Assassin: Your rank is 'Thief'.
 
so this then
Lua:
if storage == 19 then
	if msgcontains(msg, 'honour') then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 4
	else
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 5
	end
end
 
Lua:
	if storage == 19 and not isInArray({4,5}, talkState[talkUser]) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = msgcontains(msg, 'honour') and 4 or 5
	end
 
Lua:
	if storage == 19 and not isInArray({4,5}, talkState[talkUser]) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = msgcontains(msg, 'honour') and 4 or 5
	end
19:52 RazorBlade [91]: mission
19:52 Bill the Assassin: I'm swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.
19:52 Bill the Assassin: Is that your final answer?

Edit:
Here's the whole script. Ignore mission 5, I haven't made that part work yet. It doesn't affect the script at all at this point.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,135)
local storage2 = getPlayerStorageValue(cid,136)
local Ranks = {
[0] = {"Initiate"},
[1] = {"Scout"},
[2] = {"Thief"},
[3] = {"Rogue"},
[4] = {"Ninja"},
[5] = {"Assassin"}
}
local pos = getCreaturePosition(cid)
	if(msgcontains(msg, 'quest')) then
	if getPlayerLevel(cid) >= 90 then
	if storage == 11 then
		selfSay('Good to see a new face here. You don\'t look like much, but you seem to have survived Bob\'s tasks. Mine are not so easy. The second rule is honour. Honour defeats all other forces. Remember this. Feel free to ask for a {mission}.', cid)
		setPlayerStorageValue(cid,135,12)
	else
		selfSay('You\'ve already begun my quest. Ask me for a {mission} or ask about your {rank}.', cid)
	end
	else
		selfSay('I\'m afraid you\'re going to have to be a higher level. Come back when you\'ve reached level 90.', cid)
	end
	return true
end
---------------------------------------------------------

--Mission 1--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 12) then
		selfSay('Alright. Here\'s your first mission. It\'s a little different than what you\'re used to so far. You must slay 10 {Demons}. I cannot tell you where to find them.', cid)
		setPlayerStorageValue(cid,135,13)
		setPlayerStorageValue(cid,8888,1)
	elseif(msgcontains(msg, 'mission') and storage == 13) then
		selfSay('Your task is killing 10 {Demons}.', cid)
	end
----------------------------------------------------------		
	if(msgcontains(msg, 'demons') and storage == 13) then
		selfSay('Have you killed those 10 demons?', cid)
		talkState[talkUser] = 1
	end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
	if getPlayerStorageValue(cid, 55551) >= 10 then
		setPlayerStorageValue(cid,135,14)
		setPlayerStorageValue(cid,8888,-1)
		setPlayerStorageValue(cid,15551,-1)
		setPlayerStorageValue(cid,55551,-1)
		doPlayerAddExperience(cid,35000)
		doSendAnimatedText(pos, "35000", COLOR_WHITE)
		selfSay('You managed to kill all 10. Impressive. Here\'s your first reward. You can ask for your next {mission} anytime.', cid)
		talkState[talkUser] = 0
	else
		selfSay('Do you think I don\'t know when you\'ve killed them? I do. Now go and do it for real.', cid)
		talkState[talkUser] = 0
	end
	end
---------------------------------------------------------	
	
--Mission 2--
	
---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 14) then
		selfSay('Your second mission is similar to your first. Kill 25 {Destroyers} and then come talk to me.', cid)
		setPlayerStorageValue(cid,135,15)
		setPlayerStorageValue(cid,9899,1)
	elseif(msgcontains(msg, 'mission') and storage == 15) then
		selfSay('You have to kill 25 {Destroyers}.', cid)
	end
----------------------------------------------------------		
	if(msgcontains(msg, 'destroyers') and storage == 15) then
		selfSay('Have you destroyed the 25 destroyers?', cid)
		talkState[talkUser] = 2
	end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
	if getPlayerStorageValue(cid, 9889) >= 10 then
		setPlayerStorageValue(cid,135,16)
		setPlayerStorageValue(cid,9899,-1)
		setPlayerStorageValue(cid,9889,-1)
		setPlayerStorageValue(cid,9998,-1)
		doPlayerAddExperience(cid,40000)
		doSendAnimatedText(pos, "40000", COLOR_WHITE)
		selfSay('You actually killed them all. Here is a small reward. Ask for another {mission} if you want.', cid)
		talkState[talkUser] = 0
	else
		selfSay('I know you didn\'t kill them so go do it before I change my mind about you!', cid)
		talkState[talkUser] = 0
	end
	end
---------------------------------------------------------

--Mission 3--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 16) then
		selfSay('Your third mission should prove to be a little more difficult. I seem to have lost my lucky {sabre}. I was stalking a wanted member of the {Mecha Group} and I was found and ambushed. I fought with all my might and got away but I dropped my {sabre}. Go find it please!', cid)
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,3121,1)
	elseif(msgcontains(msg, 'mission') and storage == 17) then
		selfSay('Bring back my {sabre} from the caverns of the {Mecha Group}.', cid)
	end
---------------------------------------------------------
	if(msgcontains(msg, 'sabre') and storage == 17) then
		selfSay('Did you infiltrate the caverns and get me my sabre?', cid)
		talkState[talkUser] = 3
	end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
	if getPlayerItemCount(cid, 213) >= 1 then
		doPlayerRemoveItem(cid, 213, 1)
		setPlayerStorageValue(cid,135,18)
		setPlayerStorageValue(cid,136,2)
		setPlayerStorageValue(cid,3121,-1)
		doPlayerAddExperience(cid,45000)
		doSendAnimatedText(pos, "45000", COLOR_WHITE)
		selfSay('Ah, thank you! I have missed this blade dearly. For your bravery and sheer skill, I grant you this reward and a brand new {rank} you can ask for a {trade} if you wish.', cid)
		talkState[talkUser] = 0
	else
		selfSay('Oh? You don\'t have it yet! Please hurry with my {sabre}.', cid)
		talkState[talkUser] = 0
	end
	end
---------------------------------------------------------

--Mission 4--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 18) then
		selfSay('This task is a riddle. It won\'t be as easy as the first one. I don\'t give options - I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
		setPlayerStorageValue(cid,135,19)
	elseif(msgcontains(msg, 'mission') and storage == 19) then
		selfSay('I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
	end
---------------------------------------------------------
	if storage == 19 then
	if msgcontains(msg, 'honour') then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 4
	else
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = 5
	end
end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
		setPlayerStorageValue(cid,135,20)
		doPlayerAddExperience(cid,25000)
		doSendAnimatedText(pos, "25000", COLOR_WHITE)
		selfSay('Correct. The second rule is that honour defeats all other forces. Your skills are strong in all areas. I reward you. You may ask for another {mission}.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,7574,-1)
		setPlayerStorageValue(cid,136,1)
		selfSay('Honour defeats all other forces. That is the second rule. Your poor listening skills and honour have made me lose my {sabre} again. Now, go find it again. Your {rank} has gone down as well. You will get it back after you find my {sabre} again.', cid)
		talkState[talkUser] = 0
	end
---------------------------------------------------------

--Mission 5--

---------------------------------------------------------
if(msgcontains(msg, 'mission') and storage == 9) then
		selfSay('I think you are doing well. This will be your last mission from me. It is very important. I need you to enter the nearby cave and find my {assassin cloak}. You can\'t miss it. It is currently being guarded by a powerful rogue. I haven\'t the time to get it myself.', cid)
		setPlayerStorageValue(cid,135,10)
	elseif(msgcontains(msg, 'mission') and storage == 10) then
		selfSay('Bring me my {assassin cloak}.', cid)
	end
---------------------------------------------------------
	if(msgcontains(msg, 'assassin cloak') and storage == 10) then
		selfSay('Have you completed my final mission? Did you bring me my assassin cloak?', cid)
		talkState[talkUser] = 6
	end
---------------------------------------------------------
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 6) then
	if getPlayerItemCount(cid, 2664) >= 1 then
		doPlayerRemoveItem(cid, 2664, 1)
		setPlayerStorageValue(cid,135,11)
		setPlayerStorageValue(cid,136,1)
		doPlayerAddExperience(cid,30000)
		doSendAnimatedText(pos, "30000", COLOR_WHITE)
		selfSay('Well, I am simply impressed that you have made it this far. Go on and find Bill the Assassin and you can start your training. Your {rank} is now \'Scout\'. Here is your reward.', cid)
		talkState[talkUser] = 0
	else
		selfSay('You do not have what I asked for. Go get my {assassin cloak}!', cid)
		talkState[talkUser] = 0
	end
	end
---------------------------------------------------------

--Rank--

---------------------------------------------------------
local Rank = Ranks[storage2]
local RankName = Rank[1]
	if(msgcontains(msg, 'rank') and storage2 > -1) then
		selfSay('Your rank is \'' .. RankName .. '\'.', cid)
	end
---------------------------------------------------------

--Mecha Group--

---------------------------------------------------------
	if(msgcontains(msg, 'mecha group') and storage == 19) then
		selfSay('The Mecha Group is a powerful guild made up of different golems and their pets. Worker and War Golems are strong and technologically advanced beings. They have harnessed the power of Energy Elementals of all kinds and made them their pets. Beware the Golem Leader.', cid)
	end
---------------------------------------------------------

--Trade--

---------------------------------------------------------
	if(msgcontains(msg, 'trade') and storage2 >= 2) then
	local shopModule = ShopModule:new()
	npcHandler:addModule(shopModule)
	shopModule:addBuyableItem({'assassin star'}, 7368, 250, 1, 'assassin star')
	shopModule:addSellableItem({'gear wheel'}, 9690, 500,'gear wheel')
	shopModule:addSellableItem({'gear crystal'}, 10572, 250, 'gear crystal')	
	shopModule:addSellableItem({'war crystal'}, 10571, 1000, 'war crystal')
	end
---------------------------------------------------------

--End--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage >= 20) then
		selfSay('I am all out of missions. Maybe Brian the Assassin has some jobs for you? In the meantime, you could ask me about your {rank} or ask for a {trade}.', cid)
		talkState[talkUser] = 0
	end
	
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
if storage == 19 then
   if msgcontains(msg, 'honour') then
      selfSay('Is that your final answer?', cid)
      talkState[talkUser] = 4
   else
    selfSay('Is that your final answer?', cid)
    talkState[talkUser] = 5
   end
end
??
 
Lua:
if storage == 19 then
   if msgcontains(msg, 'honour') then
      selfSay('Is that your final answer?', cid)
      talkState[talkUser] = 4
   else
    selfSay('Is that your final answer?', cid)
    talkState[talkUser] = 5
   end
end
??


19:59 RazorBlade [91]: mission
19:59 Bill the Assassin: Bring back my sabre from the caverns of the Mecha Group.
19:59 Bill the Assassin: Is that your final answer?

Even if it's not on the right mission it says it.



Alright, edit:
I changed it all to elseifs. Seems to work. I'll reset storages and start over to test
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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

local Ranks = {
	[0] = {"Initiate"},
	[1] = {"Scout"},
	[2] = {"Thief"},
	[3] = {"Rogue"},
	[4] = {"Ninja"},
	[5] = {"Assassin"}
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local storage = getPlayerStorageValue(cid,135)
	local storage2 = getPlayerStorageValue(cid,136)

	if(msgcontains(msg, 'quest')) then
		if getPlayerLevel(cid) >= 90 then
			if storage == 11 then
				selfSay('Good to see a new face here. You don\'t look like much, but you seem to have survived Bob\'s tasks. Mine are not so easy. The second rule is honour. Honour defeats all other forces. Remember this. Feel free to ask for a {mission}.', cid)
				setPlayerStorageValue(cid,135,12)
			else
				selfSay('You\'ve already begun my quest. Ask me for a {mission} or ask about your {rank}.', cid)
			end
		else
			selfSay('I\'m afraid you\'re going to have to be a higher level. Come back when you\'ve reached level 90.', cid)
		end
---------------------------------------------------------

--Mission 1--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 12) then
		selfSay('Alright. Here\'s your first mission. It\'s a little different than what you\'re used to so far. You must slay 10 {Demons}. I cannot tell you where to find them.', cid)
		setPlayerStorageValue(cid,135,13)
		setPlayerStorageValue(cid,8888,1)
	elseif(msgcontains(msg, 'mission') and storage == 13) then
		selfSay('Your task is killing 10 {Demons}.', cid)
----------------------------------------------------------		
	elseif(msgcontains(msg, 'demons') and storage == 13) then
		selfSay('Have you killed those 10 demons?', cid)
		talkState[cid] = 1
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 1) then
		if getPlayerStorageValue(cid, 55551) >= 10 then
			setPlayerStorageValue(cid,135,14)
			setPlayerStorageValue(cid,8888)
			setPlayerStorageValue(cid,15551)
			setPlayerStorageValue(cid,55551)
			doPlayerAddExperience(cid,35000)
			doSendAnimatedText(getThingPos(cid), "35000", COLOR_WHITE)
			selfSay('You managed to kill all 10. Impressive. Here\'s your first reward. You can ask for your next {mission} anytime.', cid)
		else
			selfSay('Do you think I don\'t know when you\'ve killed them? I do. Now go and do it for real.', cid)
		end
		talkState[cid] = 0
---------------------------------------------------------	
	
--Mission 2--
	
---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 14) then
		selfSay('Your second mission is similar to your first. Kill 25 {Destroyers} and then come talk to me.', cid)
		setPlayerStorageValue(cid,135,15)
		setPlayerStorageValue(cid,9899,1)
	elseif(msgcontains(msg, 'mission') and storage == 15) then
		selfSay('You have to kill 25 {Destroyers}.', cid)
----------------------------------------------------------		
	elseif(msgcontains(msg, 'destroyers') and storage == 15) then
		selfSay('Have you destroyed the 25 destroyers?', cid)
		talkState[cid] = 2
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 2) then
		if getPlayerStorageValue(cid, 9889) >= 10 then
			setPlayerStorageValue(cid,135,16)
			setPlayerStorageValue(cid,9899)
			setPlayerStorageValue(cid,9889)
			setPlayerStorageValue(cid,9998)
			doPlayerAddExperience(cid,40000)
			doSendAnimatedText(getThingPos(cid), "40000", COLOR_WHITE)
			selfSay('You actually killed them all. Here is a small reward. Ask for another {mission} if you want.', cid)
		else
			selfSay('I know you didn\'t kill them so go do it before I change my mind about you!', cid)
		end
		talkState[cid] = 0
---------------------------------------------------------

--Mission 3--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 16) then
		selfSay('Your third mission should prove to be a little more difficult. I seem to have lost my lucky {sabre}. I was stalking a wanted member of the {Mecha Group} and I was found and ambushed. I fought with all my might and got away but I dropped my {sabre}. Go find it please!', cid)
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,3121,1)
	elseif(msgcontains(msg, 'mission') and storage == 17) then
		selfSay('Bring back my {sabre} from the caverns of the {Mecha Group}.', cid)
---------------------------------------------------------
	elseif(msgcontains(msg, 'sabre') and storage == 17) then
		selfSay('Did you infiltrate the caverns and get me my sabre?', cid)
		talkState[cid] = 3
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 3) then
		if doPlayerRemoveItem(cid, 213, 1) then
			setPlayerStorageValue(cid,135,18)
			setPlayerStorageValue(cid,136,2)
			setPlayerStorageValue(cid,3121)
			doPlayerAddExperience(cid,45000)
			doSendAnimatedText(getThingPos(cid), "45000", COLOR_WHITE)
			selfSay('Ah, thank you! I have missed this blade dearly. For your bravery and sheer skill, I grant you this reward and a brand new {rank} you can ask for a {trade} if you wish.', cid)
		else
			selfSay('Oh? You don\'t have it yet! Please hurry with my {sabre}.', cid)
		end
		talkState[cid] = 0
---------------------------------------------------------

--Mission 4--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 18) then
		selfSay('This task is a riddle. It won\'t be as easy as the first one. I don\'t give options - I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
		setPlayerStorageValue(cid,135,19)
	elseif(msgcontains(msg, 'mission') and storage == 19) then
		selfSay('I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
		talkState[cid] = 7
---------------------------------------------------------
	elseif talkState[cid] == 7 and storage == 19 then
		selfSay('Is that your final answer?', cid)
		talkState[cid] = msgcontains(msg, 'honour') and 4 or 5
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 4) then
		setPlayerStorageValue(cid,135,20)
		doPlayerAddExperience(cid,25000)
		doSendAnimatedText(getThingPos(cid), "25000", COLOR_WHITE)
		selfSay('Correct. The second rule is that honour defeats all other forces. Your skills are strong in all areas. I reward you. You may ask for another {mission}.', cid)
		talkState[cid] = 0
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 5) then
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,7574)
		setPlayerStorageValue(cid,136,1)
		selfSay('Honour defeats all other forces. That is the second rule. Your poor listening skills and honour have made me lose my {sabre} again. Now, go find it again. Your {rank} has gone down as well. You will get it back after you find my {sabre} again.', cid)
		talkState[cid] = 0
---------------------------------------------------------

--Mission 5--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 9) then
		selfSay('I think you are doing well. This will be your last mission from me. It is very important. I need you to enter the nearby cave and find my {assassin cloak}. You can\'t miss it. It is currently being guarded by a powerful rogue. I haven\'t the time to get it myself.', cid)
		setPlayerStorageValue(cid,135,10)
	elseif(msgcontains(msg, 'mission') and storage == 10) then
		selfSay('Bring me my {assassin cloak}.', cid)
---------------------------------------------------------
	elseif(msgcontains(msg, 'assassin cloak') and storage == 10) then
		selfSay('Have you completed my final mission? Did you bring me my assassin cloak?', cid)
		talkState[cid] = 6
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[cid] == 6) then
		if doPlayerRemoveItem(cid, 2664, 1) then
			setPlayerStorageValue(cid,135,11)
			setPlayerStorageValue(cid,136,1)
			doPlayerAddExperience(cid,30000)
			doSendAnimatedText(getThingPos(cid), "30000", COLOR_WHITE)
			selfSay('Well, I am simply impressed that you have made it this far. Go on and find Bill the Assassin and you can start your training. Your {rank} is now \'Scout\'. Here is your reward.', cid)
		else
			selfSay('You do not have what I asked for. Go get my {assassin cloak}!', cid)
		end
		talkState[cid] = 0
---------------------------------------------------------

--Rank--

---------------------------------------------------------
	elseif(msgcontains(msg, 'rank') and storage2 > -1) then
		local Rank = Ranks[storage2]
		local RankName = Rank[1]
		selfSay('Your rank is \'' .. RankName .. '\'.', cid)
	end
---------------------------------------------------------

--Mecha Group--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mecha group') and storage == 19) then
		selfSay('The Mecha Group is a powerful guild made up of different golems and their pets. Worker and War Golems are strong and technologically advanced beings. They have harnessed the power of Energy Elementals of all kinds and made them their pets. Beware the Golem Leader.', cid)
---------------------------------------------------------

--Trade--

---------------------------------------------------------
	elseif(msgcontains(msg, 'trade') and storage2 >= 2) then
		local shopModule = ShopModule:new()
		npcHandler:addModule(shopModule)
		shopModule:addBuyableItem({'assassin star'}, 7368, 250, 1, 'assassin star')
		shopModule:addSellableItem({'gear wheel'}, 9690, 500,'gear wheel')
		shopModule:addSellableItem({'gear crystal'}, 10572, 250, 'gear crystal')	
		shopModule:addSellableItem({'war crystal'}, 10571, 1000, 'war crystal')
---------------------------------------------------------

--End--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage >= 20) then
		selfSay('I am all out of missions. Maybe Brian the Assassin has some jobs for you? In the meantime, you could ask me about your {rank} or ask for a {trade}.', cid)
		talkState[cid] = 0
	end
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I changed it myself, to:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,135)
local storage2 = getPlayerStorageValue(cid,136)
local Ranks = {
[0] = {"Initiate"},
[1] = {"Scout"},
[2] = {"Thief"},
[3] = {"Rogue"},
[4] = {"Ninja"},
[5] = {"Assassin"}
}
local Rank = Ranks[storage2]
local RankName = Rank[1]
local pos = getCreaturePosition(cid)
	if(msgcontains(msg, 'quest')) then
	if getPlayerLevel(cid) >= 90 then
	if storage == 11 then
		selfSay('Good to see a new face here. You don\'t look like much, but you seem to have survived Bob\'s tasks. Mine are not so easy. The second rule is honour. Honour defeats all other forces. Remember this. Feel free to ask for a {mission}.', cid)
		setPlayerStorageValue(cid,135,12)
	else
		selfSay('You\'ve already begun my quest. Ask me for a {mission} or ask about your {rank}.', cid)
	end
	else
		selfSay('I\'m afraid you\'re going to have to be a higher level. Come back when you\'ve reached level 90.', cid)
	end
	return true
end
---------------------------------------------------------

--Mission 1--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage == 12) then
		selfSay('Alright. Here\'s your first mission. It\'s a little different than what you\'re used to so far. You must slay 10 {Demons}. I cannot tell you where to find them.', cid)
		setPlayerStorageValue(cid,135,13)
		setPlayerStorageValue(cid,8888,1)
	elseif(msgcontains(msg, 'mission') and storage == 13) then
		selfSay('Your task is killing 10 {Demons}.', cid)
----------------------------------------------------------		
	elseif(msgcontains(msg, 'demons') and storage == 13) then
		selfSay('Have you killed those 10 demons?', cid)
		talkState[talkUser] = 1
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid, 55551) >= 10) then
		setPlayerStorageValue(cid,135,14)
		setPlayerStorageValue(cid,8888,-1)
		setPlayerStorageValue(cid,15551,-1)
		setPlayerStorageValue(cid,55551,-1)
		doPlayerAddExperience(cid,35000)
		doSendAnimatedText(pos, "35000", COLOR_WHITE)
		selfSay('You managed to kill all 10. Impressive. Here\'s your first reward. You can ask for your next {mission} anytime.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid, 55551) < 10) then
		selfSay('Do you think I don\'t know when you\'ve killed them? I do. Now go and do it for real.', cid)
		talkState[talkUser] = 0
---------------------------------------------------------	
	
--Mission 2--
	
---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 14) then
		selfSay('Your second mission is similar to your first. Kill 25 {Destroyers} and then come talk to me.', cid)
		setPlayerStorageValue(cid,135,15)
		setPlayerStorageValue(cid,9899,1)
	elseif(msgcontains(msg, 'mission') and storage == 15) then
		selfSay('You have to kill 25 {Destroyers}.', cid)
----------------------------------------------------------		
	elseif(msgcontains(msg, 'destroyers') and storage == 15) then
		selfSay('Have you destroyed the 25 destroyers?', cid)
		talkState[talkUser] = 2
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerStorageValue(cid, 9889) >= 25) then
		setPlayerStorageValue(cid,135,16)
		setPlayerStorageValue(cid,9899,-1)
		setPlayerStorageValue(cid,9889,-1)
		setPlayerStorageValue(cid,9998,-1)
		doPlayerAddExperience(cid,40000)
		doSendAnimatedText(pos, "40000", COLOR_WHITE)
		selfSay('You actually killed them all. Here is a small reward. Ask for another {mission} if you want.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerStorageValue(cid, 9889) < 25) then
		selfSay('I know you didn\'t kill them so go do it before I change my mind about you!', cid)
		talkState[talkUser] = 0
---------------------------------------------------------

--Mission 3--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 16) then
		selfSay('Your third mission should prove to be a little more difficult. I seem to have lost my lucky {sabre}. I was stalking a wanted member of the {Mecha Group} and I was found and ambushed. I fought with all my might and got away but I dropped my {sabre}. Go find it please!', cid)
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,3121,1)
	elseif(msgcontains(msg, 'mission') and storage == 17) then
		selfSay('Bring back my {sabre} from the caverns of the {Mecha Group}.', cid)
---------------------------------------------------------
	elseif(msgcontains(msg, 'sabre') and storage == 17) then
		selfSay('Did you infiltrate the caverns and get me my sabre?', cid)
		talkState[talkUser] = 3
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3 and getPlayerItemCount(cid, 213) >= 1) then
		doPlayerRemoveItem(cid, 213, 1)
		setPlayerStorageValue(cid,135,18)
		setPlayerStorageValue(cid,136,2)
		setPlayerStorageValue(cid,3121,-1)
		doPlayerAddExperience(cid,45000)
		doSendAnimatedText(pos, "45000", COLOR_WHITE)
		selfSay('Ah, thank you! I have missed this blade dearly. For your bravery and sheer skill, I grant you this reward and a brand new {rank} you can ask for a {trade} if you wish.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3 and getPlayerItemCount(cid, 213) < 1) then
		selfSay('Oh? You don\'t have it yet! Please hurry with my {sabre}.', cid)
		talkState[talkUser] = 0
---------------------------------------------------------

--Mission 4--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 18) then
		selfSay('This task is a riddle. It won\'t be as easy as the first one. I don\'t give options - I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
		setPlayerStorageValue(cid,135,19)
	elseif(msgcontains(msg, 'mission') and storage == 19) then
		selfSay('I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
---------------------------------------------------------
	elseif (storage == 19 and not isInArray({4,5}, talkState[talkUser])) then
		selfSay('Is that your final answer?', cid)
		talkState[talkUser] = msgcontains(msg, 'honour') and 4 or 5
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
		setPlayerStorageValue(cid,135,20)
		doPlayerAddExperience(cid,25000)
		doSendAnimatedText(pos, "25000", COLOR_WHITE)
		selfSay('Correct. The second rule is that honour defeats all other forces. Your skills are strong in all areas. I reward you. You may ask for another {mission}.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
		setPlayerStorageValue(cid,135,17)
		setPlayerStorageValue(cid,7574,-1)
		setPlayerStorageValue(cid,136,1)
		selfSay('Honour defeats all other forces. That is the second rule. Your poor listening skills and honour have made me lose my {sabre} again. Now, go find it again. Your {rank} has gone down as well. You will get it back after you find my {sabre} again.', cid)
		talkState[talkUser] = 0
---------------------------------------------------------

--Mission 5--

---------------------------------------------------------
	elseif(msgcontains(msg, 'mission') and storage == 9) then
		selfSay('I think you are doing well. This will be your last mission from me. It is very important. I need you to enter the nearby cave and find my {assassin cloak}. You can\'t miss it. It is currently being guarded by a powerful rogue. I haven\'t the time to get it myself.', cid)
		setPlayerStorageValue(cid,135,10)
	elseif(msgcontains(msg, 'mission') and storage == 10) then
		selfSay('Bring me my {assassin cloak}.', cid)
---------------------------------------------------------
	elseif(msgcontains(msg, 'assassin cloak') and storage == 10) then
		selfSay('Have you completed my final mission? Did you bring me my assassin cloak?', cid)
		talkState[talkUser] = 6
---------------------------------------------------------
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6 and getPlayerItemCount(cid, 2664) >= 1) then
		doPlayerRemoveItem(cid, 2664, 1)
		setPlayerStorageValue(cid,135,11)
		setPlayerStorageValue(cid,136,1)
		doPlayerAddExperience(cid,30000)
		doSendAnimatedText(pos, "30000", COLOR_WHITE)
		selfSay('Well, I am simply impressed that you have made it this far. Go on and find Bill the Assassin and you can start your training. Your {rank} is now \'Scout\'. Here is your reward.', cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6 and getPlayerItemCount(cid, 2664) < 1) then
		selfSay('You do not have what I asked for. Go get my {assassin cloak}!', cid)
		talkState[talkUser] = 0
	end
---------------------------------------------------------

--Rank--

---------------------------------------------------------
	if(msgcontains(msg, 'rank') and storage2 > -1) then
		selfSay('Your rank is \'' .. RankName .. '\'.', cid)
	end
---------------------------------------------------------

--Mecha Group--

---------------------------------------------------------
	if(msgcontains(msg, 'mecha group') and storage == 19) then
		selfSay('The Mecha Group is a powerful guild made up of different golems and their pets. Worker and War Golems are strong and technologically advanced beings. They have harnessed the power of Energy Elementals of all kinds and made them their pets. Beware the Golem Leader.', cid)
	end
---------------------------------------------------------

--Trade--

---------------------------------------------------------
	if(msgcontains(msg, 'trade') and storage2 >= 2) then
	local shopModule = ShopModule:new()
		npcHandler:addModule(shopModule)
		shopModule:addBuyableItem({'assassin star'}, 7368, 250, 1, 'assassin star')
		shopModule:addSellableItem({'gear wheel'}, 9690, 500,'gear wheel')
		shopModule:addSellableItem({'gear crystal'}, 10572, 250, 'gear crystal')	
		shopModule:addSellableItem({'war crystal'}, 10571, 1000, 'war crystal')
	end
---------------------------------------------------------

--End--

---------------------------------------------------------
	if(msgcontains(msg, 'mission') and storage >= 20) then
		selfSay('I am all out of missions. Maybe Brian the Assassin has some jobs for you? In the meantime, you could ask me about your {rank} or ask for a {trade}.', cid)
		talkState[talkUser] = 0
	end
	
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And it seems to work so far.

Edit: It seems to work. All my functions are working and the whole quest works, including the little riddle thing. Thanks for your help everyone, rep for everyone who I can rep. I don't rep often, so you might not be able to get rep again cyko xD
Edit2: You must spread some Reputation around before giving it to Cykotitan again.
 
Last edited:
Back
Top