SetPedRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Client function}} This function allows you to set the current rotation of the specified ped. ==Syntax== <syntaxhighlight lang="lua"> bool setPedRotation ( ped thePed, float rotation ) ...)
 
m (Undo revision 80463 by AirNewSCR (talk))
Tag: Undo
 
(17 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
{{Deprecated|setElementRotation|}}
 
This function allows you to set the current rotation of the specified ped.
This function allows you to set the current rotation of the specified ped.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setPedRotation ( ped thePed, float rotation )         
bool setPedRotation ( ped thePed, float rotation [, bool conformPedRotation = false ] )         
</syntaxhighlight>  
</syntaxhighlight>  


Line 11: Line 13:
*'''thePed:''' The [[ped]] to set the rotation of
*'''thePed:''' The [[ped]] to set the rotation of
*'''rotation:''' A [[float]] specifying the desired rotation in degrees.
*'''rotation:''' A [[float]] specifying the desired rotation in degrees.
===Optional Arguments===
{{New feature/item|3.0152|1.3.2|4680|
*'''conformPedRotation:''' A bool which should be set to ''true'' to ensure the ped rotation is correctly set in all circumstances. Failing to set this argument may result in the rotation being inverted when the ped is in the air and other inconsistencies. The default value of false is for backward compatibility with scripts which may depend upon the incorrect behaviour
}}


===Returns===
===Returns===
Returns ''true'' if successful, ''false'' otherwise.
Returns ''true'' if successful, ''false'' otherwise.


==Example==  
==Example==
<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">function discoTime ( )
<syntaxhighlight lang="lua">function discoTime ( )
Line 25: Line 33:
function initiateDiscoMode ( commandName )
function initiateDiscoMode ( commandName )
     -- Trigger a random change in player rotation every second
     -- Trigger a random change in player rotation every second
     setTimer (discoTime, 1000, 0 )
     setTimer ( discoTime, 1000, 0 )
end
end
addCommandHandler ( "disco", initiateDiscoMode )</syntaxhighlight>
addCommandHandler ( "disco", initiateDiscoMode )
</syntaxhighlight>
</section>
 
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.3.1-9.04680|Added conformPedRotation argument}}


==See Also==
==See Also==
{{Client_ped_functions}}
{{Ped_functions}}
[[ru:setPedRotation]]

Latest revision as of 13:30, 8 September 2024

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementRotation instead.


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

Syntax

bool setPedRotation ( ped thePed, float rotation [, bool conformPedRotation = false ] )         

Required Arguments

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

Optional Arguments

  • conformPedRotation: A bool which should be set to true to ensure the ped rotation is correctly set in all circumstances. Failing to set this argument may result in the rotation being inverted when the ped is in the air and other inconsistencies. The default value of false is for backward compatibility with scripts which may depend upon the incorrect behaviour

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 )

Changelog

Version Description
1.3.1-9.04680 Added conformPedRotation argument

See Also