F2 Common Local Variables

From F2 EN
Jump to navigation Jump to search


To help mission designers writing custom scripts, F2 contains a component that automatically generates a selection of useful common local variables. These variables provide information such as arrays containing all the groups on a particular side, or all OPFOR men etc.

Required files

All the code associated with this component is found in:

  • init.sqf
  • f\common\f_setLocalVars.sqf
  • f\common\f_waitForJIP.sqf

How to use

How variables are generated

The script f_setLocalVars.sqf is executed at the start of the mission, on the server and every client machine. The variables created are accurate only for the local machine. This means that the precise value of any of the variables described below may differ from machine to machine. However, for most of the variables (such as arrays containing all units in the mission), the values are usually the same on all machines.

Available variables

Once the script f_setLocalVars.sqf (which has the handle f_script_setLocalVars when run from the init.sqf file) has completed, the following variables are available:

f_var_unitsArrayContains all units, regardless of side etc.
f_var_units_BLUArrayContains all BLUFOR units.
f_var_units_RESArrayContains all resistance units.
f_var_units_OPFArrayContains all OPFOR units.
f_var_units_CIVArrayContains all civilian units.
f_var_menArrayContains all men, regardless of side etc.
f_var_men_BLUArrayContains all BLUFOR men.
f_var_men_RESArrayContains all resistance men.
f_var_men_OPFArrayContains all OPFOR men.
f_var_men_CIVArrayContains all civilian men.
f_var_men_playersArrayContains all players (excluding JIP players).
f_var_groupsArrayContains all groups, regardless of side etc.
f_var_groups_BLUArrayContains all BLUFOR groups.
f_var_groups_RESArrayContains all resistance groups.
f_var_groups_OPFArrayContains all OPFOR groups.
f_var_groups_CIVArrayContains all civilian groups.
f_var_vehiclesArrayContains all vehicles, regardless of side etc.
f_var_vehicles_BLUArrayContains all BLUFOR vehicles.
f_var_vehicles_RESArrayContains all resistance vehicles.
f_var_vehicles_OPFArrayContains all OPFOR vehicles.
f_var_vehicles_CIVArrayContains all civilian vehicles.

Using variables in your scripts

To use any of these variables in a custom script ensure your custom script does not start until the variables have been set. This is done by placing the following block of code at the start of your script (or at least before you need to use the variables):

waitUntil {scriptDone f_script_setLocalVars};


  • You can further subdivide the arrays to create your own faction-specific ones using the faction command.

How to disable

You should not attempt to disable this component. Do not disable, remove or alter the script f_setLocalVars.sqf, or stop it being called from the init.sqf file.


  • Headspace
  • Fer
  • Raedor