[HELP] [ESX] How to add notification when a user lose health

Hi, i’m trying to add a notification when a user have low health. For example if somebody has 50 or lower health it will show notification that you are bleeding and need help or need to go to Hospital, something like this: [HELP] ESX_STATUS Modification doesn't work but that is notification for hunger and thirst and i have set that up and it works but i dont know how to set up this. If somebody can help me i would appreciate it. :slight_smile:

Hi, you can try this code and modify it according to your requirements

ESX = exports["es_extended"]:getSharedObject()

Citizen.CreateThread(function()
    local isBleedingNotified = false
    while true do
        Citizen.Wait(1000) -- Check every second
        local playerPed = PlayerPedId()
        local health = GetEntityHealth(playerPed)
        
        if health <= 50 and not isBleedingNotified then
            ESX.ShowNotification('You are bleeding and need medical attention. Go to the nearest hospital!')
            isBleedingNotified = true
        elseif health > 50 then
            isBleedingNotified = false
        end
    end
end)


1 Like

Thank you so much, its working! But i edited it like this and still works so if someone wants to use it then better like this because it will every 50 seconds notify player that he is bleeding and needs medical attention.

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(50000) -- Check every 50 seconds
		local playerPed = PlayerPedId()
		local health = GetEntityHealth(playerPed)
		if health <= 165 then -- 65 Health or lower
			ESX.ShowNotification('You are bleeding and need medical attention. Go to the nearest hospital!')
        end
	end
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.