Sign in to follow this  
ArcAngeL

Zombie health bar

Recommended Posts


local sX,sY = guiGetScreenSize()
local sX,sY = sX*0.05,sY*0.95

font = "default-bold"

function healthbar()
	local plr = localPlayer
	for k, pedsz in pairs(getElementsByType("ped", root, true)) do
	if getElementData(pedsz, "zombie") then
	target = getPedTarget(plr)
	if (not target) then
		return false
	end
	if (not getElementType(target) == "ped" ) then
		return false
	end
	if (not isElementOnScreen(pedsz)) then
		return false
	end
	dxDrawText("Zombie", sX+460, sY-627, sX+155, sY-19-(32*7), tocolor(0,0,0, 255), 1.5, font, "left", "top")
	dxDrawText("Zombie", sX+461.5, sY-625.5, sX+153.5, sY-17.5-(32*7), tocolor(204, 204, 204, 255), 1.5, font, "left", "top")
	
	local healthA = dxDrawRectangle(sX+420, sY-600,150, 12, tocolor(241, 236, 253, 114), false)
    local health = getElementHealth(pedsz)
	local lineLength = 100 * (health / 100)
	local healthB = dxDrawRectangle(sX+423, sY-597,lineLength, 7, tocolor(9, 172, 213, 254), false)
	end           
end
end
addEventHandler("onClientRender", root, healthbar)

Hello All,

its simple zombie health bar codes.dxDrawText and dxDrawRectangle look successful.but zombie is losing health but,health bar is doesnt go down :/ sometimes even when ı aim at the zombies,health bar does not appear :( what can ı do for it ? Can my math. be wrong ? 

 

 

 

 

Edited by ArcAngeL

Share this post


Link to post
21 minutes ago, ArcAngeL said:

I mean zombie is losing health but ,health bar does not go down :/

It has to work.
Health is probably stored in elementData so getElementHealth() always returns 100

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.