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

Lua Npc system problem

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
I usually use the "normal" npc system, with if msgcontains() etc.
But I wanted to get used to the other one, as it seems easier sometimes.

And here is the problem. I don't know, if I'm using it right but what I think it should do is:
- respond on the word "rekruten" at any time.
- only respond on "ja/yes/nein/no" if "rekruten" was said first.
- after said once, you have to ask for "rekruten" again first

What it does:
When you say "rekruten" once, she always replies on the sub-words, no matter how often you say them.

My question:
How can I reset the talkState in this system? I thought about reseting the npc, but wouldn't that reset it for all players talking to the npc at that time?

Version:
TFS 0.2.15

script:
Lua:
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)    end
function onThink()                npcHandler:onThink()                end

function gnometteRecruits(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if getPlayerStorageValue(cid, 51234) == 1 then
        npcHandler:say('Exzellent! Ich bin so aufgeregt, wegen all dieser mutigen Leute, die beitreten wollen. So, du kannst nun anfangen {Missionen} für unser Rekruten Programm die Treppe runter zu erledigen, ich werde dir den Mittelsmann auf der Karte markieren. Aber erstmal solltest du vielleicht wissen, {worum} es hier überhaupt geht!', cid)
        setPlayerStorageValue(cid, 51234, 2)
        setPlayerStorageValue(cid, 51240, 0)
        doAddMapMark(cid, { x = 2393, y = 2049, z = 10 }, MAPMARK_EXCLAMATION, "Commander Stone (Missions)")  
    elseif getPlayerStorageValue(cid, 51234) == 2 then
        npcHandler:say('Du bist doch bereits Mitglied!', cid)
    else
        npcHandler:say('Du solltest erst mit Xelvar reden. Wie bist Du überhaupt hier hin gekommen?', cid)
    end
    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'rekruten'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'So, du bist also hier um ein Rekrut zu werden?'})
node1:addChildKeyword({'ja'}, gnometteRecruits, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'yes'}, gnometteRecruits, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'nein'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Okay, Dann komm wieder, wenn du deine Meinung geändert hast.', reset = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Okay, Dann komm wieder, wenn du deine Meinung geändert hast.', reset = true})
npcHandler:addModule(FocusModule:new())
 
Back
Top