I have a problem with a NPC, when i type on tibia the number that the NPC asks, it gives this error: "can't compare nil with number", or something like that, i don't know where is the error.
Here is the script:
Thx by the help ^_^
Here is the script:
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'ticket') then
selfSay('you really want to buy it by 100 GP?', cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if getPlayerMoney(cid) > 100 then
selfSay('So, tell me the numbers ')
talkState[talkUser] = 2
else
selfSay('Sorry, you don\'t have enough money.')
end
end
elseif talkState[talkUser] == 2 then
if tonumber(msg) > 0 then
doItemSetAttribute(doPlayerAddItem(cid, 6092, 1), 'aid', tonumber(msgcontains(msg, '')))
selfSay('Thank You for contributing!')
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thx by the help ^_^