New event onDamageEventCancelled #4384
Open
+181
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new event:
onDamageEventCancelled
.resourceName - The name of the resource in which the event was cancelled.
The event is triggered when a client cancels (via
cancelEvent
) events such asonClientPedDamage
,onClientPlayerDamage
, andonClientVehicleDamage
.The source of the event is the source of the packet, i.e. the client where the event was cancelled.
1. Why?
It’s meant to help fight cheats related to godmode. Cheaters using executors either call
setElementHealth
on the localPlayer (for example inonClientRender
- this soon can be blocked through PR #4376), or they cancel damage events such asonClientPedDamage
oronClientPlayerDamage
. I’m not entirely sure whether this event will be useful for vehicles - if not, it can be removed fromonClientVehicleDamage
.2. Unnecessary packet sending / event flood
That’s why there’s an interval - one packet per second. This interval can be increased if one second is too short. The goal is mainly to prevent massive spam, e.g. when a player is on fire and takes constant damage. In one “cycle” of burning, the event is triggered exactly six times with the current interval. Maybe it should be increased?
For the same reason, the event is not triggered while a player is drowning. When oxygen drops to zero, the game attempts to subtract HP every frame, which would otherwise cause event flooding and unnecessary packet spam.
3. This doesn’t solve the problem
That’s true - this is not a direct fix for cheats. But we need to take into account that a huge portion of cheats aren’t memory modifications. They’re malicious Lua code executed through Lua executors. That’s exactly what cheaters use to modify vehicle handling, weapon properties, or to enable godmode.