GetCameraPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(23 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Needs_Checking|Returns 0 0 0 with script:
__NOTOC__
<syntaxhighlight lang="lua">addCommandHandler ( "getcampos", "retrieveCameraPosition" )
{{Server client function}}
function retrieveCameraPosition ( player, commandName )
{{Deprecated|getCameraMatrix|}}
local camx, camy, camz = getCameraPosition ( player )
outputChatBox ( "X: "..camx.." Y: "..camy.." Z: "..camz )
end</syntaxhighlight>--[[User:Ransom|Ransom]] 17:17, 11 April 2007 (CDT)}}  


This function returns the position that the player's camera would have if the camera mode was fixed (see [[setCameraMode]]).


 
==Procedural==
__NOTOC__
This function returns the position the player's camera would have if the camera mode is fixed (see [[setCameraMode]]).
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float float getCameraPosition ( player thePlayer )
float float float getCameraPosition ()
</syntaxhighlight>  
</syntaxhighlight>


===Required Arguments===
This function returns the X, Y and Z coordinates as three [[float|floats]] if the function was successful, ''false'' otherwise.
*'''thePlayer:''' The player whose camera position you wish to obtain.


===Returns===
===Example===
Returns three [[float|floats]] containing the x, y and z co-ordinate values if the function was successful, ''false'' otherwise.
This page lacks an example.


==Example==  
{{New items|3.0140|1.4|
<!-- Explain what the example is in a single sentence -->
==Object-oriented==
This example checks if the camera is fixed, and prints its position if so.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkCamera( source )
Vector3 Camera.getPosition ()
      if ( getCameraMode( source ) == "fixed" ) then --If the camera is fixed...
            local camx, camy, camz = getCameraPosition( source ) --Get the cameras position
            outputConsole( camx .. " " .. camy .. " " .. camz, source ) --And output it.
      else
            outputConsole( "The camera is not fixed", source ) --If not, say so.
      end
end
addCommandHandler( "check", checkCamera )
</syntaxhighlight>
</syntaxhighlight>


This function returns a vector with the coordinates if the function was successful, an empty vector otherwise.
===Example===
This page lacks an example.
}}
==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}

Latest revision as of 16:24, 13 February 2015

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 getCameraMatrix instead.


This function returns the position that the player's camera would have if the camera mode was fixed (see setCameraMode).

Procedural

float float float getCameraPosition ()

This function returns the X, Y and Z coordinates as three floats if the function was successful, false otherwise.

Example

This page lacks an example.

Object-oriented

Vector3 Camera.getPosition ()

This function returns a vector with the coordinates if the function was successful, an empty vector otherwise.

Example

This page lacks an example.

See Also