boro Posted August 15, 2014 Share Posted August 15, 2014 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
boro Posted August 15, 2014 Author Share Posted August 15, 2014 ? I have defined team in line 2 Link to comment
Et-win Posted August 15, 2014 Share Posted August 15, 2014 local team = getTeamFromName ( Team1 ) Where is Team1 defined? Link to comment
Backsage Posted August 19, 2014 Share Posted August 19, 2014 I think you need to put Team 1 in quotation marks, otherwise, it doesn't read the team. If not that, then "Team 1" probably isn't defined. Link to comment
Moderators IIYAMA Posted August 20, 2014 Moderators Share Posted August 20, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now