Skip to content

Conversation

@Gogsi
Copy link
Contributor

@Gogsi Gogsi commented Aug 28, 2025

Goal of this PR

The goal of this PR is to fix #3079. The issue is caused by calling TerminateThread() with a threadId occupied by a script started by the pause menu. In Singleplayer and GTAO, certain pause menu tabs may stream in and start additional scripts/threads to fill in dynamic content. For example to handle clicking on race/deathmatch join blips on the map, or fill in the mission objective in the GAME tab. See pausemenu.xml, looking for <type>SCRIPT</type>.

As you cannot stream pausemenu.xml, this feature is entirely unused in FiveM (outside of Story Mode) but the scripts are still started and can cause issues.

How is this PR achieving the goal

  1. Disable the starting and updating of pause menu scripts outside of Story Mode
  2. Prevent the use of TerminateThread() and TerminateThisThread() outside of Story Mode, as they only work for .ysc scripts, are not intended to be used in FiveM, and can cause issues with script registration.

See https://forum.cfx.re/t/terminatethisthread-not-working-at-all/788684/2 and other threads on the forum about these natives.

This PR applies to the following area(s)

FiveM

Successfully tested on

Pattern checked statically on all supported FiveM builds.

Game builds: 3095, 3258, 3407 in both a server (disabled) and in Story Mode (enabled)

Platforms: Windows,

Checklist

  • [x ] Code compiles and has been tested successfully.
  • [x ] Code explains itself well and/or is documented.
  • [x ] My commit message explains what the changes do and what they are for.
  • [x ] No extra compilation warnings are added by these changes.

Fixes issues

#3079

Gogsi added 2 commits August 28, 2025 22:50
… threads.

In Singleplayer and GTAO, certain pause menu tabs may stream in and start additional scripts/threads to fill in dynamic content. For example to handle clicking on race/deathmatch join blips, or fill in the mission objective in the GAME tab.

However bad script containing calls such as `TerminateThread(0)` as described in citizenfx#3079, often end up killing these scripts, causing the game to crash the next time it's paused. Since this functionality is completely unused in FiveM, might as well patch it out.
…E_THIS_THREAD outside of SP

These natives can cause problems with the registration of CfxThread and GtaThread
@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Game crashing on pause

1 participant