Skip to content

Conversation

@MohabCodeX
Copy link
Contributor

@MohabCodeX MohabCodeX commented Sep 4, 2025

This PR fixes issues #2312 and #2273 where onPlayerWasted and onClientPlayerWasted events received inconsistent parameters when players died via setElementHealth or vehicle explosions.

Root Cause: Race condition between health RPC packets and client-side death events caused DoWastedCheck() to fire with stale damage data, resulting in inconsistent parameters between server and client death events.

Solution: Added client-side flag m_bServerProcessedDeath to prevent stale data usage and implemented dynamic weapon data retrieval.

Results
-- Client

function onClientPlayerWasted(...)
	local t = {...}

	iprint("Client: "..inspect(t))
end
addEventHandler("onClientPlayerWasted", root, onClientPlayerWasted)

-- Server

function onPlayerWasted(...)
	local t = {...}

	iprint("Server: "..inspect(t))
end
addEventHandler("onPlayerWasted", root, onPlayerWasted)
crun setElementHealth(localPlayer,"0")
[13:15:37] [debug] mark\client.lua:4 - "Client: { false, 0, 3, false, 0, 15 }"
[13:15:37] [debug] mark\server.lua:4 - "Server: { 0, false, 0, 3, false, 0, 15 }"

Vehicle Explosion

mark\client.lua:4 - "Client: { false, 51, 3, false, 0, 15 }"
mark\server.lua:4 - "Server: { 2972, false, 51, 3, false, 0, 15 }"

This also incidentally fixed an additional bug:

The inconsistent value of 63 that appeared when dying from a vehicle explosion. It was hardcoded and unrelated to the correct ID, which is 51. Please note that the information on the wiki will need to be updated accordingly. I will provide the full list of damage types later.

@MohabCodeX
Copy link
Contributor Author

This is likely to be backward-incompatible because of the explosion type ID change.

@Fernando-A-Rocha
Copy link
Contributor

Perfect fix for 1.7 😄

@FileEX FileEX added backwards-incompatible Should be merged after the release of 1.7.1 bugfix Solution to a bug of any kind labels Sep 4, 2025
@MohabCodeX MohabCodeX requested a review from FileEX September 5, 2025 11:42
@FileEX FileEX merged commit 0f01e5d into multitheftauto:master Sep 5, 2025
MTABot pushed a commit that referenced this pull request Sep 5, 2025
0f01e5d Death Event Parameters Synchronization Fix (#4418)
@FileEX FileEX added this to the 1.7.1 milestone Sep 5, 2025
@MohabCodeX MohabCodeX deleted the fix/onplayerwasted-wrong-params branch September 7, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards-incompatible Should be merged after the release of 1.7.1 bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants