Im having trouble with my quest npcs. Only one of them responds, wich is the last one I added or the first one I speak to.
So there must be something I missed. Can anyone help me? rep+
So there must be something I missed. Can anyone help me? rep+
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {0}
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 say(param)
npcHandler:say(param.text,param.cid)
end
function delayedSay(text, delay, cid)
if(not npcHandler:isFocused(cid)) then
return FALSE
else
local param = {cid = cid, text = text}
local delay = delay or 0
local cid = cid or 0
local nid = getNpcCid()
addEvent(say, delay, param)
end
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 quest = 76669
local reward = 70000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'mission') then
delayedSay("Great, a valentuer. I need you to slay 200 dragons for me. And then, we might be able to take out those dragon lords. Well, can you slay 200 dragons for me?", 100, cid)
talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
delayedSay("Please come back for a reward.", 10, cid)
elseif(getPlayerStorageValue(cid, quest) == 3) then --pirates
delayedSay("200 dragons, allready? You're a true dragon slayer. Here's your reward as I promised.", 100, cid)
doPlayerAddItem(cid,2160,30)
doPlayerAddExp(cid, 1000000)
if getPlayerSex(cid) == 0 then
doPlayerAddOutfit(cid, 142, 2)
else
doPlayerAddOutfit(cid, 134, 2)
doPlayerSendTextMessage(cid,22,"You have been rewarded with the warrior addon!")
setPlayerStorageValue(cid, quest, 4)
end
elseif(getPlayerStorageValue(cid, quest) == 4) then
delayedSay("You have done enough for me I will soon plan our attack!", 100, cid)
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
delayedSay("Great! I'll reward you greatly {ok}?.", 100, cid)
talkState[talkUser]= 3
elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
delayedSay("Okay, Hurry up!", 100, cid)
setPlayerStorageValue(cid, quest, 2)
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {0}
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 say(param)
npcHandler:say(param.text,param.cid)
end
function delayedSay(text, delay, cid)
if(not npcHandler:isFocused(cid)) then
return FALSE
else
local param = {cid = cid, text = text}
local delay = delay or 0
local cid = cid or 0
local nid = getNpcCid()
addEvent(say, delay, param)
end
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 quest = 66669
local reward = 80000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'mission') then
delayedSay("Could you possibly help me clean up down here and kill 30 rotworms?", 100, cid)
talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
delayedSay("Please come back for a reward.", 10, cid)
elseif(getPlayerStorageValue(cid, quest) == 3) then --pirates
delayedSay("Great, here you have a reward.", 100, cid)
doPlayerAddItem(cid,2195,1)
doPlayerAddItem(cid,2160,2)
doPlayerAddExp(cid, 250000)
setPlayerStorageValue(cid, quest, 4)
elseif(getPlayerStorageValue(cid, quest) == 4) then
delayedSay(" I dont need any help at the moment.", 100, cid)
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
delayedSay("Ok, use this to heal {ok}?.", 100, cid)
talkState[talkUser]= 3
elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
doPlayerAddItem(cid,2273,25)
delayedSay("Okay, Hurry up!", 100, cid)
setPlayerStorageValue(cid, quest, 2)
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())