• 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!

Error no log otclient

Nubaza

LUA Scripter
Joined
Jun 5, 2011
Messages
330
Solutions
1
Reaction score
21
Location
New Zeland
Hello otland,
i have some error in the log of my Otclient, please help me to fix it :c

This is the error:
Code:
    [C]: ?
    /game_extrapokebar/barpoke.lua:41: in function 'callback'
    /gamelib/protocolgame.lua:17: in function </gamelib/protocolgame.lua:14>
ERROR: protected lua call failed: LUA ERROR:
/game_extrapokebar/barpoke.lua:96: attempt to index a nil value
stack traceback:
    [C]: ?
    /game_extrapokebar/barpoke.lua:96: in function 'callback'
    /gamelib/protocolgame.lua:17: in function </gamelib/protocolgame.lua:14>
ERROR: protected lua call failed: LUA ERROR:
/game_extrapokebar/barpoke.lua:96: attempt to index a nil value
stack traceback:
    [C]: ?

game_extrapokebar/barpoke.lua
Code:
local OPCODE_POKEMONBAR = 150
local OPCODE_PERCENTLIFE = 151

local barPoke = nil
local icons = {}
-- Public functions
function init()
   barPoke = g_ui.displayUI('barpoke', modules.game_interface.getRootPanel())
   barPoke:setVisible(false)
   barPoke:move(250,100)

  ProtocolGame.registerExtendedOpcode(OPCODE_POKEMONBAR, atualizarBar)
  ProtocolGame.registerExtendedOpcode(OPCODE_PERCENTLIFE, onPokes)
   connect(g_game, { onGameEnd = hide } )
   connect(g_game, { onGameStart = show } )
   createIcons()
end
function terminate()
   disconnect(g_game, { onGameEnd = hide })
  ProtocolGame.unregisterExtendedOpcode(OPCODE_POKEMONBAR)
  ProtocolGame.unregisterExtendedOpcode(OPCODE_PERCENTLIFE)

   barPoke:destroy()
end
function atualizarBar(self, opcode, buffer)
if (buffer == 'BarClosed') then hide() return true end
if buffer == nil then return true end
if string.find(buffer, 'Pokebar') then
local talk = "/pokamon"
show()
cleanAllPokes()
local t = string.explode(buffer, "/")
for i= 2, #t do
x= i-1
local poke = t[i]
local zafrada = i-1
local progress = icons['Icon'..x].progress
changeIconPoke(x, poke)
progress.onClick = function() g_game.talk(talk.." "..poke..""..zafrada.."")
end
end
end
end
function changeIconPoke(i, poke)
if not g_game.isOnline() then return end
   local icon = icons['Icon'..i].icon
local image = "/data/pokes/"..poke..".png"
   icon:setImageSource(image)
end
function createIcons()
   local d = 50
   local image = "/data/pokes/portait.png"
   for i = 1, 6 do
      local icon = g_ui.createWidget('IconPoke', barPoke)
      local icon1 = g_ui.createWidget('HealthLabel', icon)
      local progress = g_ui.createWidget('Poke', barPoke)
      icon:setId('Icon'..i)
      progress:setId('Progress'..i)
      icons['Icon'..i] = {icon = icon, progress = progress, dist = (i == 20 and -5 or i == 2 and 50 or d + ((i-2)*38)), event = nil}
      icon:setMarginLeft(icons['Icon'..i].dist)
      icon:setImageSource(image)
      icon:setMarginTop(10)
      icon1:setMarginTop(31)
      icon1:setMarginLeft(-3)
      icon1:setId('HealthLabel'..i)
      progress:fill(icon:getId())
   end
end
function cleanAllPokes()
   local image = "/data/pokes/portait.png"
   for i = 1, 6 do
       local icon = icons['Icon'..i].icon
  local icon1 = barPoke:recursiveGetChildById('HealthLabel'..i)
       icon.onClick = function() end
      icon:setImageSource(image)
     local progress = icons['Icon'..i].progress
     progress.onClick = function() g_game.talk("") end
     icon1:hide()
end            
end
function onPokes(self, opcode, buffer)
if buffer == nil then return true end
if string.find(buffer, '#life#') then
    local t = buffer:explode(',')
    table.remove(t, 1)
    for i = 1, #t do
                barPoke:recursiveGetChildById('HealthLabel'..i):show()

        barPoke:recursiveGetChildById('HealthLabel'..i):setText(t[i]..'%')
           if t[i] == "0" then
            barPoke:recursiveGetChildById('HealthLabel'..i):setText("KO")
            end

                local PokemonBars = barPoke:recursiveGetChildById('HealthLabel'..i)
                if t[i] == "100" then
                   PokemonBars:setColor('#21AB28')
                elseif t[i] >= "75" then
                       PokemonBars:setColor('#1FDB28')
            elseif t[i] >= "50" then
                        PokemonBars:setColor('#F0A00C')
            elseif t[i] >= "25" then
                        PokemonBars:setColor('#EDF00C')
            elseif t[i] >= "10" then
                        PokemonBars:setColor('#F00F0B')
            elseif t[i] == "0" then
                     PokemonBars:setColor("#969696")
                end
    end
end
end
function hide()
   barPoke:setVisible(false)
end
function show()
   barPoke:setVisible(true)
end
-- End public functions

gamelib/protocolgame.lua
Code:
local opcodeCallbacks = {}
local extendedCallbacks = {}

function ProtocolGame:onOpcode(opcode, msg)
  for i, callback in pairs(opcodeCallbacks) do
    if i == opcode then
      callback(self, msg)
      return true
    end
  end
  return false
end

function ProtocolGame:onExtendedOpcode(opcode, buffer)
  local callback = extendedCallbacks[opcode]
  if callback then
    callback(self, opcode, buffer)
  end
end

function ProtocolGame.registerOpcode(opcode, callback)
  if opcodeCallbacks[opcode] then
    error('opcode ' .. opcode .. ' already registered will be overriden')
  end

  opcodeCallbacks[opcode] = callback
end

function ProtocolGame.unregisterOpcode(opcode)
  opcodeCallbacks[opcode] = nil
end

function ProtocolGame.registerExtendedOpcode(opcode, callback)
  if not callback or type(callback) ~= 'function' then
    error('Invalid callback.')
  end

  if opcode < 0 or opcode > 255 then
    error('Invalid opcode. Range: 0-255')
  end

  if extendedCallbacks[opcode] then
    error('Opcode is already taken.')
  end

  extendedCallbacks[opcode] = callback
end

function ProtocolGame.unregisterExtendedOpcode(opcode)
  if opcode < 0 or opcode > 255 then
    error('Invalid opcode. Range: 0-255')
  end

  if not extendedCallbacks[opcode] then
    error('Opcode is not registered.')
  end

  extendedCallbacks[opcode] = nil
end

Please help :( !
 
Back
Top