If you haven't solved this yet, or if you have and others are wondering how to do this, try the following. I use a random headgear script for some of my units, and this is how I do it:
In the following script, replace Item0, Item1, etc with the names of your headgear items, and save the file as whatever you wish to call it.
_Unit = _this select 0;
_HeadGear = ["Item0","Item1","Item2","Item3","Item4","Item5"];
_CountH = count _HeadGear;
RemoveHeadgear _unit;
_unit AddHeadgear (_headgear select floor random _CountH);
Then, put the following in the unit's config:
class EventHandlers: EventHandlers
{
init = "[(_this select 0)] execVM ""\AddonName\ScriptName.sqf""";
};
It's important to note that whatever your unit's parent class is, must have 'class eventhandlers;' in its config entry, since this EventHandlers script has a parent EventHandlers class. I create a base unit (with a private scope so it can't be placed/created in-game) with 'class Eventhandlers;' in its config, then base the rest of my units off that one, so they're inheriting its attributes.