ArcAngeL Posted December 6, 2019 Share Posted December 6, 2019 (edited) 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 December 6, 2019 by ArcAngeL Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 https://wiki.multitheftauto.com/wiki/IsPedDead if getElementData(pedsz, "zombie") and not isPedDead(pedsz) then ... end Link to comment
ArcAngeL Posted December 6, 2019 Author Share Posted December 6, 2019 13 minutes ago, stPatrick said: https://wiki.multitheftauto.com/wiki/IsPedDead if getElementData(pedsz, "zombie") and not isPedDead(pedsz) then ... end I mean zombie is losing health but ,health bar does not go down Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 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 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