Creation of a random wype system

Hello,
I would like to set up a “life” system on my server.

At the connection, we receive a random between 5 and 10 lives.
Each time we fall unconscious, it takes away 1 life.

Here is how I proceeded to connect to the server:

local healthv = math.random(5,10)
    MySQL.Async.execute("UPDATE users SET healthv = @healthv WHERE identifier = @user", {
		["@healthv"]		= healthv,
		["@user"]			= xPlayer.identifier,
	})

Every time someone dies, here’s what I did

RegisterNetEvent('esx_ambulancejob:death')
AddEventHandler('esx_ambulancejob:death', function(isDead)
	local xPlayer = ESX.GetPlayerFromId(source)

	
		MySQL.update('UPDATE users SET healthv = healthv - 1 WHERE identifier = ?', {xPlayer.identifier})
	
end)

But I would like to block each revive and give a notification to the paramedics but also to the players if the life = 0

I have to do this in the server.lua of esx_ambulancejob, but I don’t know how to go about it

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