GetCameraViewMode: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(add ped camera modes)
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.5.8|20851|Now you can get the camera mode when the [[player]] is not inside a [[vehicle]].}}
This function allows you to get the active camera view modes. This indicates at what distance the camera will follow the player or vehicle.
 
This function allows you to get the camera's view mode. This indicates at what distance the camera will follow the player.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int, int getCameraViewMode ( )
int, int getCameraViewMode ( )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||Camera.getCameraViewMode|viewMode|setCameraViewMode}}
{{OOP||Camera.getCameraViewMode|viewMode|setCameraViewMode}}


===Returns===
===Returns===
Returns two [[int]] indicating the current camera view modes. Their meanings can be seen below.
{{Deprecated items|3.0159|1.5.8|Returns an [[int]] indicating the current vehicle camera view mode. Their meanings can be seen below.|20851}}
 
{{New feature/item|3.0159|1.5.8|20851|Returns two [[int|ints]] indicating the current vehicle and ped camera view mode respectively. Their meanings can be seen below.}}


{{Camera view modes}}
{{Camera view modes}}
Line 19: Line 19:
This example tells the player their current camera view when they change it
This example tells the player their current camera view when they change it
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onPlayerSpawn ( theSpawnpoint )
function onPlayerSpawn(theSpawnpoint)
     currentCam("fire") -- start a repeating check
     currentCam("fire") -- start a repeating check
end
end
addEventHandler ( "onClientPlayerSpawn", root, onPlayerSpawn )
addEventHandler("onClientPlayerSpawn", root, onPlayerSpawn)


function currentCam(key)
function currentCam(key)
   if (getControlState(key)) then
   if (getControlState(key)) then
       local vehicleMode, pedMode = getCameraViewMode()
       local vehicleMode, pedMode = getCameraViewMode()
       outputChatBox("Your current cam view is: "..vehicleMode..".")
       outputChatBox("Your current cam view is: " .. vehicleMode .. ".")
   end
   end
end
end

Revision as of 11:10, 11 April 2021

This function allows you to get the active camera view modes. This indicates at what distance the camera will follow the player or vehicle.

Syntax

int, int getCameraViewMode ( )

OOP Syntax Help! I don't understand this!

Method: Camera.getCameraViewMode(...)
Variable: .viewMode
Counterpart: setCameraViewMode


Returns

BEFORE VERSION 1.5.8 r20851:
Returns an int indicating the current vehicle camera view mode. Their meanings can be seen below.

Returns two ints indicating the current vehicle and ped camera view mode respectively. Their meanings can be seen below.

Vehicle Modes:

  • 0: Bumper
  • 1: Close external
  • 2: Middle external
  • 3: Far external
  • 4: Low external
  • 5: Cinematic

Ped Modes:

  • 1: Close
  • 2: Middle
  • 3: Far

Example

This example tells the player their current camera view when they change it

function onPlayerSpawn(theSpawnpoint)
    currentCam("fire") -- start a repeating check
end
addEventHandler("onClientPlayerSpawn", root, onPlayerSpawn)

function currentCam(key)
   if (getControlState(key)) then
      local vehicleMode, pedMode = getCameraViewMode()
      outputChatBox("Your current cam view is: " .. vehicleMode .. ".")
   end
end

See Also