GetCameraMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Fixed spelling of addCommandHandler, placed it after function declaration, second argument is a function pointer and not a string)
mNo edit summary
Line 1: Line 1:
__NOTOC__  
{{Server function}}
__NOTOC__
This function returns a [[string]] containing the current mode of the specified player's camera.
This function returns a [[string]] containing the current mode of the specified player's camera.
==Syntax==  
==Syntax==  
Line 21: Line 22:
<!-- 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 -->
<!-- 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, command, player )
function checkCamera( source, command, targetName )
       player = getPlayerFromName( player ) --Gets the player using his name
       local targetPlayer = getPlayerFromNick ( targetName )   -- Get the player using his name
       outputConsole( getCameraMode( player ), source ) --Outputs the state of players' camera.
       outputConsole( getCameraMode( targetPlayer ), source ) -- Output the state of player's camera
end
end
addCommandHandler( "camera", checkCamera )
addCommandHandler( "camera", checkCamera )

Revision as of 16:50, 20 August 2007

This function returns a string containing the current mode of the specified player's camera.

Syntax

string getCameraMode ( player thePlayer )

Required Arguments

  • thePlayer: The player whose camera mode you wish to obtain.

Returns

Returns a string with one of two values if successful:

  • player: The camera is attached to a player.
  • fixed: The camera is in a fixed position.

The function will return false if unsuccessful.

Example

This function checks the camera state of a player.

function checkCamera( source, command, targetName )
      local targetPlayer = getPlayerFromNick ( targetName )   -- Get the player using his name
      outputConsole( getCameraMode( targetPlayer ), source )  -- Output the state of player's camera
end
addCommandHandler( "camera", checkCamera )

See Also