SetFPSLimit: Difference between revisions
(Update example.) |
(Update example yet again.) |
||
Line 48: | Line 48: | ||
end | end | ||
local | local currentLimit = getFPSLimit() | ||
local setNewFPS = (newFPS ~= currentLimit) | |||
if | if setNewFPS then | ||
outputChatBox("Your FPS has been limited to: "..newFPS..".") | outputChatBox("Your FPS has been limited to: "..newFPS..".") | ||
setFPSLimit(newFPS) | |||
end | end | ||
end | end |
Revision as of 21:56, 22 May 2023
This function sets the maximum FPS (Frames per second) that players on the server can run their game at.
Syntax
bool setFPSLimit ( int fpsLimit )
Required Arguments
- fpsLimit: An integer value representing the maximum FPS. Refer to the note above for possible values. You can also pass 0 or false, in which case the FPS limit will be the one set in the client settings (by default, 100 FPS and the client fps limit should also be manually changed via "fps_limit=0" in console or MTA San Andreas 1.5\MTA\config\coreconfig.xml).
Returns
Returns true if successful, or false if it was not possible to set the limit or an invalid value was passed.
Issues when increasing FPS
Note: with "very high" FPS, any FPS limit over 74 is meant. It is recommended to set a conservative FPS limit (between 40-60 and 74 highest) because high FPS can break some GTA internal calculations, causing various bugs. The higher the FPS the more of a problem these become:
74 FPS is the breaking point that opens the door to various more severe GTA bugs related to FPS and physics.
- Physics of vehicles is effected, both high and low FPSes may bring their own set of unfair advantages. Speaking about the consequences of high FPS in this context, up to 70 or 74 FPS is considered safe (as any differences in physics, if they do exist to begin with as they theoretically should, are so tiny that they are unmeasurable and thus wouldn't affect racing results in practise). Anything beyond 74 FPS may cause impactful discrepancies.
- Pressing the horn button to turn on and off sirens gets really hard at very high FPS. For instance, at 100 FPS, you are more likely to hit the regular horn 3 times (inconsistent) before eventually triggering the siren, besides taking a similar amount of tries to turn off the siren.
- At very high FPS, climbing over certain objects will result in instant death. Example at: 2520.108, -1681.407, 19.406, 266
- The higher your FPS, the more of a penalty in satchel throwing distance (up to ~10% at very high FPS) will apply.
For a full list of FPS-related GTA bugs (that are much less likely to impact gameplay in a meaningful way) and MTA developers' progress in tackling them, see the Framerate issues tracker github project.
Example
This example allows players to limit their own FPS using a command.
local minFPS = 25 local maxFPS = 100 function fpsFunction(commandName, fpsLimit) local newFPS = tonumber(fpsLimit) local displaySyntax = (not newFPS) or (newFPS < minFPS) or (newFPS > maxFPS) if displaySyntax then outputChatBox("Syntax: /"..commandName.." ["..minFPS.." ~ "..maxFPS.."] - limit your own FPS.") return false end local currentLimit = getFPSLimit() local setNewFPS = (newFPS ~= currentLimit) if setNewFPS then outputChatBox("Your FPS has been limited to: "..newFPS..".") setFPSLimit(newFPS) end end addCommandHandler("limitfps", fpsFunction) addCommandHandler("fpslimit", fpsFunction)