altv-issues icon indicating copy to clipboard operation
altv-issues copied to clipboard

Add player and vehicle "heal" events

Open TheGodlyLuzer opened this issue 3 years ago • 6 comments
trafficstars

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

TheGodlyLuzer avatar Jul 31 '22 22:07 TheGodlyLuzer

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
})

CsokiHUN avatar Aug 01 '22 05:08 CsokiHUN

Would also add a damage type to it. Player armor, vehicle engine / body health.

xLuxy avatar Aug 01 '22 09:08 xLuxy

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.

FabianTerhorst avatar Aug 01 '22 09:08 FabianTerhorst

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);

xLuxy avatar Aug 01 '22 09:08 xLuxy

there are more then 10 different vehicle health values. Will think about how to do it properly at some point.

FabianTerhorst avatar Aug 01 '22 09:08 FabianTerhorst

We don't know the damager in most cases and it would return the old damager on health increase.

FabianTerhorst avatar Aug 01 '22 10:08 FabianTerhorst