SetPlayerGravity: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 12: Line 12:
==Example==
==Example==
This example allows the user to type a command to change their gravity:
This example allows the user to type a command to change their gravity:
<syntaxhighlight lang="lua">addCommandHandler ( "setplayergravity", "playerGrav" )
<syntaxhighlight lang="lua">function consoleSetPlayerGravity ( player, commandName, level ) --Calls the function
function playerGrav ( source, command, gravid )
if ( player ) then
    setPlayerGravity ( source, gravid )
local success = setPlayerGravity ( player, tonumber ( level ) ) --Sets the gravity
end</syntaxhighlight>
if (not success) then
 
outputConsole( "Failed to set player gravity", player ) --If it can't be set, this message will show
end
end
end
addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )</syntaxhighlight>
==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 05:29, 6 August 2007

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

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

function consoleSetPlayerGravity ( player, commandName, level ) --Calls the function
	if ( player ) then
		local success = setPlayerGravity ( player, tonumber ( level ) ) --Sets the gravity
		if (not success) then
			outputConsole( "Failed to set player gravity", player ) --If it can't be set, this message will show
		end
	end
end
addCommandHandler ( "setplayergravity", consoleSetPlayerGravity )

See Also