Ir para conteúdo

Featured Replies

Postado

Estou com os seguintes erros no terminal do meu otclient (com o tempo isso faz o client freezar muito)

 

esse aqui aparece sempre que eu desço uma escada e tem um pokémon no lugar:

Spoiler

image.png.4281ac4520965e7a07a48e96a6e40293.png

 

battle.lua:

 

 

Spoiler

battleWindow = nil
battleButton = nil
battlePanel = nil
lastBattleButtonSwitched = nil
battleButtonsByCreaturesList = {}

mouseWidget = nil
pokemon = nil
pokemonId = nil
hidePlayersButton = nil
hideNPCsButton = nil
hideMonstersButton = nil

function init()
  g_ui.importStyle('battlebutton')
  battleButton = modules.client_topmenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', '/images/topbuttons/battle', toggle)
  battleButton:setWidth(24)
  battleButton:setOn(true)
  battleWindow = g_ui.loadUI('battle', modules.game_interface.getRightPanel())
  g_keyboard.bindKeyDown('Ctrl+B', toggle)

  -- this disables scrollbar auto hiding
  local scrollbar = battleWindow:getChildById('miniwindowScrollBar')
  scrollbar:mergeStyle({ ['$!on'] = { }})

  battlePanel = battleWindow:recursiveGetChildById('battlePanel')

  hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
  hideNPCsButton = battleWindow:recursiveGetChildById('hideNPCs')
  hideMonstersButton = battleWindow:recursiveGetChildById('hideMonsters')

  mouseWidget = g_ui.createWidget('UIButton')
  mouseWidget:setVisible(false)
  mouseWidget:setFocusable(false)
  mouseWidget.cancelNextRelease = false

  battleWindow:setContentMinimumHeight(78)

  connect(Creature, {
    onSkullChange = updateCreatureSkull,
    onEmblemChange = updateCreatureEmblem,
    onOutfitChange = onCreatureOutfitChange,
    onHealthPercentChange = onCreatureHealthPercentChange,
    onPositionChange = onCreaturePositionChange,
    onAppear = onCreatureAppear,
    onDisappear = onCreatureDisappear
  })

  connect(g_game, {
    onAttackingCreatureChange = onAttack,
    onFollowingCreatureChange = onFollow,
    onGameEnd = removeAllCreatures
  })

  ProtocolGame.registerExtendedOpcode(106, function(protocol, opcode, buffer) isMyPokemon(protocol, opcode, buffer) end)

  checkCreatures()
  battleWindow:setup()
end

function terminate()
  g_keyboard.unbindKeyDown('Ctrl+B')
  battleButtonsByCreaturesList = {}
  battleButton:destroy()
  battleWindow:destroy()
  mouseWidget:destroy()

  disconnect(Creature, {  
    onSkullChange = updateCreatureSkull,
    onEmblemChange = updateCreatureEmblem,
    onOutfitChange = onCreatureOutfitChange,
    onHealthPercentChange = onCreatureHealthPercentChange,
    onPositionChange = onCreaturePositionChange,
    onAppear = onCreatureAppear,
    onDisappear = onCreatureDisappear
  })

  disconnect(g_game, {
    onAttackingCreatureChange = onAttack,
    onFollowingCreatureChange = onFollow,
    onGameEnd = removeAllCreatures
  })

  ProtocolGame.unregisterExtendedOpcode(106)
end

function toggle()
  if battleButton:isOn() then
    battleWindow:close()
    battleButton:setOn(false)
  else
    battleWindow:open()
    battleButton:setOn(true)
  end
end

function onMiniWindowClose()
  battleButton:setOn(false)
end

function checkCreatures()
  removeAllCreatures()

  local spectators = {}
  local player = g_game.getLocalPlayer()
  if g_game.isOnline() then
    g_game.getProtocolGame():sendExtendedOpcode(106, 'refresh')
    creatures = g_map.getSpectators(player:getPosition(), false)
    for i, creature in ipairs(creatures) do
      if creature ~= player and doCreatureFitFilters(creature) then
        table.insert(spectators, creature)
      end
    end
  end

  for i, v in pairs(spectators) do
    addCreature(v)
  end
end

function isMyPokemon(protocol, opcode, buffer)
  local battleButton = battleButtonsByCreaturesList[tonumber(buffer)]
  local creature = battleButton:getCreature()
  if battleButton then
    removeCreature(creature)
  end
  pokemon = creature
  pokemonId = tonumber(buffer)
  addCreature(creature)
