boro Posted August 15, 2014 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) I'll help When I Can.
boro Posted August 15, 2014 Author Posted August 15, 2014 ? I have defined team in line 2 I'll help When I Can.
Et-win Posted August 15, 2014 Posted August 15, 2014 local team = getTeamFromName ( Team1 ) Where is Team1 defined? ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Backsage Posted August 19, 2014 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.
Moderators IIYAMA Posted August 20, 2014 Moderators 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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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