setOpticsMode: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(remove duplicate text; shorten parameter name)
m (Text replacement - "\|branch= *dev " to "")
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
|version1= 2.10
|version1= 2.10


|branch= dev


|gr1= Object Manipulation
|gr1= Object Manipulation
Line 13: Line 12:


|p1= unit: [[Object]]
|p1= unit: [[Object]]
|p2= mode: [[String]] or [[Number]] - Class name defined in the OpticsModes config class of the optic. Or the 0-based index of the optic mode with 0 being the default optic mode.
 
|p2= mode: [[String]], [[Number]] or [[Array]]:
* [[String]] - class name defined in the optic's {{hl|OpticsModes}} config class
* [[Number]] - 0-based index of the optic mode with 0 being the default optic mode
* [[Array]] - in format [slotIndex, opticsModeIndexOrClassName] where:
** slotIndex: [[Number]], can be one of:
*** 0 - Current weapon
*** 1 - Primary weapon
*** 2 - Secondary weapon
*** 3 - Handgun
** opticsModeIndexOrClassName: [[String]] or [[Number]] as above


|r1= [[Nothing]]
|r1= [[Nothing]]
Line 20: Line 29:


|x2= <sqf>player setOpticsMode 0;</sqf>
|x2= <sqf>player setOpticsMode 0;</sqf>
|x3= <sqf>player setOpticsMode [1, 0]; // reset the optics mode of the player's primary weapon to the default</sqf>


|seealso= [[getOpticsMode]]
|seealso= [[getOpticsMode]]
}}
}}

Latest revision as of 13:23, 23 August 2022

Hover & click on the images for description

Description

Description:
Sets the optic mode of the current weapon to the given class name or the index.
Groups:
Object Manipulation

Syntax

Syntax:
unit setOpticsMode mode
Parameters:
unit: Object
mode: String, Number or Array:
  • String - class name defined in the optic's OpticsModes config class
  • Number - 0-based index of the optic mode with 0 being the default optic mode
  • Array - in format [slotIndex, opticsModeIndexOrClassName] where:
    • slotIndex: Number, can be one of:
      • 0 - Current weapon
      • 1 - Primary weapon
      • 2 - Secondary weapon
      • 3 - Handgun
    • opticsModeIndexOrClassName: String or Number as above
Return Value:
Nothing

Examples

Example 1:
player setOpticsMode "Hamr2Scope"; // Default optic mode for optic_Hamr
Example 2:
player setOpticsMode 0;
Example 3:
player setOpticsMode [1, 0]; // reset the optics mode of the player's primary weapon to the default

Additional Information

See also:
getOpticsMode

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note