SetCameraMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Visual improvement)
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function allows you to change a player's camera mode to either "following" or "fixed".  
{{Server function}}
{{Deprecated|setCameraTarget}}
{{Note|remember to set players camera mode back to "player" on resource unload, or you will encounter the invisible player 'bug' if players camera is still set to fixed.}}
 
This function allows you to set a player's camera to either follow him or be fixed at a certain position.
 
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setCameraMode ( player thePlayer, string mode ) --- possible modes "player", "fixed"
bool setCameraMode ( player thePlayer, string mode )
</syntaxhighlight>  
</syntaxhighlight>  


Line 9: Line 14:
*'''thePlayer:''' The player whose camera you wish to modify.
*'''thePlayer:''' The player whose camera you wish to modify.
*'''mode:''' The mode to be set. It has the following possible values:
*'''mode:''' The mode to be set. It has the following possible values:
** '''"player":''' Sets the camera to follow a player or another moving object.
** '''"player":''' Sets the camera to follow a player.
** '''"fixed":''' Fixes the camera in a set position.
** '''"fixed":''' Fixes the camera in a set position/rotation.
   
   
===Returns===
===Returns===
Returns a [[bool]] with a value of ''true'' if the function was successful, ''false'' otherwise.
Returns a [[bool]] with a value of ''true'' if the function was successful, ''false'' otherwise.


==Example==  
==Example==
 
<syntaxhighlight lang="lua">
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
</syntaxhighlight>


==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}
[[Category:Incomplete]]
{{Needs_Checking|Is the description correct?}}

Latest revision as of 12:29, 26 June 2014

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 setCameraTarget instead.
[[{{{image}}}|link=|]] Note: remember to set players camera mode back to "player" on resource unload, or you will encounter the invisible player 'bug' if players camera is still set to fixed.

This function allows you to set a player's camera to either follow him or be fixed at a certain position.

Syntax

bool setCameraMode ( player thePlayer, string mode )

Required Arguments

  • thePlayer: The player whose camera you wish to modify.
  • mode: The mode to be set. It has the following possible values:
    • "player": Sets the camera to follow a player.
    • "fixed": Fixes the camera in a set position/rotation.

Returns

Returns a bool with a value of 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