GetGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Minor fix)
No edit summary
Line 18: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function getGravityLevel( playerSource )
function getGravityLevel( playerSource )
     local gravity = getGravity()
     local gravity = getGravity ( )
     outputConsole ( "The gravity is currently set to "..gravity, playerSource )
     outputConsole ( "The gravity is currently set to " .. gravity, playerSource )
end
end
-- attach the 'getGravityLevel' function to the "gravity" command
-- attach the 'getGravityLevel' function to the "gravity" command
addCommandHandler ( getGravityLevel, "gravity" )
addCommandHandler ( "gravity", getGravityLevel )
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 18:32, 19 August 2007

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

Syntax

Click to collapse [-]
Server and Client
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

Shared