Health to the maximum when you leave and enter the server

Hello, I have a very important question… I have noticed that when a user restarts (that is, he leaves and enters the server) his life regenerates to 100%. Is there any way to fix it? Is it because of my version of esx_basicneeds or something similar? Is there a way to save, for example, the life that the user had in the database so that it does not restart or some good version of esx_basicneeds?

You are talking about the peds health, right?

Default behavior (simplified): Player joins, ped is getting created with full life.
So of course, everytime someome leaves and rejoins will have full life again.

However, if you wish to save the health of the ped everytime the player leaves you’ll need to keep track of it by yourself, for instance using an already existing script or making one by yourself.


It’s basic functionality should have following workflow:

player leaves → retrieve his ped → retrieve the peds health → save in your database of choice

player joins → wait until he got spawned (i.e: using esx events) → retrieve his freshly spawned ped → set the previously saved health (and/or armor)


Some script I found while searching (maybe you can find something else or make yourself something else): GitHub - NotBad5/notbad-save-health-armour: Simple script coded in lua for FiveM, saves health and armour when disconnecting and sets health and armour when connecting


If you have any further questions feel free to ask. I hope I could help you!

Thx, I wanna test it

Dont work for me but I can try other scripts

EDIT: Maybe I talked soo fast, I think this work but the multichard is incompatible cause heal the player on the character select

You need to trigger your events later then, specifically after some “character fully selected and spawned and the person is playing the game now” event.

Dont work with that, if I use this the player spawn all time with full hp :frowning: sad