Please help me.
Log:
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
hmage = 22385
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function creatureSayCallback(cid, type, msg)
if (not npcHandler:isFocused(cid)) then
return false
end
if msgcontains (msg, "mage") and getPlayerSex(cid) == 1 then
npcHandler:say("I can give you {male Hat Addon}", cid)
Topic[talkUser] = 0
elseif msgcontains (msg, "male hat addon") and getPlayerSex(cid) == 1 and getPlayerStorageValue(cid, hmage) == -1 then
npcHandler:say("You need 1 x ferumbras' hat to unlock Hat Addon.", cid)
Topic[talkUser] = 1
elseif msgcontains(msg, "yes") and getPlayerStorageValue(cid, hmage) < 1 and Topic[talkUser] == 1 and getPlayerItemCount(cid,5903) >= 1 then
npcHandler:say("Ah, right! The mage rod! Here you go.", cid)
Topic[talkUser] = 0
doPlayerRemoveItem(cid,5903,1)
doSendMagicEffect(getCreaturePosition(cid), 13)
setPlayerStorageValue(cid,hmage,1)
if getPlayerSex(cid) == 1 then
doPlayerAddOutfit(cid, 129, 1)
elseif getPlayerSex(cid) == 0 then
doPlayerAddOutfit(cid, 137, 2)
else
npcHandler:say("You do not have required materials", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Log:
Code:
[10:28:01.068] [Error - NpcScript Interface]
[10:28:01.068] data/npc/scripts/Thomas.lua:onCreatureSay
[10:28:01.068] Description:
[10:28:01.068] data/npc/scripts/Thomas.lua:27: attempt to index global 'Topic' (a nil value)
[10:28:01.068] stack traceback:
[10:28:01.068] data/npc/scripts/Thomas.lua:27: in function 'callback'
[10:28:01.068] data/npc/lib/npcsystem/npchandler.lua:385: in function 'onCreatureSay'
[10:28:01.068] data/npc/scripts/Thomas.lua:8: in function <data/npc/scripts/Thomas.lua:8>
Last edited: