Surts 13 Postado 27 de Dezembro 2023 Compartilhar Postado 27 de Dezembro 2023 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: local janelaWindow = nil local pokeBarWindow = nil local pokeBarButton = nil local barList = {} local barVar = nil function init() connect(g_game, {onGameStart = online, onGameEnd = offline}) pokeBarButton = modules.client_topmenu.addRightGameToggleButton('pokeBarButton', tr('Poke Bar') .. ' ', '/images/topbuttons/bar', toggle) -- pokeBarButton:setWidth(25) pokeBarButton:setOn(false) janelaWindow = g_ui.displayUI('janela.otui') pokeBarWindow = g_ui.displayUI('pokeBar', modules.game_interface.getRightPanel()) -- pokeBarWindow:move(250,50) pokeBarWindow:hide() janelaWindow:hide() ProtocolGame.registerExtendedOpcode(160, receive) connect(g_game, 'onTextMessage', portrait) end function portrait(mode, text) if not g_game.isOnline() then return end if mode == MessageModes.Failure then local t = text:explode(",") table.remove(t, 1) if string.find(text, 'p#') then for i = 6, 1, -1 do barVar = #t pokeBarWindow:setHeight((51*#t)) if i <= #t then local t2 = t[i]:explode("|") pokeBarWindow:getChildById('slot'..i):setVisible(true) pokeBarWindow:getChildById('slot'..i):setItemId(tonumber(t2[1])) pokeBarWindow:getChildById('bar'..i).onClick = function() g_game.talk('!@pokebar@ '..tonumber(t2[3])) end pokeBarWindow:getChildById('L'..i):setColor("#FFFF00") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover.png") pokeBarWindow:getChildById('bar'..i):setVisible(true) pokeBarWindow:getChildById('B'..i):setVisible(true) receive(i, t2[2], tonumber(t2[4]), tonumber(t2[5]), tonumber(t2[6]), tonumber(t2[7])) else pokeBarWindow:getChildById('slot'..i):setItemId(3283) pokeBarWindow:getChildById('slot'..i):setVisible(false) pokeBarWindow:getChildById('bar'..i):setVisible(false) pokeBarWindow:getChildById('B'..i):setVisible(false) pokeBarWindow:getChildById('bar'..i).onClick = function() end receive(i, "", 0, 0, 0) end end elseif string.find(text, 'pGS') then local t2 = t[1]:explode("|") lifeBarAtual(tonumber(t2[2]), tonumber(t2[1])) elseif string.find(text, 'KGT') then local t2 = t[1]:explode("|") levelBarAtual(t2[1], 0) end end end function levelBarAtual(i) pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_use.png") pokeBarWindow:getChildById('L'..i):setColor("green") end function lifeBarAtual(i, hp) -- if i > 6 or i < 1 then -- return -- end color = '#' -- pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") if tonumber(hp) <= 0 then pokeBarWindow:getChildById('HP'..i):setText("Desmaiado") pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") pokeBarWindow:getChildById('L'..i):setColor("gray") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png") else if tonumber(hp) <= 6 then return true end color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0) pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color) if tonumber(hp) == -1 then pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ; else pokeBarWindow:getChildById('HP'..i):setPercent(hp); pokeBarWindow:getChildById('HP'..i):setText(hp.."%"); end end end function receive(i, name, hp, boost, level, sexo) color = '#' pokeBarWindow:getChildById('L'..i):setText(name) pokeBarWindow:getChildById('B'..i):setText("+"..boost) pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000") pokeBarWindow:getChildById('level'..i):setText("Lv."..level) local genders = { ["male"] = 4, ["female"] = 3, ["indefinido"] = 1, ["genderless"] = 1, [4] = "male", [3] = "female", } if genders[sexo] ~= nil then pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/"..genders[sexo]..".png") else pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/unisexo.png") end --print("HP;"..hp) if tonumber(hp) == 0 then pokeBarWindow:getChildById('HP'..i):setText("Desmaiado") pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") pokeBarWindow:getChildById('L'..i):setColor("gray") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png") else color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0) pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color) if tonumber(hp) == -1 then pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ; else pokeBarWindow:getChildById('HP'..i):setPercent(hp); pokeBarWindow:getChildById('HP'..i):setText(hp.."%"); end end end function terminate() disconnect(g_game, { onGameStart = online, onGameEnd = offline}) pokeBarWindow:destroy() janelaWindow:destroy() disconnect(g_game, 'onTextMessage', portrait) end function toggle() if pokeBarButton:isOn() then pokeBarWindow:hide() pokeBarButton:setOn(false) janelaWindow:hide() else pokeBarWindow:show() pokeBarButton:setOn(true) janelaWindow:show() end end function online() -- if g_game.isOnline() then -- pokeBarWindow:show() -- pokeBarButton:setOn(true) -- janelaWindow:show() -- end end function offline() pokeBarWindow:hide() pokeBarButton:setOn(false) janelaWindow:hide() end function onMoveBottomPanelHoverChange(widget) if widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then addEvent(function() g_effects.fadeIn(widget, 250) end) elseif not widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then addEvent(function() g_effects.fadeOut(widget, 250) end) end end function getMoveBottomPanel() return gameRootPanel:recursiveGetChildById('moveBottomPanel') end function onOrdeEdit(cmd, cmdnew) g_game.talk("!@vik@ "..cmd..","..cmdnew) end Se puderem nos ajudar a resolver esse problema agradeceremos imensamente! 1 Citar Link para o comentário Compartilhar em outros sites Mais opções de compartilhamento...
Moderador Wang 1.338 Postado 16 de Junho Moderador Compartilhar Postado 16 de Junho 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: local janelaWindow = nil local pokeBarWindow = nil local pokeBarButton = nil local barList = {} local barVar = nil function init() connect(g_game, {onGameStart = online, onGameEnd = offline}) pokeBarButton = modules.client_topmenu.addRightGameToggleButton('pokeBarButton', tr('Poke Bar') .. ' ', '/images/topbuttons/bar', toggle) -- pokeBarButton:setWidth(25) pokeBarButton:setOn(false) janelaWindow = g_ui.displayUI('janela.otui') pokeBarWindow = g_ui.displayUI('pokeBar', modules.game_interface.getRightPanel()) -- pokeBarWindow:move(250,50) pokeBarWindow:hide() janelaWindow:hide() ProtocolGame.registerExtendedOpcode(160, receive) connect(g_game, 'onTextMessage', portrait) end function portrait(mode, text) if not g_game.isOnline() then return end if mode == MessageModes.Failure then local t = text:explode(",") table.remove(t, 1) if string.find(text, 'p#') then for i = 6, 1, -1 do barVar = #t pokeBarWindow:setHeight((51*#t)) if i <= #t then local t2 = t[i]:explode("|") pokeBarWindow:getChildById('slot'..i):setVisible(true) pokeBarWindow:getChildById('slot'..i):setItemId(tonumber(t2[1])) pokeBarWindow:getChildById('bar'..i).onClick = function() g_game.talk('!@pokebar@ '..tonumber(t2[3])) end pokeBarWindow:getChildById('L'..i):setColor("#FFFF00") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover.png") pokeBarWindow:getChildById('bar'..i):setVisible(true) pokeBarWindow:getChildById('B'..i):setVisible(true) receive(i, t2[2], tonumber(t2[4]), tonumber(t2[5]), tonumber(t2[6]), tonumber(t2[7])) else pokeBarWindow:getChildById('slot'..i):setItemId(3283) pokeBarWindow:getChildById('slot'..i):setVisible(false) pokeBarWindow:getChildById('bar'..i):setVisible(false) pokeBarWindow:getChildById('B'..i):setVisible(false) pokeBarWindow:getChildById('bar'..i).onClick = function() end receive(i, "", 0, 0, 0) end end elseif string.find(text, 'pGS') then local t2 = t[1]:explode("|") lifeBarAtual(tonumber(t2[2]), tonumber(t2[1])) elseif string.find(text, 'KGT') then local t2 = t[1]:explode("|") levelBarAtual(t2[1], 0) end end end function levelBarAtual(i) pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_use.png") pokeBarWindow:getChildById('L'..i):setColor("green") end function lifeBarAtual(i, hp) -- if i > 6 or i < 1 then -- return -- end color = '#' -- pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") if tonumber(hp) <= 0 then pokeBarWindow:getChildById('HP'..i):setText("Desmaiado") pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") pokeBarWindow:getChildById('L'..i):setColor("gray") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png") else if tonumber(hp) <= 6 then return true end color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0) pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color) if tonumber(hp) == -1 then pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ; else pokeBarWindow:getChildById('HP'..i):setPercent(hp); pokeBarWindow:getChildById('HP'..i):setText(hp.."%"); end end end function receive(i, name, hp, boost, level, sexo) color = '#' pokeBarWindow:getChildById('L'..i):setText(name) pokeBarWindow:getChildById('B'..i):setText("+"..boost) pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000") pokeBarWindow:getChildById('level'..i):setText("Lv."..level) local genders = { ["male"] = 4, ["female"] = 3, ["indefinido"] = 1, ["genderless"] = 1, [4] = "male", [3] = "female", } if genders[sexo] ~= nil then pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/"..genders[sexo]..".png") else pokeBarWindow:getChildById('sexo'..i):setImageSource("graph/unisexo.png") end --print("HP;"..hp) if tonumber(hp) == 0 then pokeBarWindow:getChildById('HP'..i):setText("Desmaiado") pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020") pokeBarWindow:getChildById('L'..i):setColor("gray") pokeBarWindow:getChildById('bar'..i):setImageSource("graph/background_hover_dead.png") else color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0) pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color) if tonumber(hp) == -1 then pokeBarWindow:getChildById('HP'..i):setPercent(100); pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ; else pokeBarWindow:getChildById('HP'..i):setPercent(hp); pokeBarWindow:getChildById('HP'..i):setText(hp.."%"); end end end function terminate() disconnect(g_game, { onGameStart = online, onGameEnd = offline}) pokeBarWindow:destroy() janelaWindow:destroy() disconnect(g_game, 'onTextMessage', portrait) end function toggle() if pokeBarButton:isOn() then pokeBarWindow:hide() pokeBarButton:setOn(false) janelaWindow:hide() else pokeBarWindow:show() pokeBarButton:setOn(true) janelaWindow:show() end end function online() -- if g_game.isOnline() then -- pokeBarWindow:show() -- pokeBarButton:setOn(true) -- janelaWindow:show() -- end end function offline() pokeBarWindow:hide() pokeBarButton:setOn(false) janelaWindow:hide() end function onMoveBottomPanelHoverChange(widget) if widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then addEvent(function() g_effects.fadeIn(widget, 250) end) elseif not widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then addEvent(function() g_effects.fadeOut(widget, 250) end) end end function getMoveBottomPanel() return gameRootPanel:recursiveGetChildById('moveBottomPanel') end function onOrdeEdit(cmd, cmdnew) g_game.talk("!@vik@ "..cmd..","..cmdnew) end Se puderem nos ajudar a resolver esse problema agradeceremos imensamente! Olá boa tarde caso n tenha conseguido me chame aí no chat podemos analisar o bug juntos. Citar Link para o comentário Compartilhar em outros sites Mais opções de compartilhamento...
Posts Recomendados
Participe da Conversa
Você pode postar agora e se cadastrar mais tarde. Cadastre-se Agora para publicar com Sua Conta.