Skip to content

feat(client/graphics): add FPS limit convar - #4016

Open
xalva98 wants to merge 1 commit into
citizenfx:masterfrom
xalva98:fpslimit
Open

feat(client/graphics): add FPS limit convar#4016
xalva98 wants to merge 1 commit into
citizenfx:masterfrom
xalva98:fpslimit

Conversation

@xalva98

@xalva98 xalva98 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Goal of this PR

Adds a native client-side FPS limit convar for FiveM.

This allows users to cap their game FPS without relying on external driver/game overlay limiters.

Use case: Some racing servers tell users to cap their FPS so it can still be a competetive environment (Higher FPS usually means more vehicle speed).
Having a simple console command is easier than telling users to change NVIDIA settings for example.

How is this PR achieving the goal

Adds the archived game_fpsLimit convar, defaulting to 0 / disabled.

When set to a positive value, the DirectX present path uses the existing frame-time limiter to wait until the configured frame interval has elapsed before presenting the next frame.

Values are clamped to a sane range to avoid accidentally setting unusably low or excessively high limits.

This PR applies to the following area(s)

FiveM, Client, Graphics

Successfully tested on

Game builds: bXXXX

Platforms: Windows

Checklist

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

Fixes issues

PS: Thanks to Gogsi for the hint

@github-actions github-actions Bot added the triage Needs a preliminary assessment to determine the urgency and required action label Jun 2, 2026
@AvarianKnight

Copy link
Copy Markdown
Contributor

Can you not use a uint8_t instead of an int so then you don't have to use the checks? Also iirc there's constraints you can put on convars so you don't have to do any clamping

@github-actions github-actions Bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Jun 2, 2026
@xalva98

xalva98 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Can you not use a uint8_t instead of an int so then you don't have to use the checks? Also iirc there's constraints you can put on convars so you don't have to do any clamping

I agree with using unsigned and I'll check out the constraints 👍 However I think uint16_t might be better cause some people might actually want 255+ fps.

@WLVF

WLVF commented Jun 2, 2026

Copy link
Copy Markdown

Would be huge to get this in for racing servers!

@xalva98

xalva98 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@AvarianKnight
I've looked it up and it seems like we could do

gameFpsLimit.GetHelper()->SetConstraints(0, 1000);

But this would also mean values below 30 are possible, I don't think this is good as this could brick the game for some people so we can't really get around that clamp IMO.

@AvarianKnight

Copy link
Copy Markdown
Contributor
SetConstraints

Why would you set it to 0 instead of 30? The first argument is meant to be the smallest amount

@xalva98

xalva98 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

So you can still reset it by using 0

@AvarianKnight

Copy link
Copy Markdown
Contributor

So you can still reset it by using 0

Ahh, yea then there is no way getting around that.

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.

3 participants