rlx
Well-Known Member
- Joined
- Feb 25, 2019
- Messages
- 170
- Solutions
- 1
- Reaction score
- 81
Hello,
I'm trying to set a NPC talk with addEvent functions containing selfSay. Unfortunately, it causes other random NPCs on same floor from whole map to say those lines instead of the NPC I'm talking with. Maybe the problem is with talkstates/cid inside addEvent functions?
How it looks when addEvent times are shortened:
The code:
I'm trying to set a NPC talk with addEvent functions containing selfSay. Unfortunately, it causes other random NPCs on same floor from whole map to say those lines instead of the NPC I'm talking with. Maybe the problem is with talkstates/cid inside addEvent functions?
How it looks when addEvent times are shortened:
The code:
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 node1 = keywordHandler:addKeyword({'promote'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
local node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
keywordHandler:addKeyword({'premium'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can buy premium by command !buypremium - cost 10k for 2 days.'})
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'quest') or msgcontains(msg, 'task') or msgcontains(msg, 'mission') or msgcontains(msg, 'bone key')) then
if (getPlayerStorageValue(cid,5019)) == 2 then
selfSay('Ah, I\'m glad you asked. I have hard about your actions in the underground. That inspired me to look farther in my stuff connected with [undeads]..', cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid,5019) < 2 then
selfSay('I think that one day you will become a very strong adventurer. We need people like you, to get rid of endless evil forces which we all are afraid of.', cid)
elseif getPlayerStorageValue(cid,5019) > 2 then
selfSay('Good luck with sending undeads to place, where they truly belong.', cid)
end
elseif (msgcontains(msg, 'undead')) then
selfSay('text1 ', cid)
addEvent(function() selfSay('text2', cid) end, 3000)
addEvent(function() selfSay('text3', cid) end, 6000)
addEvent(function() selfSay('text4', cid) end, 9000)
addEvent(function() selfSay('text5', cid) end, 12000)
addEvent(function() doSetItemActionId(doPlayerAddItem(cid, 2092),301) end, 13000)
addEvent(function() selfSay('text6', cid) end, 15000)
end
talkState[talkUser] = 0
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())