setPedGravity | Multi Theft Auto: Wiki Skip to content

setPedGravity

Client-side
Server-side
Shared

Pair: getPedGravity

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function sets the gravity level of a ped.

OOP Syntax Help! I don't understand this!

  • Method:ped:setGravity(...)
  • Variable: .gravity

Syntax

bool setPedGravity ( ped thePed, float gravity )
Required Arguments
  • thePed: The ped whose gravity to change.
  • gravity: MISSING_PARAM_DESC

Returns

  • bool: value

Returns true if the gravity was successfully set, false otherwise

Code Examples

shared

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 ) ) -- Set the gravity
if not success then -- Check if setPlayerGravity was false (not successful)
outputConsole( "Failed to set ped gravity", thePlayer ) -- If success is false, meaning gravity could not be set, this message will show
end
end
end
addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )

See Also