F2 Common Local Variables
Contents |
Description
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:
| Variable | Type | Description |
|---|---|---|
| f_var_units | Array | Contains all units, regardless of side etc. |
| f_var_units_BLU | Array | Contains all BLUFOR units. |
| f_var_units_RES | Array | Contains all resistance units. |
| f_var_units_OPF | Array | Contains all OPFOR units. |
| f_var_units_CIV | Array | Contains all civilian units. |
| f_var_men | Array | Contains all men, regardless of side etc. |
| f_var_men_BLU | Array | Contains all BLUFOR men. |
| f_var_men_RES | Array | Contains all resistance men. |
| f_var_men_OPF | Array | Contains all OPFOR men. |
| f_var_men_CIV | Array | Contains all civilian men. |
| f_var_men_players | Array | Contains all players (excluding JIP players). |
| f_var_groups | Array | Contains all groups, regardless of side etc. |
| f_var_groups_BLU | Array | Contains all BLUFOR groups. |
| f_var_groups_RES | Array | Contains all resistance groups. |
| f_var_groups_OPF | Array | Contains all OPFOR groups. |
| f_var_groups_CIV | Array | Contains all civilian groups. |
| f_var_vehicles | Array | Contains all vehicles, regardless of side etc. |
| f_var_vehicles_BLU | Array | Contains all BLUFOR vehicles. |
| f_var_vehicles_RES | Array | Contains all resistance vehicles. |
| f_var_vehicles_OPF | Array | Contains all OPFOR vehicles. |
| f_var_vehicles_CIV | Array | Contains 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};
Tips
- 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.
Credits
- Headspace
- Fer
- Raedor