GetPedRotation: Difference between revisions
Jump to navigation
Jump to search
(New page: __NOTOC__ {{Client function}} Gets the rotation of a ped. ==Syntax== <syntaxhighlight lang="lua"> float getPedRotation ( ped thePed ) </syntaxhighlight> ===Required Arguments=== *'''thePed:''' the ped to get the ro...) |
m (Changed "DeprecatedWithAlt" template to "Deprecated") |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Server client function}} | ||
{{Deprecated|getElementRotation|}} | |||
Gets the rotation of a ped. | Gets the rotation of a ped. | ||
Line 9: | Line 11: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePed:''' the ped to | *'''thePed:''' the ped to retrieve the rotation of. | ||
===Returns=== | ===Returns=== | ||
Returns the rotation of the ped, in degrees | Returns the rotation of the ped, in degrees: 0 means facing north, higher values go counter clockwise. Returns ''false'' if an invalid element was passed. | ||
==Example== | |||
<section name="Server" class="server" show="true"> | |||
This code adds a ''getrot'' command to get a player's current rotation. | |||
<syntaxhighlight lang="lua"> | |||
function outputPlayerRotation ( sourcePlayer ) | |||
-- if the command was triggered by an ingame player | |||
if ( sourcePlayer ) then | |||
-- if he is in a vehicle | |||
if isPedInVehicle ( sourcePlayer ) then | |||
-- store the vehicle element | |||
local playerVehicle = getPedOccupiedVehicle ( sourcePlayer ) | |||
-- and output its rotation | |||
local x,y,z = getElementRotation ( playerVehicle ) | |||
outputChatBox ( "Your vehicle's rotation is: " .. z, sourcePlayer ) | |||
-- if he is on foot | |||
else | |||
-- output the player's rotation | |||
outputChatBox ( "Your rotation is: " .. getPedRotation ( sourcePlayer ), sourcePlayer ) | |||
end | |||
end | |||
end | |||
-- register outputPlayerRotation as a handler for the getrot command | |||
addCommandHandler ( "getrot", outputPlayerRotation ) | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Ped functions}} |
Latest revision as of 16:33, 13 February 2015
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions. | |
Please use getElementRotation instead. |
Gets the rotation of a ped.
Syntax
float getPedRotation ( ped thePed )
Required Arguments
- thePed: the ped to retrieve the rotation of.
Returns
Returns the rotation of the ped, in degrees: 0 means facing north, higher values go counter clockwise. Returns false if an invalid element was passed.
Example
Click to collapse [-]
ServerThis code adds a getrot command to get a player's current rotation.
function outputPlayerRotation ( sourcePlayer ) -- if the command was triggered by an ingame player if ( sourcePlayer ) then -- if he is in a vehicle if isPedInVehicle ( sourcePlayer ) then -- store the vehicle element local playerVehicle = getPedOccupiedVehicle ( sourcePlayer ) -- and output its rotation local x,y,z = getElementRotation ( playerVehicle ) outputChatBox ( "Your vehicle's rotation is: " .. z, sourcePlayer ) -- if he is on foot else -- output the player's rotation outputChatBox ( "Your rotation is: " .. getPedRotation ( sourcePlayer ), sourcePlayer ) end end end -- register outputPlayerRotation as a handler for the getrot command addCommandHandler ( "getrot", outputPlayerRotation )
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle