GetCameraMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(fixed the examples)
Line 29: Line 29:


==Example==  
==Example==  
This function checks the camera state of a player:
<section name="Server script" class="server" show="true">
<section name="Server script" class="server" show="true">
This function checks the camera state of a player, by specifying his name:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkCamera( source, command, targetName )
function checkCamera( source, command, targetName )
       local targetPlayer = getPlayerFromNick ( targetName )  -- Get the player using his name
       local targetPlayer = getPlayerFromNick ( targetName )  -- Get the player using his name
       outputConsole( getCameraMode( targetPlayer ), source )  -- Output the state of player's camera
       outputConsole( targetName.."'s camera mode is: "..getCameraMode( targetPlayer ), source )  -- Output the state of player's camera
end
end
addCommandHandler( "camera", checkCamera )
addCommandHandler( "camera", checkCamera )
Line 41: Line 41:


<section name="Client script" class="client" show="false">
<section name="Client script" class="client" show="false">
This function checks the camera state of the local player:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkCamera( command, targetName )
function checkCamera( command )
      local targetPlayer = getPlayerFromNick ( getLocalPlayer())  -- Get the player using his name
       outputConsole( "The current camera mode is: "..getCameraMode() )  -- Output the state of player's camera
       outputConsole( getCameraMode(), getLocalPlayer())  -- Output the state of player's camera
end
end
addCommandHandler( "camera", checkCamera )
addCommandHandler( "camera", checkCamera )

Revision as of 01:51, 3 November 2008

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

Syntax

Click to collapse [-]
Server
string getCameraMode ( player thePlayer )

Required Arguments

  • thePlayer: The player whose camera mode you wish to obtain.
Click to collapse [-]
Client
string getCameraMode ( )

Required Arguments

None.

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

Click to collapse [-]
Server script

This function checks the camera state of a player, by specifying his name:

function checkCamera( source, command, targetName )
      local targetPlayer = getPlayerFromNick ( targetName )   -- Get the player using his name
      outputConsole( targetName.."'s camera mode is: "..getCameraMode( targetPlayer ), source )  -- Output the state of player's camera
end
addCommandHandler( "camera", checkCamera )
Click to expand [+]
Client script

See Also