• 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 Problem with NPC

lhc00

New Member
Joined
Mar 23, 2010
Messages
23
Reaction score
0
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:
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 ^_^
 
Back
Top