Page tree
Skip to end of metadata
Go to start of metadata


Introduced in

Version:1.22

Description

Description:

Sets the optics state of the player, gunner, vehicle driver, or vehicle turret, and broadcasts it in multiplayer.

Since version V19.1.0+, it is possible to override the optics state of a specific turret by providing a gunner object, or vehicle and turret path, instead of the active parameter. In this case, an active optics state does not change.

Syntax

Syntax:setOpticsState [active, zoom, visionmode, timode , weapon, transition, device, mode]
Parameters:
  • active: Boolean - Set to true to select optics.
  • zoom: Number or Array - Array is of the format of [zoom, continuous] (optional).
    Note: The zoom parameter has no effect in V1.50.
  • visionmode: Number - 0: day, 1: night, 2: thermal vision (optional for dismounted units).
  • timode: Number - Index of TI mode (optional for dismounted units).
  • weapon: String - Currently selected unit or turret weapon (optional).
  • transition: Number - Overrides the weapon bore sight to optics transition (blending) value (optional).
  • device: Number - Index of optic device on muzzle (optional) (V1.62+).
  • mode: Number - Index of optic mode of the optic device (optional) (V1.62+).
Return Value:Nothing

Alternative Syntax #1 (V19.1.0+)

Syntax:

setOpticsState [gunner, zoom, visionMode, tiMode , weapon, transition, device, mode]

Parameters:
  • gunner: Object - Unit, vehicle, or gunner of turret to change the optics state of. Gunner in Personal Items mode adjusts its own optics.
  • zoom: Number or Array - Array in the format of [zoom, continuous] (optional).
  • visionMode: Number - 0: day, 1: night, 2: thermal vision (optional for dismounted units).
  • tiMode: Number - Index of TI mode (optional for dismounted units).
  • weapon: String - Currently selected unit or turret weapon (optional).
  • transition: Number - Overrides the weapon bore sight to optics transition (blending) value (optional).
  • device: Number - Index of optic device on muzzle (optional).
  • mode: Number - Index of optic mode of the optic device (optional).
Return Value:Nothing

Alternative Syntax #2 (V19.1.0+)

Syntax:

setOpticsState [[vehicle, turret], zoom, visionMode, tiMode , weapon, transition, device, mode]

Parameters:
  • vehicle: Object - Unit, vehicle, or gunner of turret to change the optics state of.
  • turret: Array - Path of turret to apply the optics state to.
  • zoom: Number or Array - Array in the format of [zoom, continuous] (optional).
  • visionMode: Number - 0: day, 1: night, 2: thermal vision (optional for dismounted units).
  • tiMode: Number - Index of TI mode (optional for dismounted units).
  • weapon: String - Currently selected unit or turret weapon (optional).
  • transition: Number - Overrides the weapon bore sight to optics transition (blending) value (optional).
  • device: Number - Index of optic device on muzzle (optional).
  • mode: Number - Index of optic mode of the optic device (optional).
Return Value:Nothing

Examples

Examples:
// Set the optics of the player unit / player turret
setOpticsState [true, 2.0, 1, 0, "M16"]
// Set the optics state of the player vehicle gunner turret
setOpticsState [gunner vehicle player, 2.0, 1, 0, "M16"]
// Set the optics state of the player vehicle main turret
setOpticsState [[vehicle player, [0]], 4.0, 2, 2, "vbs2_l30a1_120mm", -1, 1, 0]

Additional Information

See also:opticsState, turretOpticsState, setWeaponZoomFactor
Multiplayer:When used on a remote object / turret, the state may be overridden by the next network update message. Therefore, it is recommended to set the optics state, where the affected object / turret is local.
Problems: