poopsiedoodle
Gibe moni plos
So, I have a script for a task npc that works just like the ones from the Killing in the Name of quest. Here's the script:
The npc that's supposed to respond to the keywords is an npc named Aquilas. But, instead of aquilas responding, random npcs that are several tiles away/floors above or under Aquilas are responding, and it's not even the same npc each time. For example, I said hi, task, and instead of aquilas responding to the word "task", Rashid responded, and another time, it was varkhal instead of aquilas. How do I make it so that ONLY Aquilas will respond?
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 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 = 86669
local reward = 90000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'task') then
delayedSay("The cavaliers on the Forsaken Island are becoming more and more of a threat to us each day. I wish someone could get rid of them once and for all, but unfortunately they just keep coming! ...", 100, cid)
delayedSay("Only a dead cavalier is a good cavalier. I think killing a large number of them would definitely help us to make Sabrehaven a safer place. ...", 12000, cid)
delayedSay("It doesn't matter how long it takes, but... would you be willing to kill 100 cavaliers for us?", 23000, cid)
talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
delayedSay("Come back here when you finish your mission.", 10, cid)
elseif(getPlayerStorageValue(cid, quest) == 3) then --cavaliers
delayedSay("Hey, great. You've done well! As a small reward I give you some coins from our treasure box. Also, let me tell you an interesting piece of information. ...", 100, cid)
delayedSay("One our of spies told us about a secret hideout somewhere on the Forsaken Island. Supposedly, the cavalier leader can be found there sometimes. If you dare go there, you might be able to face him in one on one combat. ...", 12000, cid)
delayedSay("Beware though - prepare yourself well and only flee if you must. This might be your only chance to get into there, so be careful and don't die!", 23000, cid)
doPlayerAddExp(cid, 300000)
setPlayerStorageValue(cid, quest, 4)
setPlayerStorageValue(cid, 696969, 1) ---questdoor storage---
elseif(getPlayerStorageValue(cid, quest) == 4) or (getPlayerStorageValue(cid, 696969) == 2) then
delayedSay("Hm... you already helped me a lot, so I don't really need you right now, but thanks anyway!", 100, cid)
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
delayedSay("Perfect. I know it sounds like a lot, but really, take your time. You won't do it for nothing, I promise, {ok}?.", 100, cid)
talkState[talkUser]= 3
elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
delayedSay("Okay, now go and kill cavaliers. And after that come back and report to me!", 100, cid)
setPlayerStorageValue(cid, quest, 2)
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
The npc that's supposed to respond to the keywords is an npc named Aquilas. But, instead of aquilas responding, random npcs that are several tiles away/floors above or under Aquilas are responding, and it's not even the same npc each time. For example, I said hi, task, and instead of aquilas responding to the word "task", Rashid responded, and another time, it was varkhal instead of aquilas. How do I make it so that ONLY Aquilas will respond?