end

function doCreatureFitFilters(creature)
  local localPlayer = g_game.getLocalPlayer()
  if creature == localPlayer then
    return false
  end

  local pos = creature:getPosition()
  if not pos then return false end

  if pos.z ~= localPlayer:getPosition().z or not creature:canBeSeen() then return false end

  local hidePlayers = hidePlayersButton:isChecked()
  local hideNPCs = hideNPCsButton:isChecked()
  local hideMonsters = hideMonstersButton:isChecked()

  if hidePlayers and creature:isPlayer() then
    return false
  elseif hideNPCs and creature:isNpc() then
    return false
  elseif hideMonsters and creature:isMonster() then
    return false
  end

  return true
end

function onCreatureHealthPercentChange(creature, health)
  local battleButton = battleButtonsByCreaturesList[creature:getId()]
  if battleButton then
    battleButton:setLifeBarPercent(creature:getHealthPercent())
	if creature:getHealthPercent() <= 0 then
	   battleButton:setVisible(false)
	end
  end
end

function onCreaturePositionChange(creature, newPos, oldPos)
  if creature:isLocalPlayer() then
    if oldPos and newPos and newPos.z ~= oldPos.z then
      checkCreatures()
    else
      for id, creatureButton in pairs(battleButtonsByCreaturesList) do
        addCreature(creatureButton.creature)
      end
    end
  else
    local has = hasCreature(creature)
    local fit = doCreatureFitFilters(creature)
    if has and not fit then
      removeCreature(creature)
    elseif fit then
      addCreature(creature)
    end
  end
end

function onCreatureOutfitChange(creature, outfit, oldOutfit)
  if doCreatureFitFilters(creature) then
    addCreature(creature)
  else
    removeCreature(creature)
  end
end

function onCreatureAppear(creature)
  if doCreatureFitFilters(creature) then
    addCreature(creature)
  end
end

function onCreatureDisappear(creature)
  removeCreature(creature)
end

function hasCreature(creature)
  return battleButtonsByCreaturesList[creature:getId()] ~= nil
end

function addCreature(creature)
  local creatureId = creature:getId()
  local battleButton = battleButtonsByCreaturesList[creatureId]
  
		if creature:getHealthPercent() <= 1 then
		   battleButton:setVisible(false)
		   return true
		end

  if not battleButton then
    battleButton = g_ui.createWidget('BattleButton')
    battleButton:setup(creature)

    battleButton.onHoverChange = onBattleButtonHoverChange
    battleButton.onMouseRelease = onBattleButtonMouseRelease

    battleButtonsByCreaturesList[creatureId] = battleButton

    if pokemonId and creatureId == pokemonId then
      battlePanel:insertChild(1, battleButton)
      battleButton:getChildById('myPokemon'):setImageColor('white')
    else
      battlePanel:addChild(battleButton)
    end

    if creature == g_game.getAttackingCreature() then
      onAttack(creature)
    end

    if creature == g_game.getFollowingCreature() then
      onFollow(creature)
    end
  else
    battleButton:setLifeBarPercent(creature:getHealthPercent())
  end

  local localPlayer = g_game.getLocalPlayer()
  battleButton:setVisible(localPlayer:hasSight(creature:getPosition()) and creature:canBeSeen())
end

function removeAllCreatures()
  for i, v in pairs(battleButtonsByCreaturesList) do
    removeCreature(v.creature)
  end
end

function removeCreature(creature)
  if hasCreature(creature) then
    local creatureId = creature:getId()

    if lastBattleButtonSwitched == battleButtonsByCreaturesList[creatureId] then
      lastBattleButtonSwitched = nil
    end

    battleButtonsByCreaturesList[creatureId].creature:hideStaticSquare()
    battleButtonsByCreaturesList[creatureId]:destroy()
    battleButtonsByCreaturesList[creatureId] = nil
  end
end

function onBattleButtonMouseRelease(self, mousePosition, mouseButton)
  if mouseWidget.cancelNextRelease then
    mouseWidget.cancelNextRelease = false
    return false
  end
  if ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) 
    or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
    mouseWidget.cancelNextRelease = true
    g_game.look(self.creature)
    return true
  elseif mouseButton == MouseLeftButton and g_keyboard.isShiftPressed() then
    g_game.look(self.creature)
    return true
  elseif mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
    modules.game_interface.createThingMenu(mousePosition, nil, nil, self.creature)
    return true
  elseif mouseButton == MouseLeftButton and not g_mouse.isPressed(MouseRightButton) then
    if self.isTarget then
      g_game.cancelAttack()
    else
      g_game.attack(self.creature)
    end
    return true
  end
  return false
