altv-issues
altv-issues copied to clipboard
Add player and vehicle "heal" events
Description of the problem
It would be really useful to have events, when a vehicle's or player's health changes upwards.
This could prevent vehicles beeing repaired by cheaters or players being healed by cheaters.
Desired solution for the problem
Either add the health as "degative damage" to the damage events:
Beeing shot -> 100DMG
Beeing healed -> -100DMG
Or add 2 new events for player/vehicle heal.
Alternatives you considered
No response
Additional context
No response
Version
No response
I think this can be done with an event
entityHealthChange
Example:
alt.on('entityHealthChange', (entity: alt.Entity, value: number, old: number) => {
//value represents a new value
//old value from which it changed
})
Would also add a damage type to it. Player armor, vehicle engine / body health.
We also know the player that changed the health btw. But i don't think a generic event that catches everything is a good api design.
We also know the player that changed the health btw. But i don't think a generic event that catches everything is a good api design.
Maybe the following API would be better?
alt.on('playerRestoreHealth', (player: alt.Player, hp: number, armor?: number) => void);
alt.on('vehicleRestoreHealth', (player: alt.Player, type: 'engine' | 'body', value: number) => void);
Updated damage events (when possible)
alt.on('playerDamage', (player: alt.Player, damager: alt.Entity, bodyPart: number, lostHP: number, lostAP?: number) => void);
alt.on('vehicleDamage', (vehicle: alt.Vehicle, damager: alt.Entity, type: 'body' | 'engine', loss: number) => void);
And if alt:V is able to detect damage done to NPCs:
alt.on('pedDamage', (pedScriptId: number, damager: alt.Entity, bodyPart: number, lostHP: number, lostAP?: number) => void);
there are more then 10 different vehicle health values. Will think about how to do it properly at some point.
We don't know the damager in most cases and it would return the old damager on health increase.