SetPedGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}} This function sets the gravity level of a player. ==Syntax== <syntaxhighlight lang="lua"> bool setPedGravity ( ped thePed, float gravity ) </syntaxhighlight> ===Required Arguments=== *...)
 
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This function sets the gravity level of a player.
This function sets the gravity level of a ped.


==Syntax==
==Syntax==

Revision as of 19:38, 25 May 2008

This function sets the gravity level of a ped.

Syntax

bool setPedGravity ( ped thePed, float gravity )

Required Arguments

  • thePed: The ped whose gravity to change.
  • level: The level of gravity (default is 0.008).

Returns

Returns true if the gravity was successfully set, false otherwise

Example

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 player gravity", thePlayer )  -- If success is false, meaning gravity could not be set, this message will show
		end
	end
end
addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )

</section>

See Also