fivem icon indicating copy to clipboard operation
fivem copied to clipboard

SetHealthHudDisplayValues does nothing or corrupts the health bar

Open mcNuggets1 opened this issue 9 months ago • 6 comments

What happened?

There is no real documentation of SetHealthHudDisplayValues. I found two seperate ways of using it. None of it works.

SetHealthHudDisplayValues(100, 100, false) Does nothing. Tried this: SetMaxHealthHudDisplay(1000) Des nothing. Tried with floats, instead of numbers, that just made the bar go invisible.

The only documentation I found told me, that the native only needs to be called once and then needs to be undone with setting health to -1. None of that besides resetting health to -1 works.

Expected result

It would change the value to the specified

Reproduction steps

SetHealthHudDisplayValues(40, 100, false)

Importancy

Unknown

Area(s)

FiveM, FXServer, FxDK, OneSync, Natives

Specific version(s)

FiveM b3095

Additional information

No response

mcNuggets1 avatar May 14 '24 15:05 mcNuggets1

I believe you may alternatively directly call functions on the minimap scaleform to achieve something similar, e.g. SET_PLAYER_HEALTH: https://vespura.com/fivem/scaleform/#MINIMAP

AdrianIsBored avatar May 14 '24 23:05 AdrianIsBored

This native looks like some kind of override as I tried taking damage after using the native, and my HP stayed the same under the minimap. I believe this native is not achieving the described goal.

After testing, it looks like it just makes the health bar red if the first argument is not -1. And makes the health bar green again after passing -1 as the first argument. The second parameter and the boolean have no impact at all on this native.

Mathu-lmn avatar May 15 '24 20:05 Mathu-lmn

This native is for overriding visual health on the healtbar apparently, it doesn't really do that however.

And yeah the only function it has, is to seemingly bug out the healthbar.

mcNuggets1 avatar May 16 '24 09:05 mcNuggets1

Yeah I first wrote what the native was "supposed" to do hahah And yeah the only usage is to make the health bar red or green. I think it's worth opening a thread on the forums for such issue

Mathu-lmn avatar May 16 '24 10:05 Mathu-lmn

function UpdateHealthbar(minimapScaleform) local health = GetLocalPlayerHealth()

BeginScaleformMovieMethod(minimapScaleform, "SET_PLAYER_HEALTH")
ScaleformMovieMethodAddParamInt(health)

if lastHealth > health then -- Was added?
	ScaleformMovieMethodAddParamBool(true)
else
	ScaleformMovieMethodAddParamBool(false)
end

local gameTimer = GetGameTimer()
if lastMaxHealthUpdate < gameTimer then
	lastMaxHealthUpdate = gameTimer
	maxHealth = GetLocalPlayerMaxHealth()
end

ScaleformMovieMethodAddParamInt(maxHealth)

if GetLastDamageTime() > lastDamageDrawn then -- Show hurt damage
	lastDamageDrawn = GetLastDamageTime()
	ScaleformMovieMethodAddParamBool(true)
else
	ScaleformMovieMethodAddParamBool(false)
end

EndScaleformMovieMethod()

end

I did follow your advice and finally got dis stuff working. I hope you dont mind my extra code I didn't remove.

mcNuggets1 avatar May 16 '24 10:05 mcNuggets1

This is taking up a lot of performance however. A setter would be better.

mcNuggets1 avatar Jun 04 '24 11:06 mcNuggets1