melhor fazer a cd bar do 0
Ajuda ExtendedOpCode
Por deglorio, 22 de abr. de 2014 em Clients
info
Grupo: Visconde
Registrado: 04/11/12
Posts: 464
Reputação: +90
Gênero: Masculino
Char no Tibia: Lysty Of Death

A base ta ai gristony, falta apenas enviar por opcode, acredito que nao precisa fazer do zero, n entendo mto de opcode, mas acredito q vc ta enganado!
Tira o connect e disconnect do 'onTextMessage'
E coloca no lugar o seguinte:
ProtocolGame.registerExtendedOpcode(numero_do_opcode, getParams)
E no disconnect:
ProtocolGame.unregisterExtendedOpcode(numero_do_opcode)
Altera também algumas coisas na função getParams
function getParams(protocol, opcode, buffer) if not g_game.isOnline() then return end if string.find(buffer, '12//,') then if string.find(buffer, 'hide') then hide() else show() end elseif string.find(buffer, '12|,') then atualizarCDs(buffer) elseif string.find(buffer, '12&,') then FixTooltip(buffer) end end
E no server, onde está enviando sendcancel, é so enviar com o numero do opcode que usou pra registrar com o texto que enviava pelo sendcancel
mas cara, a vantagem de usar opcode é usar em bytes, esse jeito ai vai continuar em texto, só vai mudar o fato de estar usando o extendedopcode
Editado Abril 23 por dalvorsn
Muito obrigado, deu certo, mais seria complicado passar o script para bytes?
Editado Abril 23 por Deglorio
Muito obrigado, deu certo, mais seria complicado passar o script para bytes?
Depende de que servidor voce esta usando, se for tfs 1.0 ele ja tem o networkmessage, no caso de outros teria que adicionar a lib dele, questao e que a lib nao e minha, nao posso simplesmente passar ela
info
Grupo: Visconde
Registrado: 04/11/12
Posts: 464
Reputação: +90
Gênero: Masculino
Char no Tibia: Lysty Of Death

A base ta ai gristony, falta apenas enviar por opcode, acredito que nao precisa fazer do zero, n entendo mto de opcode, mas acredito q vc ta enganado!
sim nao presisa fazer do 0 poriso que eu dize é melhor fazer do 0 e tbm usar bytes nao expliquei direito mais oque eu queria dizer era isso ai dos bytes pq como se dize nao usa moves do pda ia da na mesma coisa usando opcode deixe jeito ai porisso é melhor usar bytes o ruim é que nao vejo nem um tutor de como usar bytes
@dalvoson se poderia ensinar a usar bytes ai? eu tenho a lib tbm nao posso passar a lib mais eu tenho ela aqui. ai se nao pode fazer um mini tutor sobre bytes?




info
Grupo: Artesão
Registrado: 31/01/09
Posts: 108
Reputação: +44
Pessoal, estou aqui para pedir uma ajuda, estou fazendo uma spellbar para um servidor 8.54, no meu otclient 0.6.5. A dúvida é o seguinte, minha spellbar está usando o sendcancel, e queria utilizar o extendedopcode, algúem pode me dizer como ficaria o script para usar o opcode(lembrando já instalei o opcode na sources do servidor)
Segue script do otclient cdBar.lua
--[[Coisas para saber! local button = optionsWindow:recursiveGetChildById('Button'):setText("Fuu") == muda o nome do botao! optionsWindow = g_ui.loadUI('bot.otui', modules.game_interface.getRightPanel()) == faz a janela ficar nos cantos! local player = g_game.getLocalPlayer() == pega o player! player:getInventoryItem(8):getId() == pega o id do item, id do .spr ]] -- 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) 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[i]: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/"..progress:getTooltip().."_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 450 or 70) cdBarWin:setWidth(isIn == 'H' and 70 or 450) 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() ic.progress:setTooltip(t2[j]) ic.progress:setVisible(true) end end if count > 0 and count ~= 12 then if isIn == "H" then cdBarWin:setHeight(450 - (count*34)) else cdBarWin:setWidth(450 - (count*34)) end elseif count == 12 then cdBarWin:setHeight(70) cdBarWin:setWidth(70) 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 = icons[icon] if icon then 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 functionscdBar.OTUI
Abrir a barra no Servidor (goback)
Fechar a barra no Servidor (goback)