HOME

PROFILE avatar
HOME

Variables

A variable is a "storage container" or "named placeholder" for data. You can read and modify the data once this container is created. Its "name" is referenced as an Identifier.

There are two types of variables:

  1. Local Variables - Variables only existing in one object.
  2. Global Variables - Variables existing all over the mission (Made with underscore before it "_var").

Initialization

The first thing to do to create a variable is to find its name, also called identifier; this name must be speaking to the reader - keep in mind that code is meant to be read by human beings (see Code Best Practices - Variable format).

myVariable =4

Deletion

Once created, variables take up space in the computer's memory. This is not drastic for small variables, but if a big number of very large variables is used, it is recommended to undefine the unneeded ones in order to free up memory.

myVariable =nil

Spawning Assets

There are also two main types of Spawning Assets:

  1. Spawning on the Map

    For that, the best command is createVehicle, which allows you to spawn a number of assets on the map.

    1st. Syntax:

    assetName createVehicle position

    • assetName - Name of the asset (Can be found when clicking on the asset).
    • position - Position where the asset will be placed (Can be: [x, y, z] or marker pos: getMarkerPos markerName.
    B_Sniper_FcreateVehicle[784.8, 87.0, 9.7896]

    2nd. Syntax:

    createVehicle [assetName, position, placement]

    • assetName - Name of the asset (Can be found when clicking on the asset).
    • position - Position where the asset will be placed (Can be: [x, y, z] or marker pos: getMarkerPos markerName, or even in the set radius of marker.
    • placement - (Optional) Place in set radius, needs to be combined with the position.
    createVehicle[B_Sniper_F, getMarkerPos ["marker1", "marker2"], 4];



  2. Adding Items to Inventory

    With the command: addItem you are able to add an item to the inventory of any unit.

    Syntax:

    unit addItem "item"

    • unit - Unit that will receive the item.
    • "item" - Item that will be added to the unit.
    playeraddItem"NVGoggles"

Some assets list:

Weapons Magazines Items Equipment Vehicles
NATO arifle_MXC_Holo_F 30Rnd_65x39_caseless_mag bipod_01_F_blk U_B_CTRG_ B_MRAP_01_F
CSAT arifle_Katiba_GL_ACO_F 30Rnd_65x39_caseless_green bipod_02_F_hex U_O_GhillieSuit O_APC_Tracked_02_cannon_F
AAF arifle_Mk20C_F 30Rnd_556x45_Stanag bipod_03_F_oli U_I_CombatUniform I_MBT_03_cannon_F

Removing Assets

There are also two main types of Removing Assets:

  1. Removing assets from the map

    For that, the best command is deleteVehicle, which allows you to remove any assets on the map.

    Syntax:

    deleteVehicle unit

    • unit - Asset that will be removed.
    deleteVehicleunit4



  2. Removing Items from Inventory

    With the command: removeItem you are able to remove any item from the inventory of any unit.

    Syntax:

    unit removeItem "item"

    • unit - Unit that will lose the item.
    • "item" - Item that will be removed from the unit.
    playerremoveItem"NVGoggles"

Animation

There are also two main commands on how to Animate units:

  1. switchMove

    Syntax:

    unit switchMove "animation"

    • unit - Unit that will be animated.
    • "animation" - Selected animation that will be played.
    enemyUnitremoveItem"AmovPpneMstpSrasWrflDnon"
  2. BIS_fnc_ambientAnim

    Syntax:

    [unit, animation, equipment] call BIS_fnc_ambientAnim

    • unit - Unit that will be animated.
    • "animation" - Selected animation that will be played.
    • equipment - Equipment that the unit will be wearing.
    [player, SIT_U1, NONE] call BIS_fnc_ambientAnim

Hint

  1. hint

    Syntax:

    hint "message"

    • "message" - Message displayed.
    hint"This is a hint"

Teleportation

  1. setPos

    Syntax:

    object setPos position

    • object - Object that will be teleported.
    • position - Position where the asset will be teleported (Can be: [x, y, z] or marker pos: getMarkerPos markerName.
    playersetPos[80.0, 98.5, 97.26]

Custom Action

  1. addAction

    Syntax:

    object addAction [title, script, priority, hideOnUse, condition, radius, unconscious]

    • object - Object that will have the action on it.
    • title - The displayed name of the action.
    • script - Script or a link to a script that will start when activated.
    • priority - How high will this action be.
    • hideOnUse - Hides action after activation.
    • condition - Script that needs to return true for the action to show.
    • radius - Radius from where you can press it.
    • unconscious - Sets if you can activate it when unconscious.
    thisaddAction["Buy vehicle, "buyscript.sqf", "6", "true", "condition.sqf", "5", "false"]