GetGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
{{Server client function}}
This function returns the current gravity level
This function returns the current gravity level for the context in which it is called (server or client).


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">getGravity ()</syntaxhighlight>
<syntaxhighlight lang="lua">
float getGravity()
</syntaxhighlight>
 
===Returns===
Returns a float with the current server or client (depending on where you call the function) gravity level.


==Example==
==Example==
<syntaxhighlight lang="lua">addCommandHandler ( "gravity", "gravlevel" )
<section name="Server" class="server" show="true">
function gravlevel ()
This serverside command outputs the serverside gravity level.
<syntaxhighlight lang="lua">
function getGravityLevel( playerSource )
     local gravity = getGravity ( )
     local gravity = getGravity ( )
     outputConsole ( "The Gravity is currently set to " ..gravity )
     outputConsole ( "The gravity is currently set to " .. gravity, playerSource )
end</syntaxhighlight>
end
-- attach the 'getGravityLevel' function to the "gravity" command
addCommandHandler ( "gravity", getGravityLevel )
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{World functions}}
{{World functions}}
[[ru:getGravity]]

Latest revision as of 09:53, 7 March 2010

This function returns the current gravity level for the context in which it is called (server or client).

Syntax

float getGravity()

Returns

Returns a float with the current server or client (depending on where you call the function) gravity level.

Example

Click to collapse [-]
Server

This serverside command outputs the serverside gravity level.

function getGravityLevel( playerSource )
    local gravity = getGravity ( )
    outputConsole ( "The gravity is currently set to " .. gravity, playerSource )
end
-- attach the 'getGravityLevel' function to the "gravity" command
addCommandHandler ( "gravity", getGravityLevel )

See Also