SetPlayerGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 20: Line 20:
function consoleSetPlayerGravity ( thePlayer, commandName, level )
function consoleSetPlayerGravity ( thePlayer, commandName, level )
if ( thePlayer and level ) then
if ( thePlayer and level ) then
local success = setPlayerGravity ( thePlayer, tonumber ( level ) )  -- Sets the gravity
local success = setPedGravity ( thePlayer, tonumber ( level ) )  -- Sets the gravity
if (not success) then --Check if setPlayerGravity was false (not successful)
if (not success) then --Check if setPlayerGravity was false (not successful)
outputConsole( "Failed to set player gravity", thePlayer )  -- If success is false, meaning gravity could not be set, this message will show
outputConsole( "Failed to set player gravity", thePlayer )  -- If success is false, meaning gravity could not be set, this message will show

Revision as of 14:11, 30 August 2016


Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does.


Please use setPedGravity

Description

This function sets the gravity level of a player.

Syntax

setPlayerGravity ( player thePlayer, float level )

Required Arguments

  • thePlayer: The player whose gravity to change.
  • level: The level of gravity ( default is 0.008 )

Example

Click to collapse [-]
Server

This example allows the user to type a command to change their gravity:

function consoleSetPlayerGravity ( thePlayer, commandName, level )
	if ( thePlayer and level ) then
		local success = setPedGravity ( thePlayer, tonumber ( level ) )  -- Sets the gravity
		if (not success) then --Check if setPlayerGravity was false (not successful)
			outputConsole( "Failed to set player gravity", thePlayer )  -- If success is false, meaning gravity could not be set, this message will show
		end
	end
end
addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )

See Also