I have an effect with flies in a mission, it comes in two scripts.
deadguy is unit named that (it's a corpse)
That script is run when a player enters a trigger.
OnActivation [deadguy] exec "flies.sqs"
The SQF is then run from that script as you can see.
_body = _this select 0
_count = 0
#loop
? _count >= 100 : exit
_count = _count + 1
_fly = "HouseFly" createvehicle [(getpos _body select 0) + (2 - random 4), (getpos _body select 1) + (2 - random 4), random 2]
_fly setdir random 360
[_body,_fly] exec "randomfly.sqf"
_fly = ObjNull
~ 0.01
goto "loop"
Laggy