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

Solved NPC wont respond except to hi

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is the npc

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

-- 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
function creatureSayCallback(cid, type, msg) 
function onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		end
-- OTServ event handling functions end

if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


--------------------------------
------- NPC MISION  2.5 --------
---by Acubens, great scripter---
-----modified by Ziggy46802-----
       -- Otland.net --
--------------------------------
 
local first = {
-- Place true if you want experience to be part of the quest reward, false if only an item. Place true if you want both
useExpReward = true,
-- The experience, if above is set to true, that the player will receive as a reward for the quest
experience = 1500,
-- Item ID of the "quest item", or the item that the npc takes from you for you to complete the quest
item = 8710,
-- Item ID of the second quest item, just leave alone if you only want one item
itemtwo = 2160,
-- The quanity, or how many, of the item needed to complete the quest
item_count = 10,
-- The quantity, or how many, of the second quest item needed to complete the quest
itemtwo_count = 1,  
-- Item ID of the quest reward if the first option is set to false, but an item can be used with true for exp as reward as well 
reward = 2480,
-- Item ID of the quest reward if the first option is set to false, this is the second item that can be "not used"
rewardtwo = 2160,
-- The quantity, or how many, of the quest reward that the player will receive for the second item upon completion of the quest, can be "not used"
rewardtwo_count = 100,
-- The quanity, or how many, of the quest reward that the player will receive upon completion of the quest
reward_count = 1, 
-- The storage value that the quest will use (advised would be between 1000 and 10000)
storage = 1001, 
--this is the value of the storage value above that is set when the quest is completed, most people use -1 (non existant) for starting the quest and 1 for ending, but I use 2
last = 2,
-- The name of the quest which will pop up upon completion of the quest as "You have completed the quest 'quest name'"
questname = "Rat Extermination"
}
 
local npc_message ={
 
--the number at the front just shows you what number message it is so when you see "npc_message[4]" in the script you know which line of code it refers to

-- 1Message asking if you have the required items, should be something like "Do you have the 10 antennas?" no highlighting is needed
"Did you kill enough of them to collect 10 of their antennas?",
-- 2if you dont have items - message
"You dont have any items to this mission.", 
-- 3thanks - message
"Thank You for Help me, {take it}.",
-- 4Message that the npc says if you have already done the quest
"Well the rats aren't as bad anymore, thanks to you that is.",
-- 5First message for the quest, should be like "Please go collect 10 chicken feathers for me" and do {} around a word like I did, antennas
"We have a real bad rat problem here in Granitewood. If you kill some of them and collect 10 of their {antennas} then I might give up one of my products for free just for you.",
-- 6Message given upon completion of the quest, the npc does not say it, it is another type of text
"Congratulations, you have finished the quest "..first.questname..""
 
}
 
 
if(msgcontains(msg, 'rat')) then --the first keyword, should be a word that the xml file for the npc says to you upon greeting
doCreatureSay(cid, npc_message[5], TALKTYPE_ORANGE_1)
end
return true
end

npcHandler:addModule(FocusModule:new())

He responds to "hi" but then when I say rat to him he just stands there, I don't understand why. I'm using the latest TFS 9.6
 
Last edited by a moderator:
well all my other npc's work, but all they do is do shop modules in the .lua file, they dont selfsay or docreaturesay anything. And I'm using the latest lib folder from TFS 9.6, so I don't think theres a problem there, I think theres a problem in the talkstate system. Is it out of date?
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
-- 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
 
function onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid) end
-- OTServ event handling functions 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
	 
	 
	--------------------------------
	------- NPC MISION  2.5 --------
	---by Acubens, great scripter---
	-----modified by Ziggy46802-----
		   -- Otland.net --
	--------------------------------
 
	local first = {
	-- Place true if you want experience to be part of the quest reward, false if only an item. Place true if you want both
	useExpReward = true,
	-- The experience, if above is set to true, that the player will receive as a reward for the quest
	experience = 1500,
	-- Item ID of the "quest item", or the item that the npc takes from you for you to complete the quest
	item = 8710,
	-- Item ID of the second quest item, just leave alone if you only want one item
	itemtwo = 2160,
	-- The quanity, or how many, of the item needed to complete the quest
	item_count = 10,
	-- The quantity, or how many, of the second quest item needed to complete the quest
	itemtwo_count = 1,  
	-- Item ID of the quest reward if the first option is set to false, but an item can be used with true for exp as reward as well 
	reward = 2480,
	-- Item ID of the quest reward if the first option is set to false, this is the second item that can be "not used"
	rewardtwo = 2160,
	-- The quantity, or how many, of the quest reward that the player will receive for the second item upon completion of the quest, can be "not used"
	rewardtwo_count = 100,
	-- The quanity, or how many, of the quest reward that the player will receive upon completion of the quest
	reward_count = 1, 
	-- The storage value that the quest will use (advised would be between 1000 and 10000)
	storage = 1001, 
	--this is the value of the storage value above that is set when the quest is completed, most people use -1 (non existant) for starting the quest and 1 for ending, but I use 2
	last = 2,
	-- The name of the quest which will pop up upon completion of the quest as "You have completed the quest 'quest name'"
	questname = "Rat Extermination"
	}
 
	local npc_message ={
	 
	--the number at the front just shows you what number message it is so when you see "npc_message[4]" in the script you know which line of code it refers to
	 
	-- 1Message asking if you have the required items, should be something like "Do you have the 10 antennas?" no highlighting is needed
	"Did you kill enough of them to collect 10 of their antennas?",
	-- 2if you dont have items - message
	"You dont have any items to this mission.", 
	-- 3thanks - message
	"Thank You for Help me, {take it}.",
	-- 4Message that the npc says if you have already done the quest
	"Well the rats aren't as bad anymore, thanks to you that is.",
	-- 5First message for the quest, should be like "Please go collect 10 chicken feathers for me" and do {} around a word like I did, antennas
	"We have a real bad rat problem here in Granitewood. If you kill some of them and collect 10 of their {antennas} then I might give up one of my products for free just for you.",
	-- 6Message given upon completion of the quest, the npc does not say it, it is another type of text
	"Congratulations, you have finished the quest "..first.questname..""
	 
	}
 
 
	if(msgcontains(msg, 'rat')) then --the first keyword, should be a word that the xml file for the npc says to you upon greeting
		doCreatureSay(cid, npc_message[5], TALKTYPE_ORANGE_1)
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top