• 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 no answer

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
931
Solutions
7
Reaction score
127
Location
Brazil
YouTube
caruniawikibr
After speaking zax, the NPC responds correctly, but I can't access the rest of the script. tfs 1.5


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

local function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if not npcHandler:isFocused(cid) then
        if msgcontains(msg, 'Zax') then
            npcHandler:say('Kul\'nak fethrak sha, '..player:getName()..'? ', cid)
            npcHandler:focus(cid)
            return true
        end
    end
end

function helmet(cid, message, keywords, parameters, node)
    local player = Player(cid)
    if getPlayerItemCount(cid, 5704) >= 2 then
        if doPlayerRemoveItem(cid, 5704, 2) then
            npcHandler:say('MUAHAHAHAHA! Xoroth, fethrak!', cid)
            doPlayerAddItem(cid, 2471, 1)
            Npc():getPosition():sendMagicEffect(CONST_ME_YELLOW_RINGS)
            player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONAREA)
        end
    else
        npcHandler:say('Krathok xoroth, fethrak! Uxil zonaghtis!', cid)
    end

local node1 = keywordHandler:addKeyword({'gor\'thakul'}, StdModule.say, {npcHandler = npcHandler, text = 'Uxor nokthagor krunoth kulgathrax xoroth, thrax gor\'thakul nuk urgor.'})
node1:addChildKeyword({'thrax'}, helmet, {npcHandler = npcHandler, reset = true})
node1:addChildKeyword({'nul'}, StdModule.say, {npcHandler = npcHandler, text = 'Kulgathis xoroth!', reset = true})


npcHandler:setMessage(MESSAGE_WALKAWAY, 'Krathok xoroth, fethrak!!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Krathok xoroth, fethrak!!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Solution
I made a custom script here, it's much better and simpler. Easy to edit, tested, and works fine, okay!

Lua:
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 function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if not npcHandler:isFocused(cid) then
        if msgcontains(msg, 'Zax') then
            npcHandler:say('Kul\'nak fethrak sha...
Explain more clearly for better understanding so that I can correct the script. Are you saying that when talking to the NPC "Zax," the NPC removes 2 items of ID 5704 and adds item 2471 to the player's backpack? Is that correct? It seems like the script is somewhat incomplete, as some details are missing. Please explain further!
 
Explain more clearly for better understanding so that I can correct the script. Are you saying that when talking to the NPC "Zax," the NPC removes 2 items of ID 5704 and adds item 2471 to the player's backpack? Is that correct? It seems like the script is somewhat incomplete, as some details are missing. Please explain further!
Hi = Zax
gor\'thakul = golden helmet
thrax = Yes
Post automatically merged:

So I got him to talk to me, Gor'thakul, but he still needs to accept Thrax to exchange the item for golden

Lua:
local function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if not npcHandler:isFocused(cid) then
        if msgcontains(msg, 'Zax') then
            npcHandler:say('Kul\'nak fethrak sha, '..player:getName()..'? ', cid)
           npcHandler:addFocus(cid)
        end
        return false
end
end
Post automatically merged:

When i say "thrax" = Yes npc no answer me... i think need focus to answer me


Lua:
local function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if not npcHandler:isFocused(cid) then
        if msgcontains(msg, 'Zax') then
            npcHandler:say('Kul\'nak fethrak sha, '..player:getName()..'? ', cid)
           npcHandler:addFocus(cid)
        end
        return false
end
end
    
    
function helmet(cid, message, keywords, parameters, node)
    local player = Player(cid)
     if not npcHandler:isFocused(cid) then
    if getPlayerItemCount(cid, 5704) >= 2 then
        if doPlayerRemoveItem(cid, 5704, 2) then
            npcHandler:say('MUAHAHAHAHA! Xoroth, fethrak!', cid)
            doPlayerAddItem(cid, 2471, 1)
            Npc():getPosition():sendMagicEffect(CONST_ME_YELLOW_RINGS)
            player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONAREA)
        end
    else
        npcHandler:say('Krathok xoroth, fethrak! Uxil zonaghtis!', cid)
    end
end
end

local node1 = keywordHandler:addKeyword({'gor\'thakul'}, StdModule.say, {npcHandler = npcHandler, text = 'Uxor nokthagor krunoth kulgathrax xoroth, thrax gor\'thakul nuk urgor.'})
node1:addChildKeyword({'thrax'}, helmet, {npcHandler = npcHandler, reset = true})
node1:addChildKeyword({'nul'}, StdModule.say, {npcHandler = npcHandler, text = 'Kulgathis xoroth!', reset = true})
 
Last edited:
I made a custom script here, it's much better and simpler. Easy to edit, tested, and works fine, okay!

Lua:
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 function creatureSayCallback(cid, type, msg)
    local player = Player(cid)
    if not npcHandler:isFocused(cid) then
        if msgcontains(msg, 'Zax') then
            npcHandler:say('Kul\'nak fethrak sha, '..player:getName()..'? ', cid)
            npcHandler:addFocus(cid)
            return true
        end
    else
        if msgcontains(msg, 'gor\'thakul') or msgcontains(msg, 'Gor') then
            npcHandler:say('Uxor nokthagor krunoth kulgathrax xoroth, thrax gor\'thakul nuk urgor,', cid)
            talkState[player:getId()] = 3
            return true
        elseif msgcontains(msg, 'thrax') and talkState[player:getId()] == 3 then
            if player:getItemCount(5704) >= 2 then
                if player:removeItem(5704, 2) then
                    npcHandler:say('MUAHAHAHAHA! Xoroth, fethrak!', cid)
                    player:addItem(2471, 1)
                    player:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONAREA)
                    local npc = Npc()
                    if npc then
                        npc:getPosition():sendMagicEffect(CONST_ME_YELLOW_RINGS)
                    end
                end
            else
                npcHandler:say('Krathok xoroth, fethrak! Uxil zonaghtis!', cid)
            end
            talkState[player:getId()] = 0
            return true
        end
    end
    return false
end

npcHandler:setMessage(MESSAGE_WALKAWAY, 'Krathok xoroth, fethrak!!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Krathok xoroth, fethrak!!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 
Solution
Back
Top