Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Alguém pode me ajudar, meu servidor ultiliza um spellbar de opcodes, e tem uma spell de transformação, mas quando eu transformo as spells não mudam, só se eu relogar, teria como por um refresh cada vez q mudar de vocation?

 

Script:

 

Spoiler

infos = {
    hotkey     = "Ctrl+F",     
    slot_count = 24,
    vocation   = nil,
    spells     = {},
    chopper_transformation = 1, -- a cada transformacao, ele recebe o id da transformacao   
    styleone_transformation = 1, -- a cada transformacao, ele recebe o id da transformacao     
}

function setupSlots()
    miniWindow:setHeight(34 + math.ceil(#infos.spells / 4) * 36 + 8)
    for index = 1, infos.slot_count do
        local current = miniWindow:getChildById('m' .. index)
        local progress = miniWindow:getChildById('p' .. index)        
        if index <= #infos.spells then
            current:show()
            progress:show()
        else
            current:hide()
            progress:hide()
        end  
    end
end

function configure_spells()        
    
    setupSlots()        
    
    for index, spell in pairs(infos.spells) do
    
        local current = miniWindow:getChildById('m' .. index)
        local progress = miniWindow:getChildById('p' .. index)

        if index > infos.slot_count then
          print('[ERROR - game_spells/spells.lua :: Not possible to get cd slot with index `' .. (index or '__unknown__') .. '`]')
          return false
        end

        current:setImageSource(spell.image)
        progress.name = spell.name 
        progress:setTooltip(spell.name .. " - lvl " .. spell.level .. " (" .. (spell.mana or '?') .. " en)")
        if spell.mana > 0 then
            progress.onClick = function (self)
                g_game.talk(self.name)
            end
        else
            progress.onClick = function (self)
                -- faz nada, mas substitui o antigo
            end
        end
        progress.var = spell.var            
        progress.onMouseRelease = function(self, mousePosition, mouseButton)
            if mouseButton == MouseRightButton then
                if self.var then
                    g_game.talk(self.var)
                end
            end
        end
    end
end

function toggle()
    doOpen(not spellsButton:isOn())
end

function doOpen(bool)
    spellsButton:setOn(bool)
    if bool then
        miniWindow:show()
    else
        miniWindow:hide()
    end    
end

function doRefreshClient()
    infos.chopper_transformation = 1
    local protocolGame = g_game.getProtocolGame()
    if protocolGame then
        protocolGame:sendExtendedOpcode(ClientOpcodes.RequestCdInformations) -- manda pro server, mandar todas spells
    end
end

function getVocationSpells()        
    if infos.vocation == 7 then
        return CHOPPER_FILTER_SPELLS[infos.chopper_transformation] 
    else
        return VOCATIONS_SPELLS[infos.vocation]
    end
end

-- styleone refresh

function doRefreshClient()
    infos.styleone_transformation = 1
    local protocolGame = g_game.getProtocolGame()
    if protocolGame then
        protocolGame:sendExtendedOpcode(ClientOpcodes.RequestCdInformations) -- manda pro server, mandar todas spells
    end
end

function getVocationSpells()        
    if infos.vocation == 10 then
        return STYLEONE_FILTER_SPELLS[infos.styleone_transformation] 
    else
        return VOCATIONS_SPELLS[infos.vocation]
    end
end

function runThread()
    local __clock = os.clock() 
    for index, spell in pairs(infos.spells) do
        local progress = miniWindow:getChildById('p' .. index)            
        if progress then
            if g_game.getLocalPlayer() and g_game.getLocalPlayer():getLevel() >= spell.level then                                                
                progress:setColor('gray')
                local time = math.round((spell.delay - os.clock()) * 10) / 10
                if time <= 0 then
                    progress:setText()                   
                    progress:setPercent(100)             
                else                                                  
                    progress:setText(string.format("%.1f", time)) 
                    progress:setPercent(0)                                                                                                                    
                end
            else
                progress:setColor('pink')
                progress:setText('L' .. spell.level)
                progress:setPercent(0)            
            end
        else
            print('[ERROR - spells.lua :: Invalid progress at spell id `' .. spell.id .. '`]')
        end
    end    
    scheduleEvent(runThread, 100)
end

function init()
    connect(g_game, {onGameStart = doRefreshClient})
    miniWindow = g_ui.loadUI('spells', modules.game_interface.getRightPanel())
    miniWindow:disableResize()
    spellsButton = modules.client_topmenu.addRightGameToggleButton('spellsButton', tr('Spells (' .. infos.hotkey .. ')'), 'images/icon', toggle)
    g_keyboard.bindKeyDown(infos.hotkey, toggle)
    doOpen(true)    
    miniWindow:setup()            
    
    ProtocolGame.registerExtendedOpcode(GameServerOpcodes.CdInformations, function(protocol, opcode, buffer)
        --print(buffer)
        local __buffer = loadstring('return ' .. buffer)()
        if __buffer.vocation or __buffer.Tr then -- Exemplo: `{vocation = 2, ...}` ;
            if __buffer.vocation then
                infos.vocation = (tonumber(__buffer.vocation) or 0) % 10
            end
            if __buffer.Tr then
                infos.chopper_transformation = tonumber(__buffer.Tr)
                if not infos.chopper_transformation then
                    print('[ERROR - game_spells/spells.lua :: Invalid chopper transformation buffer')
                end         
            end
            if not VOCATIONS_SPELLS[infos.vocation] then
                print('[ERROR - game_spells/spells.lua :: Invalid vocation]')
            else
                infos.spells = {}
                local table_spells = getVocationSpells()
                for index, spell_id in pairs(table_spells) do
                    local spell = SPELL_LIST[table_spells[index]]
                    infos.spells[index] = {index  = index, id = spell_id, name = spell.name, level = spell.level, mana = spell.mana, delay = 0, image = spell.image}
                end
                configure_spells() 
            end
        end
        if __buffer.cd then
            for index, cd in pairs(__buffer.cd) do
                local found
                for index, spell in pairs(infos.spells) do
                    --print('> ' .. spell.id)
                    if spell.id == cd[1] then
                        spell.delay = os.clock() + cd[2]
                        found = true
                        break
                    end
                end
                if not found then
                    print('[ERROR - game_spells/spells.lua :: Not found cd slot with spell_id `' .. cd[1] .. '` ; Delay would be set to `' .. cd[2]  .. '`]')
                end                                        
            end            
        end
    end)        
    runThread()
end

function terminate()
    miniWindow:destroy()
    spellsButton:destroy()
    g_keyboard.unbindKeyDown(infos.hotkey)
    disconnect(g_game, {onGameStart = doRefreshClient})
    ProtocolGame.unregisterExtendedOpcode(GameServerOpcodes.CdInformations)
end

 

 

2z8t5ef.jpg

assinatura2.fw.png

Link para o post
Compartilhar em outros sites

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

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

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo