SetPedRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
This example allows a player to type the command 'disco', which will result in the player being rotated to a random direction every 1 second, infinite times.
This example allows a player to type the command 'disco', which will result in the player being rotated to a random direction every 1 second, infinite times.
<syntaxhighlight lang="lua" line="GESHI_NORMAL_LINE_NUMBERS" highlight=4>function discoTime ( )
<syntaxhighlight lang="lua">function discoTime ( )
     -- Randomly choose a new player rotation and set it
     -- Randomly choose a new player rotation and set it
     newRotation = math.random ( 0, 360 )
     newRotation = math.random ( 0, 360 )

Revision as of 17:38, 18 July 2009

This function allows you to set the current rotation of the specified ped.

Syntax

bool setPedRotation ( ped thePed, float rotation )         

Required Arguments

  • thePed: The ped to set the rotation of
  • rotation: A float specifying the desired rotation in degrees.

Returns

Returns true if successful, false otherwise.

Example

Click to collapse [-]
Client

This example allows a player to type the command 'disco', which will result in the player being rotated to a random direction every 1 second, infinite times.

function discoTime ( )
     -- Randomly choose a new player rotation and set it
     newRotation = math.random ( 0, 360 )
     setPedRotation ( getLocalPlayer(), newRotation )
end

function initiateDiscoMode ( commandName )
     -- Trigger a random change in player rotation every second
     setTimer ( discoTime, 1000, 0 )
end
addCommandHandler ( "disco", initiateDiscoMode )

See Also