SetPlayerRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (blegh. done.)
(changed category to 'Server client function', since this is also a client function (with exact same args))
Line 1: Line 1:
{{Server function}}
{{Server client function}}


__NOTOC__  
__NOTOC__  
Line 11: Line 11:
===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The [[player]] to set the rotation of
*'''thePlayer:''' The [[player]] to set the rotation of
*'''rotation:''' A [[float]] specifying the desired rotation.
*'''rotation:''' A [[float]] specifying the desired rotation in degrees.


===Returns===
===Returns===

Revision as of 03:28, 29 January 2008


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

Syntax

bool setPlayerRotation ( player thePlayer, float rotation )         

Required Arguments

  • thePlayer: The player to set the rotation of
  • rotation: A float specifying the desired rotation in degrees.

Returns

Returns true if successful, false otherwise.

Example

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 ( player )
     -- Randomly choose a new player rotation and set it
     newRotation = math.random ( 0, 360 )
     setPlayerRotation ( player, newRotation )
end

function initiateDiscoMode ( player, commandName )
     --Trigger a random change in player rotation every second
     --Send the stored 'activating player' to the discoTime
     --function, so his rotation will be changed.
     setTimer (discoTime, 1000, 0, player )
end
addCommandHandler ( "disco", initiateDiscoMode )

See Also