• 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 Script: attempt to compare number with boolean

Misterion

New Member
Joined
Jan 24, 2014
Messages
52
Reaction score
4
Hello!
I'm getting this error when trying to talk with a NPC. Heres the script below:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

-- OTServ event handling functions start
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
-- OTServ event handling functions end


function doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end

--returns how many msgs he have said already
function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end


function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
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, 'mission')) and not getPlayerStorageValue(cid, 555590) >= 10 and not getPlayerStorageValue(cid, 555570) >= 14 and getPlayerStorageValue(cid, 55556) == 14 then
        selfSay('So you wish to {join} us. Right?', cid)
            setPlayerStorageValue(cid, 55556, 15)
            doPlayerSendTextMessage(cid, 22, "Seu registro de missões foi atualizado.")
          
    elseif(msgcontains(msg, 'mission')) and (getPlayerStorageValue(cid, 555590) >= 10 or getPlayerStorageValue(cid, 555570) >= 14) and getPlayerStorageValue(cid, 55556) == 14 then
        selfSay('Sorry, but it seems that youve chosen your destiny already.', cid)
      
    elseif(msgcontains(msg, 'unite')) and getPlayerStorageValue(cid, 55556) == 15 then
        selfSay('Good. So be it.', cid)
            setPlayerStorageValue(cid, 55556, 16)
            setCreatureMaxMana(cid, getCreatureMaxMana(cid) + 230)
            doPlayerAddItem(cid,10220,1)
            doPlayerSendTextMessage(cid, 22, "Seu registro de missões foi atualizado.")
      
    elseif(msgcontains(msg, 'join')) and getPlayerStorageValue(cid, 55556) == 15 then
                            local msgs3={
            "Do you truly wish to {unite}?"
            }
           doNPCTalkALot(msgs3,3000)
          
    elseif(msgcontains(msg, 'missao')) and getPlayerStorageValue(cid, 55556) == 16 then
                            local msgs4={
            "Someday I shall hunt by your side!"
            }
           doNPCTalkALot(msgs4,3000)  

end
    return TRUE   
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I get the error:

Lua:
[Error - Npc interface]
data/npc/scripts/darthaelim.lua:onCreatureSay
Description:
data/npc/scripts/darthaelim.lua:62: attempt to compare number with boolean
stack traceback:
        data/npc/scripts/darthaelim.lua:62: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
        data/npc/scripts/darthaelim.lua:9: in function <data/npc/scripts/darthaelim.lua:9>

What is this?
 
Change line 62 to:
Lua:
if(msgcontains(msg, 'mission')) and not (getPlayerStorageValue(cid, 555590) >= 10) and not (getPlayerStorageValue(cid, 555570) >= 14) and getPlayerStorageValue(cid, 55556) == 14 then
 
Back
Top