SetCameraPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (First argument of setTimer is now a function pointer, not a string)
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function allows you to move a specified player's camera to a specific location if it is fixed (see [[setCameraMode]]).
{{Server client function}}
This function allows you to move a player's camera to a specific location if it is fixed (see [[setCameraMode]]).
   
   
==Syntax==  
==Syntax==  
Line 9: Line 10:
===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player whose camera you wish to modify.
*'''thePlayer:''' The player whose camera you wish to modify.
*'''x:''' The x co-ordinate of the new position.
*'''x:''' The x coordinate of the new position.
*'''y:''' The x co-ordinate of the new position.
*'''y:''' The x coordinate of the new position.
*'''z:''' The x co-ordinate of the new position.
*'''z:''' The x coordinate of the new position.


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

Revision as of 13:08, 16 August 2007

This function allows you to move a player's camera to a specific location if it is fixed (see setCameraMode).

Syntax

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

Required Arguments

  • thePlayer: The player whose camera you wish to modify.
  • x: The x coordinate of the new position.
  • y: The x coordinate of the new position.
  • z: The x coordinate of the new position.

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