SetPlayerRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (blegh. done.)
Line 2: Line 2:


__NOTOC__  
__NOTOC__  
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 function allows you to set the current rotation of the specified player.


==Syntax==  
==Syntax==  
Line 17: Line 17:


==Example==  
==Example==  
This example code makes the player named Cheesepie look south.
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">function discoTime ( player, command )
<syntaxhighlight lang="lua">function discoTime ( player )
     -- Randomly choose a new playe rotation and set it
     -- Randomly choose a new player rotation and set it
     newRotation = math.random ( 0, 360 )
     newRotation = math.random ( 0, 360 )
     setPlayerRotation ( player, newRotation )
     setPlayerRotation ( player, newRotation )
end
end


--When 'disco' command is typed
function initiateDiscoMode ( player, commandName )
function initiateDiscoMode ( player, commandName )
     --Trigger a random change in player rotation every second.
     --Trigger a random change in player rotation every second
     --Send the player who activated discoTime to the function so his rotation will be changed.
     --Send the stored 'activating player' to the discoTime
    --function, so his rotation will be changed.
     setTimer (discoTime, 1000, 0, player )
     setTimer (discoTime, 1000, 0, player )
end
end
Line 34: Line 34:
==See Also==
==See Also==
{{Player functions}}
{{Player functions}}
[[Category:Incomplete]]

Revision as of 08:09, 11 October 2007


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.

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