Difference between revisions of "SetGravity"

From Multi Theft Auto: Wiki
 
(5 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
{{Server client function}}
 
{{Server client function}}
 
This function sets the server's gravity level.
 
This function sets the server's gravity level.
 
+
{{Note|
'''Note:''' that this does not effect peds/players; to set ped/player gravity use [[setPedGravity]].
+
*This will override [[setPedGravity]] applied to peds/players.
 +
*Setting the gravity level to different values on clients can cause animation bugs (players floating across ground because players see different fall animation.)}}
  
 
==Syntax==
 
==Syntax==
Line 17: Line 18:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
function grav ( sourcePlayer, command, level )
 
function grav ( sourcePlayer, command, level )
 +
    local level = tonumber(level)
 +
    if (not level) then return end
 
     setGravity ( tonumber(level) )
 
     setGravity ( tonumber(level) )
 
end
 
end

Latest revision as of 10:37, 8 May 2020

This function sets the server's gravity level.

[[{{{image}}}|link=]] Note:
  • This will override setPedGravity applied to peds/players.
  • Setting the gravity level to different values on clients can cause animation bugs (players floating across ground because players see different fall animation.)

Syntax

bool setGravity ( float level )

Required Arguments

  • level: The level of gravity (default is 0.008).

Returns

Returns true if gravity was changed, false otherwise.

Example

function grav ( sourcePlayer, command, level )
    local level = tonumber(level)
    if (not level) then return end
    setGravity ( tonumber(level) )
end
addCommandHandler ( "setgravity", grav )

See Also