SetCameraLookAt: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{Deprecated|setCameraMatrix|}}
This function allows you to set a player's camera to look at a specific point when the camera is fixed (see [[setCameraMode]]).
This function allows you to set a player's camera to look at a specific point when the camera is fixed (see [[setCameraMode]]).
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 8: Line 11:


===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player whose camera you wish to modify.
*'''thePlayer:''' The player whose camera you wish to modify. (not needed for clientside scripting)
*'''x:''' The x co-ordinate of the point to be looked at.
*'''x:''' The x coordinate of the point to be looked at.
*'''y:''' The y co-ordinate of the point to be looked at.
*'''y:''' The y coordinate of the point to be looked at.
*'''z:''' The z co-ordinate of the point to be looked at.
*'''z:''' The z coordinate of the point to be looked at.


===Returns===
===Returns===
Returns a [[bool]] with a value of ''true'' if the function was successful, ''false'' otherwise.
Returns ''true'' if the function was successful, ''false'' otherwise.


==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function spawnScreen ( source ) --Calls the function spawnScreen
function spawnScreen ( source )
setCameraMode ( source, "fixed" ) --Classifies which camera mode to use for the spawn screen
setCameraMode ( source, "fixed" )                                     -- Make the camera fixed (instead of following the player)
setTimer ( setCameraPosition, 1000, 1, source, 160.15, -1951.68, 50 ) --Coords for the fixated camera
setTimer ( setCameraPosition, 1000, 1, source, 160.15, -1951.68, 50 ) -- Set the coordinates of the camera
setTimer ( setCameraLookAt, 1000, 1, source, 165, -1951.68, 50 ) --Coords for the fixated camera. This will "point" the camera, so to speak.
setTimer ( setCameraLookAt, 1000, 1, source, 165, -1951.68, 50 )     -- Make the camera look at specified coordinates
bindKey ( source, "F1", "down", "Spawn as Vagos", spawnVagos ) --Spawns player as team #1. In this case, a new function is created later on
bindKey ( source, "F1", "down", "Spawn as Vagos", spawnVagos )       -- Bind spawn key (function spawnVagos is not given here)
bindKey ( source, "F2", "down", "Spawn as Aztecs", spawnAztecs ) --Spawns player as team #2. In this case, a new function is created later on
bindKey ( source, "F2", "down", "Spawn as Aztecs", spawnAztecs )     -- Bind spawn key (function spawnAztecs is not given here)
end
end
</syntaxhighlight>
</syntaxhighlight>

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


This function allows you to set a player's camera to look at a specific point when the camera is fixed (see setCameraMode).

Syntax

bool setCameraLookAt ( player thePlayer, float x, float y, float z )

Required Arguments

  • thePlayer: The player whose camera you wish to modify. (not needed for clientside scripting)
  • x: The x coordinate of the point to be looked at.
  • y: The y coordinate of the point to be looked at.
  • z: The z coordinate of the point to be looked at.

Returns

Returns true if the function was successful, false otherwise.

Example

function spawnScreen ( source )
	setCameraMode ( source, "fixed" )                                     -- Make the camera fixed (instead of following the player)
	setTimer ( setCameraPosition, 1000, 1, source, 160.15, -1951.68, 50 ) -- Set the coordinates of the camera
	setTimer ( setCameraLookAt, 1000, 1, source, 165, -1951.68, 50 )      -- Make the camera look at specified coordinates
	bindKey ( source, "F1", "down", "Spawn as Vagos", spawnVagos )        -- Bind spawn key (function spawnVagos is not given here)
	bindKey ( source, "F2", "down", "Spawn as Aztecs", spawnAztecs )      -- Bind spawn key (function spawnAztecs is not given here)
end

See Also