• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Doubt adds Health Bar in OTClient

AnnaFeeh

Let her pass, or looks, or moves
Joined
May 2, 2014
Messages
14
Reaction score
0
Location
Belo Jardim PE
Hello staff of OtLand, I'm here today to take a question about OTClient!
I am wondering how I can add a healthbar in the skills OTClient
The skills are as follows:
141012032228376539.png

then I wanted to put a healthbar that there Half :D
 
Yes you can do this, but by 'healthbar' do you mean the same style bar as a skill bar just representing the players health? or the same type of healthbar as the health info window?
Which ever way is doable you just need to create the widget and connect a method to LocalPlayer#onHealthChange:
PHP:
healthBar = nil

function init()
  connect(LocalPlayer, { onHealthChange = healthChanged })

  healthBar = healthInfoWindow:recursiveGetChildById('healthBar')
end

function terminate()
  disconnect(LocalPlayer, { onHealthChange = healthChanged })
end

function healthChanged(localPlayer, health, maxHealth)
  healthBar:setText(health .. ' / ' .. maxHealth)
  healthBar:setTooltip(tr(healthTooltip, health, maxHealth))
  healthBar:setValue(health, 0, maxHealth)
end

Need to ensure you have a HealthBar widget inside the otui file too.
PHP:
HealthBar < ProgressBar
  id: healthBar
  background-color: #ff4444
  anchors.top: parent.top
  anchors.left: parent.left
  anchors.right: parent.right
  margin: 1

Something like this would work. Of course you would have to get the positioning right too.
 
Code:
skillsWindow = nil
skillsButton = nil

local imgs = {
   [-1] = "/modules/game_skills/img/trainer", -- -1 quer dizer esta sem clan...
   [1] = "/modules/game_skills/img/volcanic",
   [2] = "/modules/game_skills/img/seavell",
   [3] = "/modules/game_skills/img/orebound",
   [4] = "/modules/game_skills/img/wingeon",
   [5] = "/modules/game_skills/img/malefic",
   [6] = "/modules/game_skills/img/gardestrike",
   [7] = "/modules/game_skills/img/psycraft",
   [8] = "/modules/game_skills/img/naturia",
   [9] = "/modules/game_skills/img/raibolt",
}

function init()
  connect(LocalPlayer, {
    onExperienceChange = onExperienceChange,
    onLevelChange = onLevelChange,
    onHealthChange = onHealthChange,
    onManaChange = onManaChange,
    onSoulChange = onSoulChange,
    onFreeCapacityChange = onFreeCapacityChange,
    onTotalCapacityChange = onTotalCapacityChange,
    onStaminaChange = onStaminaChange,
    onOfflineTrainingChange = onOfflineTrainingChange,
    onRegenerationChange = onRegenerationChange,
    onSpeedChange = onSpeedChange,
    onBaseSpeedChange = onBaseSpeedChange,
    onMagicLevelChange = onMagicLevelChange,
    onBaseMagicLevelChange = onBaseMagicLevelChange,
    onSkillChange = onSkillChange,
    onBaseSkillChange = onBaseSkillChange
  })
  connect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })
  connect(g_game, 'onTextMessage', getParams)
  connect(g_game, {onGameStart = changeImg})

  skillsButton = modules.client_topmenu.addCustomRightButton('skillsButton', tr('skills') .. ' (Ctrl+S)', '/modules/game_skills/img/perfil_icon', toggle, true)
  skillsButton:setOn(true)
  skillsWindow = g_ui.loadUI('skills', modules.game_interface.getRightPanel()) -- skills

  g_keyboard.bindKeyDown('Ctrl+S', toggle)

  refresh()
  skillsWindow:setup()
end

function terminate()
  disconnect(LocalPlayer, {
    onExperienceChange = onExperienceChange,
    onLevelChange = onLevelChange,
    onHealthChange = onHealthChange,
    onManaChange = onManaChange,
    onSoulChange = onSoulChange,
    onFreeCapacityChange = onFreeCapacityChange,
    onTotalCapacityChange = onTotalCapacityChange,
    onStaminaChange = onStaminaChange,
    onOfflineTrainingChange = onOfflineTrainingChange,
    onRegenerationChange = onRegenerationChange,
    onSpeedChange = onSpeedChange,
    onBaseSpeedChange = onBaseSpeedChange,
    onMagicLevelChange = onMagicLevelChange,
    onBaseMagicLevelChange = onBaseMagicLevelChange,
    onSkillChange = onSkillChange,
    onBaseSkillChange = onBaseSkillChange
  })
  disconnect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })
  disconnect(g_game, 'onTextMessage', getParams)
  disconnect(g_game, {onGameStart = changeImg})
  g_keyboard.unbindKeyDown('Ctrl+S')
  skillsWindow:destroy()
  skillsButton:destroy()
end

function onHealthChange(localPlayer, health, maxHealth, percent)
  setSkillValue('health', health)
  checkAlert('health', health, maxHealth, 30)
  setSkillPercent('health', (health * 100)/maxHealth, "")
end
 
Back
Top