Wandering around with player’s health, I found out that if you have the female multiplayer model, you have a max health of 175 (from 100 to 75 so actually only 75 health, I don’t know why yet) and if you have a male multiplayer model you now have a max health of 200. So I made a little script to fix that :
local ped = GetPlayerPed(-1)
if GetPedMaxHealth(ped) ~= 200 and not IsEntityDead(ped) then
SetEntityHealth(ped, GetEntityHealth(ped) + 25)
I put it in my gamemode, and it works as expected.
I’m not sure it will work 100% of the time. You have to use ped not entity max health.
And before you start adding 25 health, off the top of my head I’d probably check IsPedFatallyInjured, IsEntityDead, IsPedProne. Putting it in the spawnmanager.lua and setting everyone spawning to max 200 would probably be safe (use ped not entity max health of course).
And of course, it’s not really sexism. The average female can take less punches then the average male. Height, weight, muscle mass? So if you want to make it unrealistic, then of course set everyone to 200.
I also thought about that, but I tested a lot of damage types and it still works fine since from 0 to 100 changes nothing. After some testing the player does have 25/200 health if my code happens after the player death. I changed my post with new code to fix that.
I now check if the player is dead, because as said above, it does add 25 health to the player, even dead. Thanks !
The code I have is only the health part, I’m actually using it in a playerSpawned event as @Rubidium said.
I don’t agree with you but it’s not a debate to have on the FiveM forum I see this as game design, it doesn’t feel right to have players with less health x)
Changing the model on the go and not respawning will not trigger playerSpawned (obv) so you’ll have to reapply the code for it to have an effect, since changing model also changes max health. I personally have a modelChanged event that is triggered on every model change (duh).
I hate that event shit, it’s unreliable. Everyone should write their own spawn manager anyway and take out the fivem_client.lua call (exports.spawnmanager:forceRespawn() which shouldn’t even be there really). Notice how a really important first spawn doesn’t use events? So if CitizenFX doesn’t trust events, why exactly should we? I’ve seen so much code chained to events across different resources, it’s a nightmare. You shouldn’t really be adding on random code at the end of the spawnPlayer function. The spawnPlayer function should spawn the player, and do everything that’s needed. Instead you have to search through the spawnPlayer events and see what random code is also attached on god knows what resource. Having spawnPlayer code in 2-3-4-5+ files is a cluster fuck, it should be in 1 spot only, and if you need to make changes, change the function not slap on extra code un-doing model changes or health changes or position changes that make debugging a pain in the ass. The event system was created because its easy for newbies and stops them from changing core code, but that doesn’t mean its a good idea or the best way, it’s easy, that’s it.