end

function onBattleButtonHoverChange(widget, hovered)
  if widget.isBattleButton then
    widget.isHovered = hovered
    updateBattleButton(widget)
  end
end

function onAttack(creature)
  local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
  if battleButton then
    battleButton.isTarget = creature and true or false
    updateBattleButton(battleButton)
  end
end

function onFollow(creature)
  local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
  if battleButton then
    battleButton.isFollowed = creature and true or false
    updateBattleButton(battleButton)
  end
end

function updateCreatureSkull(creature, skullId)
  local battleButton = battleButtonsByCreaturesList[creature:getId()]
  if battleButton then
    battleButton:updateSkull(skullId)
  end
end

function updateCreatureEmblem(creature, emblemId)
  local battleButton = battleButtonsByCreaturesList[creature:getId()]
  if battleButton then
    battleButton:updateSkull(emblemId)
  end
end

function updateBattleButton(battleButton)
  battleButton:update()
  if battleButton.isTarget or battleButton.isFollowed then
    -- set new last battle button switched
    if lastBattleButtonSwitched and lastBattleButtonSwitched ~= battleButton then
      lastBattleButtonSwitched.isTarget = false
      lastBattleButtonSwitched.isFollowed = false
      updateBattleButton(lastBattleButtonSwitched)
    end
    lastBattleButtonSwitched = battleButton
  end
end

function getMyPokemon()
  if pokemon then
    return pokemon
  end
  return false
end

 

 

 

esse outro erro aparece quando eu mato um pokemon:

 

Spoiler

image.png.61e2b98dfcf18efa9cb1d1e7f618de15.png

 

cdbar.lua

 

Spoiler

-- Privates variables
local cdBarWin = nil
local isIn = 'H' --[[ 'H' = horizontal; 'V' = vertical ]]--
local namesAtks = ''
local icons = {}
-- End privates variables

-- Public functions
function init()
   cdBarWin = g_ui.displayUI('cdBar', modules.game_interface.getRootPanel())
   cdBarWin:setVisible(false)  
   cdBarWin:move(250,50)
   
   connect(g_game, 'onTextMessage', getParams)
   connect(g_game, { onGameEnd = hide } )
   connect(LocalPlayer, { onLevelChange = onLevelChange })
 
   g_mouse.bindPress(cdBarWin, function() createMenu() end, MouseRightButton)
   
   createIcons()
end

function terminate()
   disconnect(g_game, { onGameEnd = hide })
   disconnect(g_game, 'onTextMessage', getParams)
   disconnect(LocalPlayer, { onLevelChange = onLevelChange })
   
   destroyIcons()
   cdBarWin:destroy()
end

function onLevelChange(localPlayer, value, percent)
    if not cdBarWin:isVisible() then return end
       g_game.talk("/reloadCDs")
end

function getParams(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then
      if string.find(text, '12//,') then
         if string.find(text, 'hide') then hide() else show() end
      elseif string.find(text, '12|,') then
         atualizarCDs(text)
      elseif string.find(text, '12&,') then
         FixTooltip(text)
      end
   end
end

function atualizarCDs(text)
if not g_game.isOnline() then return end
if not cdBarWin:isVisible() then return end
   local t = text:explode(",")
   table.remove(t, 1)   
   for i = 1, 12 do
       local t2 = t:explode("|")
       barChange(i, tonumber(t2[1]), tonumber(t2[2]), tonumber(t2[3]))
   end
end

function changePercent(progress, icon, perc, num, init)
   if not cdBarWin:isVisible() then return end      
   if init then
      progress:setPercent(0)
   else
      progress:setPercent(progress:getPercent()+perc)
   end
   if progress:getPercent() >= 100 then
      progress:setText("")
      return
   end
   progress:setText(num)
   icons[icon:getId()].event = scheduleEvent(function() changePercent(progress, icon, perc, num-1) end, 1000)
end

function barChange(ic, num, lvl, lvlPoke)
if not g_game.isOnline() then return end
if not cdBarWin:isVisible() then return end
   local icon = icons['Icon'..ic].icon
   local progress = icons['Icon'..ic].progress
   
   if not progress:getTooltip() then return end
   local player = g_game.getLocalPlayer()
   local pathOn = "moves_icon/"..icons['Icon'..ic].spellName.."_on.png"
   
   icon:setImageSource(pathOn)
   
   if num and num >= 1 then   
      cleanEvents('Icon'..ic)
      changePercent(progress, icon, 100/num, num, true)      
   else   
      if (lvlPoke and lvlPoke < lvl) or player:getLevel() < lvl then
         progress:setPercent(0)
         progress:setText('L.'.. lvl)
         progress:setColor('#FF0000')
      else
         progress:setPercent(100)
         progress:setText("")
      end
   end    
end

function FixTooltip(text)
   cdBarWin:setHeight(isIn == 'H' and 416 or 40)
   cdBarWin:setWidth(isIn == 'H' and 40 or 416)
   if not text then text = namesAtks else namesAtks = text end
   
   local t2 = text:explode(",")
   local count = 0
   for j = 2, 13 do
       local ic = icons['Icon'..(j-1)]
       ic.icon:setMarginLeft(isIn == 'H' and 4 or ic.dist)
       ic.icon:setMarginTop(isIn == 'H' and ic.dist or 4)
       if t2[j] == 'n/n' then    
          ic.icon:hide()      
          count = count+1
       else
          ic.icon:show()
            if t2[j]:find("- ") then
               ic.progress:setTooltip("Mega Evoluir")    
               ic.spellName = "Mega Evoluir"
            elseif t2[j]:find("Sketch") then
               ic.progress:setTooltip("Sketch")    
               ic.spellName = "Sketch"
            else
               ic.progress:setTooltip(t2[j])
               ic.spellName = t2[j]
            end
          ic.progress:setVisible(true)
       end
   end
   if count > 0 and count ~= 12 then
      if isIn == "H" then
         cdBarWin:setHeight(416 - (count*34))
      else
         cdBarWin:setWidth(416 - (count*34))
      end
   elseif count == 12 then
      cdBarWin:setHeight(40)
      cdBarWin:setWidth(40)
      local p = icons['Icon1'].progress
      p:setTooltip(false)
      p:setVisible(false)
   end                
end

function createIcons()
   local d = 38
   for i = 1, 12 do
      local icon = g_ui.createWidget('SpellIcon', cdBarWin)
      local progress = g_ui.createWidget('SpellProgress', cdBarWin)
      icon:setId('Icon'..i)  
      progress:setId('Progress' ..i)
      icons['Icon'..i] = {icon = icon, progress = progress, dist = (i == 1 and 5 or i == 2 and 38 or d + ((i-2)*34)), event = nil}
      icon:setMarginTop(icons['Icon'..i].dist)
      icon:setMarginLeft(4)
      progress:fill(icon:getId())
      progress.onClick = function() g_game.talk('m'..i) end
   end
end

function destroyIcons()
   for i = 1, 12 do
       icons['Icon'..i].icon:destroy()
       icons['Icon'..i].progress:destroy()
   end                                
   cleanEvents()
   icons = {}
end

function cleanEvents(icon)
local e = nil
if icon then
   e = icons[icon]
   if e and e.event ~= nil then
      removeEvent(e.event)
      e.event = nil
   end
else
   for i = 1, 12 do
       e = icons['Icon'..i]
       cleanEvents('Icon'..i)
       e.progress:setPercent(100)
       e.progress:setText("")
   end
end
end

function createMenu()
   local menu = g_ui.createWidget('PopupMenu')
   menu:addOption("Set "..(isIn == 'H' and 'Vertical' or 'Horizontal'), function() toggle() end)
   menu:display()
end

function toggle()
if not cdBarWin:isVisible() then return end
   cdBarWin:setVisible(false)
   if isIn == 'H' then
      isIn = 'V'
   else
      isIn = 'H'
   end
   FixTooltip()
   show()
end

function hide()    
   cleanEvents()
   cdBarWin:setVisible(false)
end

function show()
   cdBarWin:setVisible(true)
end
-- End public functions

 

e constantemente esse erro aqui aparece:

 

Spoiler

image.png.005048d8edd117b107ef7392cafca7e2.png

 

procurei bem respostas. motivos pra isso acontecer, não costumo mexer com otclient e to tendo que fazer isso por conta (só falta isso pra lançar o meu servidor).

 

alguém pode me ajudar com esses problemas?

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 520.1k

Informação Importante

Confirmação de Termo