sleepy chronos
.::MaPpEr::.
i make this script looking on some examples but i have a bug, plis someone can help me...
this is the scrip:
works fine but give me an error on console
[17/06/2009 14:46:28] Lua Script Error: [Npc interface]
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.luanCreatureSay
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:20: attempt to index global 'talkState' (a nil value)
[17/06/2009 14:46:28] stack traceback:
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:20: in function 'callback'
[17/06/2009 14:46:28] data/npc/lib/npcsystem/npchandler.lua:384: in function 'onCreatureSay'
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:9: in function <data/npc/scripts/quest/knightquestvoc2.lua:9>
help plis with this simple problem
this is the scrip:
Code:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local storage = 7001
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if (msgcontains(msg, 'mission') or msgcontains(msg, 'quest')) then
if(getPlayerStorageValue(cid, storage) < 1) then
npcHandler:say("bla bla bla", cid)
talkState[talkUser] = 1
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("bla {bla} bla", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("Sorry, you have already done the quest.", cid)
end
elseif (msgcontains(msg, 'item') and talkState[talkUser] == 1) then
if getPlayerItemCount(cid,7433) >= 1 then
if doPlayerRemoveItem(cid,7433,1) == 1 then
npcHandler:say("Oh... you gonna be a brave knight take this scroll and go to knight training center.",cid)
doPlayerAddItem(cid,7529,1)
setPlayerStorageValue(cid, storage, 2)
end
else
npcHandler:say("I need a item for give you a knights scroll document. Come back when you have them.", cid)
talk_state = 0
end
elseif msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
npcHandler:say("Ok.. Good bye then!!", cid)
talk_state = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
[17/06/2009 14:46:28] Lua Script Error: [Npc interface]
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.luanCreatureSay
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:20: attempt to index global 'talkState' (a nil value)
[17/06/2009 14:46:28] stack traceback:
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:20: in function 'callback'
[17/06/2009 14:46:28] data/npc/lib/npcsystem/npchandler.lua:384: in function 'onCreatureSay'
[17/06/2009 14:46:28] data/npc/scripts/quest/knightquestvoc2.lua:9: in function <data/npc/scripts/quest/knightquestvoc2.lua:9>
help plis with this simple problem