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

npcHandler:releaseFocus(cid) problem

Slime

Active Member
Joined
Jan 25, 2014
Messages
115
Reaction score
32
For some reason it doesn't work, you can spam yes and npc will spam his answers.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)
if(msg == "yes") then
selfSay("That which you see rising up on that island is the Tower of Najima.", cid)
npcHandler:releaseFocus(cid)
else
if(msg == "no") then
selfSay("You should see it as soon as you go outside.", cid)
npcHandler:releaseFocus(cid)
end
end
  
end
function onThink()                npcHandler:onThink()                    end


npcHandler:addModule(FocusModule:new())
 
Last edited:
@Elite Brasil
Nope, but it just isn't how my npcs are supposed to work. By spamming I meant:
Code:
16:00 Old Man: Hast thou seen the island floating to the west of this castle?
16:00 GM Slime [1]: yes
16:00 Old Man: That which you see rising up on that island is the Tower of Najima.
16:00 GM Slime [1]: yes
16:00 Old Man: That which you see rising up on that island is the Tower of Najima.
16:00 GM Slime [1]: yes
16:00 Old Man: That which you see rising up on that island is the Tower of Najima.
16:00 GM Slime [1]: yes
16:00 Old Man: That which you see rising up on that island is the Tower of Najima.
I want him to say this line and just loose focus on the player, so the player will have to say "hi" again to talk to the npc.
 
Define some sort of topic?

Example:

Code:
local t = nil
    if msgcontains(msg, "mission") then
        npcHandler:say("xD", cid)
        t = 1
    elseif t == 1 then
        if msgcontains(msg, "yes") then
            npcHandler:say("xDDDD", cid)
        else
            npcHandler:say("NO?", cid)
        end
        t = 0
    end
 
@Hartass I could do this, but that's not really how I want my npcs to work. I want them to say what they have to say without unnecessary greeting message and just let you say yes or no (or something else), then loose focus.
 
I don't have a fix for you, but a couple of comments/questions:

1. The NPC system is set up to use callbacks to do the kind of thing you're looking for. See the comments in the original script(s)
2. You're running this outside the onXxx() callbacks: npcHandler:addModule(FocusModule:new())
Is that deliberate? If so, what do you expect it to do?
3. You're running this at the start of your script: npcHandler.onCreatureSay(cid, type, msg)
Is that deliberate? If so, what do you expect it to do?
 
Last edited:
I'm just doing things trial and error aka copy and paste method, since I've never scripted an NPC before.
 
@EvulMastah
I don't understand, could anyone post a sample script that I could learn from?
Also is there a way to set separate talk radius for each npc?
 
Back
Top