• 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 Chrak BUG: he's not responding any message

Eric Figueiredo

New Member
Joined
Dec 9, 2015
Messages
10
Reaction score
0
NPC Chrak BUG: he's not responding any message

Chrak.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Chrak" script="Chrak.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="115" />
</npc>

Chrak.lua:

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msgcontains(msg, "battle") then
        npcHandler:say("battle")
        if player:getStorageValue(Storage.TheNewFrontier.Questline) == 24 then
            npcHandler:say({
                "Zo you want to enter ze arena, you know ze rulez and zat zere will be no ozer option zan deaz or victory? ...",
                "My mazter wantz to zurprize hiz opponentz by an unexpected move. He will uze warriorz from ze outzide, zomeone zat no one can azzezz. ...",
                "One of ziz warriorz could be you. Or you could ztay here and rot in ze dungeon. Are you interezted in ziz deal?"
            }, cid)
            npcHandler.topic[cid] = 1
        end
    elseif msgcontains(msg, "mission") then
        npcHandler:say("battle")
        if player:getStorageValue(Storage.TheNewFrontier.Questline) == 26 then
            npcHandler:say({
                "You have done ze impozzible and beaten ze champion. Your mazter will be pleazed. Hereby I cleanze ze poizon from your body. You are now allowed to leave. ...",
                "For now ze mazter will zee zat you and your alliez are zpared of ze wraz of ze dragon emperor az you are unimportant for hiz goalz. ...",
                "You may crawl back to your alliez and warn zem of ze gloriouz might of ze dragon emperor and hiz minionz."
            }, cid)
            player:setStorageValue(Storage.TheNewFrontier.Questline, 27)
            player:setStorageValue(Storage.TheNewFrontier.Mission09, 3) --Questlog, The New Frontier Quest "Mission 09: Mortal Combat"
            npcHandler.topic[cid] = 0
        end
    elseif msgcontains(msg, "yes") then
        npcHandler:say("battle")
        if npcHandler.topic[cid] == 1 then
            npcHandler:say("Asss you wishzz.", cid)
            player:setStorageValue(Storage.TheNewFrontier.Questline, 25)
            player:setStorageValue(Storage.TheNewFrontier.Mission08, 2) --Questlog, The New Frontier Quest "Mission 08: An Offer You Can't Refuse"
            player:setStorageValue(Storage.TheNewFrontier.Mission09, 1) --Questlog, The New Frontier Quest "Mission 09: Mortal Combat"
            npcHandler.topic[cid] = 0
        end
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I get this error on my console:

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Chrak.lua:onCreatureSay
data/npc/lib/npcsystem/npchandler.lua:653: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/npc/lib/npcsystem/npchandler.lua:653: in function 'say'
        data/npc/scripts/Chrak.lua:21: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:430: in function 'onCreatureSay'
        data/npc/scripts/Chrak.lua:8: in function <data/npc/scripts/Chrak.lua:8>

can anybody help me? Thanks :)

Here is my npchandler.lua, if you want:

http://pastebin.com/VmM45vfa
 
Last edited by a moderator:
Back
Top