[Release] ev-hud | Customizable Standalone HUD

Remove all the code in here that’s inside the esx_status event handler.

Replace it with the following at the if state == 'esx' then

AddEventHandler("esx_status:onTick", function(status)
	for _, v in pairs(status) do
		if v.name == 'hunger' then hunger = v.percent
		elseif v.name == 'thirst' then thirst = v.percent
		elseif Config.useStress and v.name == 'stress' then stress = v.percent
		end
	end
end)

CreateThread(function()
    while true do
    		if IsPauseMenuActive() and not isPaused then
			isPaused = true
			SendNUIMessage({action = "isPaused"})
		elseif not IsPauseMenuActive() and isPaused then
			isPaused = false
			SendNUIMessage({action = "notPaused"})
		end
		local ped = PlayerPedId()
		local player = PlayerId()
		if NetworkIsPlayerTalking(player) and not isTalking then
			isTalking = true
			SendNUIMessage({
				action = 'talking',
				talking = true
			})
		elseif not NetworkIsPlayerTalking(player) and isTalking then
			isTalking = false
			SendNUIMessage({
				action = 'talking',
				talking = false
			})
		end
		local minutes, hours = GetClockMinutes(), GetClockHours()
		if minutes <= 9 then minutes = '0' .. minutes end
		if hours <= 9 then hours = '0' .. hours end
		SendNUIMessage({
			action = "hud",
			health = not IsEntityDead(ped) and math.ceil(GetEntityHealth(ped) - 100) or 0,
			armor = GetPedArmour(ped),
			stamina = math.ceil(100 - GetPlayerSprintStaminaRemaining(player)) or 100,
			hunger = hunger or 0,
			thirst = thirst or 0,
			stress = stress or 0,
			oxygen = GetPlayerUnderwaterTimeRemaining(player) * oxygenMultiplier,
			id = GetPlayerServerId(player),
			players = #GetActivePlayers() * 100 / Config.maxPlayers,
			time = hours .. ":" .. minutes
		})
        Wait(Config.waitTime)
    end
end)

That should work?

Thanks for the help.
I just tried that and appears to break the onTick event, so the hud isn’t working correctly.

Oh yeah, I forgot about the status lmao.
Put this at before the thread just like the message I edited above.

	AddEventHandler("esx_status:onTick", function(status)
		for _, v in pairs(status) do
			if v.name == 'hunger' then hunger = v.percent
			elseif v.name == 'thirst' then thirst = v.percent
			elseif Config.useStress and v.name == 'stress' then stress = v.percent
			end
		end
	end)

Just copy all the code from the message I sent first.

1 Like

Thank you! That did the trick :grinning:

Hi mate! I got the version with the hunger en thirst icon but somethimes when players are loading in the server they are dead because they have somethimes nog hunger en thirst or like 5% how can i fix this.

Could you show me a video of the issue in particular?

Yesh offcource mate

I don’t see how that could be related to the hud. The hud only displays the hunger/thirst, it does not change it.

Thats strange because i update the esx_status en add youre hud and than this problem apears. so it is the hud or the esx_status that you suggest to download! Thanks for replaying to me and i hope you found something!

Weird. I’ll see if I can find something but the hud definitely should not be affecting the status.

Can i send you my files in a dm? Maby you can see whats wrong

Well mate i have fixed it but now inhave another problem with it. When people go out game and come back like 6 hours later their food and water is gone only water has like 15% left. Can i fix this? Greetz

Tbh, I have no idea why that would happen. As I mentioned before, the hud is using the esx status event which does not actually change the status.

Do you Think its the esx_status? Do you have again the good one for me?

its not a “framework” its just a character manager

Since FiveM was down its not working (error in 291 js script i think)

Script loading way to early, any change I can delay it until the player spawns?

You can use that branch. The only thing is that you would need to implement the export yourself.

1 Like