Grehy
Killroy
This is the script;
If I say mission in default chat without saying hi, it will start the dialog. How can I fix this so it only responds to NPC channel messages besides hi?
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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
--[[
REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
]]--
local storage = 9391
if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
if(getPlayerStorageValue(cid, storage) < 1) then
npcHandler:say("Greetings. I need you to bring me a very old artifact. I'm sure Killroy will give you one.", cid)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Did you bring me what I requested?", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("You have already brought me what I asked for.", cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 9971, 1) == TRUE) then
npcHandler:say("Thank you very much. Here is your reward.", cid)
doPlayerAddItem(cid, 2522, 1)
setPlayerStorageValue(cid, storage, 2)
talkState[talkUser] = 0
else
npcHandler:say("That is not the item I requested from you.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Ok.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
If I say mission in default chat without saying hi, it will start the dialog. How can I fix this so it only responds to NPC channel messages besides hi?