Just wanted to share a few tips and tricks I use myself. Let’s start with somewhat simple yet quite effective method of quickly hinting or logging multiple values. This could be done simply by using an array.

hint str []; diag_log [];

Alternatively you can use format command, but [] is just so simple and quick and it even shows undefined variables as “any”. Observe:

hint str [name player, player, _lol]; //["KK",B Alpha 1-1:1 (KK),any] diag_log [123, isServer, vehicles]; //[123,true,[heli]]

As you know, event handlers are special constructs that execute attached code once specified event occurs. The executed code runs in a separate scope than that of invoking script, so passing parameters to it directly with private variables would be not possible. While most event handlers now support {} (CODE) as parameter for attached code, let’s not forget that all of them support “” (STRING) as well. This means we can simply use format command to form a valid string to pass parameters to event handler code.

Let’s assume we need to find out the distance between starting position of the player and his last location when he is killed. We can store his starting position in a variable and reference it after player is killed. Or we can simply store it in the code itself at the moment of event handler creation:

_eh = player addEventHandler [ "Killed", format [ "hint str (%1 distance (_this select 0))", position player ] ];

The code compiled when our event handler is defined and subsequently used will look like this:

hint str ([2479.25,5668.04,0.00143433] distance (_this select 0))

And just in case you wonder what is better, to pass {} or to pass “” to an event handler function, there seem to be no difference in performance, well at least in my own experiments.

player addEventHandler ["fired", "hint name player"]; player addEventHandler ["fired", {hint name player}];

And here is a little neat trick on how to include a file from anywhere in your mission. #include preprocessor command implementation in Arma 3 allows you to only include files from the same directory it was executed:

//Script Location: MISSION_ROOT\test.sqf #include "includes.hpp" //Search Location: MISSION_ROOT\includes.hpp

Or from sub-directories of that directory:

//Script Location: MISSION_ROOT\a\test.sqf #include "b\includes.hpp" //Search Location: MISSION_ROOT\a\b\includes.hpp

If you want to have a centralised include file, #include will just not cut it. But you can use preprocessFileLineNumbers command instead, provided you give it filepath relative to your mission root:

//Script Location: MISSION_ROOT\test.sqf call compile preprocessFileLineNumbers "a\b\c\includes.hpp"; //Search Location: MISSION_ROOT\a\b\c\includes.hpp

And you can include files from top directories while executing your code from sub-directories:

//Script Location: MISSION_ROOT\a\b\test.sqf call compile preprocessFileLineNumbers "includes.hpp"; //Search Location: MISSION_ROOT\includes.hpp

Enjoy,
KK