mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Add Crash Detection to 'onPlayerQuit' Event

Open fhostings opened this issue 7 months ago • 7 comments

Is your feature request related to a problem? Please describe.

Currently, the onPlayerQuit event does not provide any crash-related information when a player’s game crashes. This makes it difficult for server owners to track client-side crashes and diagnose potential issues.

I propose adding a way to detect when a player crashes and retrieve the crash code and offset directly from onPlayerQuit.

Describe the solution you'd like

I would like the onPlayerQuit event to detect when a player crashes and provide additional details, such as the crash code and memory offset. Currently, onPlayerQuit does not differentiate crashes from other quit reasons, making it difficult to diagnose client-side issues.

My suggestion is to modify onPlayerQuit to include extra parameters when the quit type is "Crash", allowing server owners to log crash details for debugging.

Example implementation:

addEventHandler("onPlayerQuit", root, function(quitType, crashCode, crashOffset)
    if quitType == "Crash" then
        outputDebugString("Player crashed! Code: " .. tostring(crashCode) .. " Offset: " .. tostring(crashOffset))
    end
end)
  • crashCode: The error code (e.g., 0xC0000005).
  • crashOffset: The memory offset where the crash occurred (e.g., @ 0x004F3A2B).

This feature would significantly improve crash tracking and troubleshooting without requiring external debugging tools.

Describe alternatives you've considered

One alternative could be implementing a separate event, such as onPlayerCrash, which would trigger only when a player crashes. This event could provide the crash code and memory offset without modifying onPlayerQuit.

Example usage:

addEventHandler("onPlayerCrash", root, function(crashCode, crashOffset)
    outputDebugString(getPlayerName(source) .. " crashed! Code: " .. tostring(crashCode) .. " Offset: " .. tostring(crashOffset))
end)

This approach would keep crash handling separate from normal quit events, making it easier to manage crash-specific logic. However, integrating this directly into onPlayerQuit may be more efficient and require fewer changes to existing scripts.

Additional context

No response

Security Policy

  • [x] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.

fhostings avatar Mar 10 '25 02:03 fhostings