Ir para conteúdo
Propaganda

Pokebar


Surts

Posts Recomendados

Olá pessoal! Estamos com dificuldade em implementar uma pokebar no nosso servidor. A pokebar em questão é a da base NUMB e queríamos adaptar ela para a base FANS

A interface já aparece no client, porém não linka os status dos pokemons a pokebar em si. 

Abaixo algumas imagens para demonstrar o que esta ocorrendo. No terminal do client não aparece erro nenhum. 

O código está abaixo:

  1. local janelaWindow = nil
  2. local pokeBarWindow = nil
  3. local pokeBarButton = nil
  4. local barList = {}
  5. local barVar = nil
  6.  
  7. function init()
  8. connect(g_game, {onGameStart = online, onGameEnd = offline})
  9. pokeBarButton = modules.client_topmenu.addRightGameToggleButton('pokeBarButton', tr('Poke Bar') .. ' ', '/images/topbuttons/bar', toggle)
  10. -- pokeBarButton:setWidth(25)
  11. pokeBarButton:setOn(false)
  12. janelaWindow = g_ui.displayUI('janela.otui')
  13. pokeBarWindow = g_ui.displayUI('pokeBar', modules.game_interface.getRightPanel())
  14. -- pokeBarWindow:move(250,50)
  15. pokeBarWindow:hide()
  16. janelaWindow:hide()
  17.  
  18. ProtocolGame.registerExtendedOpcode(160, receive)
  19. connect(g_game, 'onTextMessage', portrait)
  20. end
  21.  
  22. function portrait(mode, text)
  23. if not g_game.isOnline() then return end
  24. if mode == MessageModes.Failure then
  25. local t = text:explode(",")
  26. table.remove(t, 1)
  27.  
  28. if string.find(text, 'p#') then
  29. for i = 6, 1, -1 do
  30. barVar = #t
  31. pokeBarWindow:setHeight((51*#t))
  32. if i <= #t then
  33. local t2 = t[i]:explode("|")
  34. pokeBarWindow:getChildById('slot'..i):setVisible(true)
  35. pokeBarWindow:getChildById('slot'..i):setItemId(tonumber(t2[1]))
  36. pokeBarWindow:getChildById('bar'..i).onClick = function() g_game.talk('!@pokebar@ '..tonumber(t2[3])) end
  37. pokeBarWindow:getChildById('L'..i):setColor("#FFFF00")
  38. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover.png")
  39. pokeBarWindow:getChildById('bar'..i):setVisible(true)
  40. pokeBarWindow:getChildById('B'..i):setVisible(true)
  41. receive(i, t2[2], tonumber(t2[4]), tonumber(t2[5]), tonumber(t2[6]), tonumber(t2[7]))
  42. else
  43. pokeBarWindow:getChildById('slot'..i):setItemId(3283)
  44. pokeBarWindow:getChildById('slot'..i):setVisible(false)
  45. pokeBarWindow:getChildById('bar'..i):setVisible(false)
  46. pokeBarWindow:getChildById('B'..i):setVisible(false)
  47. pokeBarWindow:getChildById('bar'..i).onClick = function() end
  48. receive(i, "", 0, 0, 0)
  49. end
  50. end
  51. elseif string.find(text, 'pGS') then
  52. local t2 = t[1]:explode("|")
  53. lifeBarAtual(tonumber(t2[2]), tonumber(t2[1]))
  54. elseif string.find(text, 'KGT') then
  55. local t2 = t[1]:explode("|")
  56. levelBarAtual(t2[1], 0)
  57. end
  58. end
  59. end
  60.  
  61. function levelBarAtual(i)
  62. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_use.png")
  63. pokeBarWindow:getChildById('L'..i):setColor("green")
  64. end
  65.  
  66. function lifeBarAtual(i, hp)
  67. -- if i > 6 or i < 1 then
  68. -- return
  69. -- end
  70. color = '#'
  71. -- pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  72. if tonumber(hp) <= 0 then
  73. pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
  74. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  75. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  76. pokeBarWindow:getChildById('L'..i):setColor("gray")
  77. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png")
  78. else
  79. if tonumber(hp) <= 6 then
  80. return true
  81. end
  82. color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
  83.  
  84. pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
  85. if tonumber(hp) == -1 then
  86. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  87. pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
  88. else
  89. pokeBarWindow:getChildById('HP'..i):setPercent(hp);
  90. pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
  91. end
  92. end
  93. end
  94.  
  95. function receive(i, name, hp, boost, level, sexo)
  96. color = '#'
  97. pokeBarWindow:getChildById('L'..i):setText(name)
  98. pokeBarWindow:getChildById('B'..i):setText("+"..boost)
  99. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000")
  100. pokeBarWindow:getChildById('level'..i):setText("Lv."..level)
  101.  
  102. local genders = {
  103. ["male"] = 4,
  104. ["female"] = 3,
  105. ["indefinido"] = 1,
  106. ["genderless"] = 1,
  107. [4] = "male",
  108. [3] = "female",
  109. }
  110. if genders[sexo] ~= nil then
  111. pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/"..genders[sexo]..".png")
  112. else
  113. pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/unisexo.png")
  114. end
  115.  
  116. --print("HP;"..hp)
  117. if tonumber(hp) == 0 then
  118. pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
  119. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  120. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  121. pokeBarWindow:getChildById('L'..i):setColor("gray")
  122. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png")
  123. else
  124. color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
  125.  
  126. pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
  127. if tonumber(hp) == -1 then
  128. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  129. pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
  130. else
  131. pokeBarWindow:getChildById('HP'..i):setPercent(hp);
  132. pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
  133. end
  134. end
  135.  
  136. end
  137.  
  138. function terminate()
  139. disconnect(g_game, { onGameStart = online,
  140. onGameEnd = offline})
  141. pokeBarWindow:destroy()
  142. janelaWindow:destroy()
  143. disconnect(g_game, 'onTextMessage', portrait)
  144. end
  145.  
  146. function toggle()
  147. if pokeBarButton:isOn() then
  148. pokeBarWindow:hide()
  149. pokeBarButton:setOn(false)
  150. janelaWindow:hide()
  151. else
  152. pokeBarWindow:show()
  153. pokeBarButton:setOn(true)
  154. janelaWindow:show()
  155. end
  156. end
  157.  
  158. function online()
  159. -- if g_game.isOnline() then
  160. -- pokeBarWindow:show()
  161. -- pokeBarButton:setOn(true)
  162. -- janelaWindow:show()
  163. -- end
  164. end
  165.  
  166. function offline()
  167. pokeBarWindow:hide()
  168. pokeBarButton:setOn(false)
  169. janelaWindow:hide()
  170. end
  171.  
  172. function onMoveBottomPanelHoverChange(widget)
  173. if widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
  174. addEvent(function() g_effects.fadeIn(widget, 250) end)
  175. elseif not widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
  176. addEvent(function() g_effects.fadeOut(widget, 250) end)
  177. end
  178. end
  179.  
  180. function getMoveBottomPanel()
  181. return gameRootPanel:recursiveGetChildById('moveBottomPanel')
  182. end
  183.  
  184. function onOrdeEdit(cmd, cmdnew)
  185. g_game.talk("!@vik@ "..cmd..","..cmdnew)
  186. end

 

Se puderem nos ajudar a resolver esse problema agradeceremos imensamente!

Imagem do WhatsApp de 2023-12-27 à(s) 15.03.09_a85d2d9e.jpg

Imagem do WhatsApp de 2023-12-27 à(s) 15.03.09_43a57c93.jpg

  • Like 1
Link para o comentário
Compartilhar em outros sites

  • 5 meses depois...
  • Moderador
Em 27/12/2023 em 15:20, Surts disse:

Olá pessoal! Estamos com dificuldade em implementar uma pokebar no nosso servidor. A pokebar em questão é a da base NUMB e queríamos adaptar ela para a base FANS

A interface já aparece no client, porém não linka os status dos pokemons a pokebar em si. 

Abaixo algumas imagens para demonstrar o que esta ocorrendo. No terminal do client não aparece erro nenhum. 

O código está abaixo:

  1. local janelaWindow = nil
  2. local pokeBarWindow = nil
  3. local pokeBarButton = nil
  4. local barList = {}
  5. local barVar = nil
  6.  
  7. function init()
  8. connect(g_game, {onGameStart = online, onGameEnd = offline})
  9. pokeBarButton = modules.client_topmenu.addRightGameToggleButton('pokeBarButton', tr('Poke Bar') .. ' ', '/images/topbuttons/bar', toggle)
  10. -- pokeBarButton:setWidth(25)
  11. pokeBarButton:setOn(false)
  12. janelaWindow = g_ui.displayUI('janela.otui')
  13. pokeBarWindow = g_ui.displayUI('pokeBar', modules.game_interface.getRightPanel())
  14. -- pokeBarWindow:move(250,50)
  15. pokeBarWindow:hide()
  16. janelaWindow:hide()
  17.  
  18. ProtocolGame.registerExtendedOpcode(160, receive)
  19. connect(g_game, 'onTextMessage', portrait)
  20. end
  21.  
  22. function portrait(mode, text)
  23. if not g_game.isOnline() then return end
  24. if mode == MessageModes.Failure then
  25. local t = text:explode(",")
  26. table.remove(t, 1)
  27.  
  28. if string.find(text, 'p#') then
  29. for i = 6, 1, -1 do
  30. barVar = #t
  31. pokeBarWindow:setHeight((51*#t))
  32. if i <= #t then
  33. local t2 = t[i]:explode("|")
  34. pokeBarWindow:getChildById('slot'..i):setVisible(true)
  35. pokeBarWindow:getChildById('slot'..i):setItemId(tonumber(t2[1]))
  36. pokeBarWindow:getChildById('bar'..i).onClick = function() g_game.talk('!@pokebar@ '..tonumber(t2[3])) end
  37. pokeBarWindow:getChildById('L'..i):setColor("#FFFF00")
  38. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover.png")
  39. pokeBarWindow:getChildById('bar'..i):setVisible(true)
  40. pokeBarWindow:getChildById('B'..i):setVisible(true)
  41. receive(i, t2[2], tonumber(t2[4]), tonumber(t2[5]), tonumber(t2[6]), tonumber(t2[7]))
  42. else
  43. pokeBarWindow:getChildById('slot'..i):setItemId(3283)
  44. pokeBarWindow:getChildById('slot'..i):setVisible(false)
  45. pokeBarWindow:getChildById('bar'..i):setVisible(false)
  46. pokeBarWindow:getChildById('B'..i):setVisible(false)
  47. pokeBarWindow:getChildById('bar'..i).onClick = function() end
  48. receive(i, "", 0, 0, 0)
  49. end
  50. end
  51. elseif string.find(text, 'pGS') then
  52. local t2 = t[1]:explode("|")
  53. lifeBarAtual(tonumber(t2[2]), tonumber(t2[1]))
  54. elseif string.find(text, 'KGT') then
  55. local t2 = t[1]:explode("|")
  56. levelBarAtual(t2[1], 0)
  57. end
  58. end
  59. end
  60.  
  61. function levelBarAtual(i)
  62. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_use.png")
  63. pokeBarWindow:getChildById('L'..i):setColor("green")
  64. end
  65.  
  66. function lifeBarAtual(i, hp)
  67. -- if i > 6 or i < 1 then
  68. -- return
  69. -- end
  70. color = '#'
  71. -- pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  72. if tonumber(hp) <= 0 then
  73. pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
  74. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  75. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  76. pokeBarWindow:getChildById('L'..i):setColor("gray")
  77. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png")
  78. else
  79. if tonumber(hp) <= 6 then
  80. return true
  81. end
  82. color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
  83.  
  84. pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
  85. if tonumber(hp) == -1 then
  86. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  87. pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
  88. else
  89. pokeBarWindow:getChildById('HP'..i):setPercent(hp);
  90. pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
  91. end
  92. end
  93. end
  94.  
  95. function receive(i, name, hp, boost, level, sexo)
  96. color = '#'
  97. pokeBarWindow:getChildById('L'..i):setText(name)
  98. pokeBarWindow:getChildById('B'..i):setText("+"..boost)
  99. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000")
  100. pokeBarWindow:getChildById('level'..i):setText("Lv."..level)
  101.  
  102. local genders = {
  103. ["male"] = 4,
  104. ["female"] = 3,
  105. ["indefinido"] = 1,
  106. ["genderless"] = 1,
  107. [4] = "male",
  108. [3] = "female",
  109. }
  110. if genders[sexo] ~= nil then
  111. pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/"..genders[sexo]..".png")
  112. else
  113. pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/unisexo.png")
  114. end
  115.  
  116. --print("HP;"..hp)
  117. if tonumber(hp) == 0 then
  118. pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
  119. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  120. pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
  121. pokeBarWindow:getChildById('L'..i):setColor("gray")
  122. pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png")
  123. else
  124. color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
  125.  
  126. pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
  127. if tonumber(hp) == -1 then
  128. pokeBarWindow:getChildById('HP'..i):setPercent(100);
  129. pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
  130. else
  131. pokeBarWindow:getChildById('HP'..i):setPercent(hp);
  132. pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
  133. end
  134. end
  135.  
  136. end
  137.  
  138. function terminate()
  139. disconnect(g_game, { onGameStart = online,
  140. onGameEnd = offline})
  141. pokeBarWindow:destroy()
  142. janelaWindow:destroy()
  143. disconnect(g_game, 'onTextMessage', portrait)
  144. end
  145.  
  146. function toggle()
  147. if pokeBarButton:isOn() then
  148. pokeBarWindow:hide()
  149. pokeBarButton:setOn(false)
  150. janelaWindow:hide()
  151. else
  152. pokeBarWindow:show()
  153. pokeBarButton:setOn(true)
  154. janelaWindow:show()
  155. end
  156. end
  157.  
  158. function online()
  159. -- if g_game.isOnline() then
  160. -- pokeBarWindow:show()
  161. -- pokeBarButton:setOn(true)
  162. -- janelaWindow:show()
  163. -- end
  164. end
  165.  
  166. function offline()
  167. pokeBarWindow:hide()
  168. pokeBarButton:setOn(false)
  169. janelaWindow:hide()
  170. end
  171.  
  172. function onMoveBottomPanelHoverChange(widget)
  173. if widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
  174. addEvent(function() g_effects.fadeIn(widget, 250) end)
  175. elseif not widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
  176. addEvent(function() g_effects.fadeOut(widget, 250) end)
  177. end
  178. end
  179.  
  180. function getMoveBottomPanel()
  181. return gameRootPanel:recursiveGetChildById('moveBottomPanel')
  182. end
  183.  
  184. function onOrdeEdit(cmd, cmdnew)
  185. g_game.talk("!@vik@ "..cmd..","..cmdnew)
  186. end

 

Se puderem nos ajudar a resolver esse problema agradeceremos imensamente!

Imagem do WhatsApp de 2023-12-27 à(s) 15.03.09_a85d2d9e.jpg

Imagem do WhatsApp de 2023-12-27 à(s) 15.03.09_43a57c93.jpg

Olá boa tarde caso n tenha conseguido me chame aí no chat  podemos analisar  o bug juntos.

Link para o comentário
Compartilhar em outros sites

Participe da Conversa

Você pode postar agora e se cadastrar mais tarde. Cadastre-se Agora para publicar com Sua Conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.

×
  • Criar Novo...