SetFPSLimit: Difference between revisions
Jump to navigation
Jump to search
m (Making it work) |
|||
Line 17: | Line 17: | ||
This command sets the fps limit in a command handler. | This command sets the fps limit in a command handler. | ||
<syntaxhighlight lang="lua">function fpsFunction( player, command, limit ) -- First define the function | <syntaxhighlight lang="lua">function fpsFunction( player, command, limit ) -- First define the function | ||
if hasObjectPermissionTo ( player, "function.setFPSLimit" ) and limit then | if hasObjectPermissionTo ( player, "function.setFPSLimit" ) and tonumber(limit) then | ||
-- If the player has permission to set FPS limit and limit is submitted... | -- If the player has permission to set FPS limit and limit is submitted... | ||
setFPSLimit ( limit ) -- Set the fps. | setFPSLimit ( tonumber(limit) ) -- Set the fps. | ||
end | end | ||
end | end | ||
Line 30: | Line 30: | ||
addCommandHandler ( "setfps", function ( player, command, limit ) | addCommandHandler ( "setfps", function ( player, command, limit ) | ||
if ( hasObjectPermissionTo ( player, "function.setFPSLimit" ) ) then | if ( hasObjectPermissionTo ( player, "function.setFPSLimit" ) ) then | ||
setFPSLimit ( limit ) | setFPSLimit ( tonumber(limit) or 0 ) | ||
end | end | ||
end ) | end ) |
Revision as of 20:24, 26 May 2011
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. This value may be between 25 and 100 FPS. You can also pass 0 or false, in which case the FPS limit will be disabled.
Returns
Returns true if successful, or false if it was not possible to set the limit or an invalid value was passed.
Example
This command sets the fps limit in a command handler.
function fpsFunction( player, command, limit ) -- First define the function if hasObjectPermissionTo ( player, "function.setFPSLimit" ) and tonumber(limit) then -- If the player has permission to set FPS limit and limit is submitted... setFPSLimit ( tonumber(limit) ) -- Set the fps. end end addCommandHandler ( "setfps", fpsFunction ) -- Attach the setfps command to fpsFunction function.
This one does the same, just shorter.
addCommandHandler ( "setfps", function ( player, command, limit ) if ( hasObjectPermissionTo ( player, "function.setFPSLimit" ) ) then setFPSLimit ( tonumber(limit) or 0 ) end end )
See Also
- getMaxPlayers
- getServerConfigSetting
- getServerHttpPort
- getServerName
- getServerPassword
- getServerPort
- isGlitchEnabled
- setGlitchEnabled
- setMaxPlayers
- setServerConfigSetting
- setServerPassword
- shutdown