GetPlayerRotation: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Changed "DeprecatedWithAlt" template to "Deprecated") |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This function returns | {{Deprecated|getElementRotation|}} | ||
This function returns the current rotation (in degrees) of a player around the Z axis. It's used with on-foot players: use [[getVehicleRotation]] on the occupied [[vehicle]] if the player is in one. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | |||
float getPlayerRotation ( player thePlayer ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''thePlayer''': the [[player]] whose rotation you want to retrieve. | ||
===Returns=== | |||
Returns a ''float'' containing the player's rotation, or ''false'' if an invalid player (or one in a vehicle) was passed. | |||
==Example== | ==Example== | ||
This code adds a ''getrot'' command to get the 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 isPlayerInVehicle ( sourcePlayer ) then | |||
-- store the vehicle element | |||
local playerVehicle = getPlayerOccupiedVehicle ( sourcePlayer ) | |||
-- and output its rotation | |||
local x,y,z = getVehicleRotation ( playerVehicle ) | |||
outputChatBox ( "Your vehicle's rotation is: " .. z, sourcePlayer ) | |||
-- if he is on foot | |||
else | |||
-- output the player's rotation | |||
outputChatBox ( "Your rotation is: " .. getPlayerRotation ( sourcePlayer ), sourcePlayer ) | |||
end | |||
end | |||
end | |||
-- register outputPlayerRotation as a handler for the getrot command | |||
addCommandHandler ( "getrot", outputPlayerRotation ) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Latest revision as of 16:13, 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. |
This function returns the current rotation (in degrees) of a player around the Z axis. It's used with on-foot players: use getVehicleRotation on the occupied vehicle if the player is in one.
Syntax
float getPlayerRotation ( player thePlayer )
Required Arguments
- thePlayer: the player whose rotation you want to retrieve.
Returns
Returns a float containing the player's rotation, or false if an invalid player (or one in a vehicle) was passed.
Example
This code adds a getrot command to get the 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 isPlayerInVehicle ( sourcePlayer ) then -- store the vehicle element local playerVehicle = getPlayerOccupiedVehicle ( sourcePlayer ) -- and output its rotation local x,y,z = getVehicleRotation ( playerVehicle ) outputChatBox ( "Your vehicle's rotation is: " .. z, sourcePlayer ) -- if he is on foot else -- output the player's rotation outputChatBox ( "Your rotation is: " .. getPlayerRotation ( sourcePlayer ), sourcePlayer ) end end end -- register outputPlayerRotation as a handler for the getrot command addCommandHandler ( "getrot", outputPlayerRotation )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState