Jump to content

Team Healthbar


boro

Recommended Posts

Hi i make dxdravrectangle bar for team but this dont work why? please help me

function showteamhealth ( ) 
local team = getTeamFromName ( Team1 ) 
for i, player in ipairs(getPlayersInTeam(team)) do 
    local sWidth,sHeight = guiGetScreenSize() 
    local Width = sWidth-400 
    local health = health + getElementHealth(player) 
    local HealthBar = sWidth*( -health / Width ) 
    dxDrawRectangle(sWidth*0.79,sHeight*0.072,HealthBar,sHeight*0.03,tocolor(255,0,0,250) ,false) 
end 
end 
addEventHandler("onClientRender", getRootElement(), showteamhealth) 

Link to comment
  • Moderators

Try this:

  
local sWidth,sHeight = guiGetScreenSize() 
local teamHealthBarColor = tocolor(255,0,0,250) 
local teamHealthBarWidth = sWidth - sWidth*0.79 
  
local showteamhealth = function ( ) 
    local team = getPlayerTeam(localPlayer) 
    if team then  
        local health = 0 
        local players = getPlayersInTeam(team) 
        for i=1,#players do 
            health = health + getElementHealth(players[i]) 
        end 
        local HealthBar = teamHealthBarWidth*( health / (#players*100) ) 
        dxDrawRectangle(sWidth*0.79,sHeight*0.072,HealthBar,sHeight*0.03,teamHealthBarColor ,false) 
    end 
end 
addEventHandler("onClientRender", root, showteamhealth) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...