Forum Jump :

Author Message

Posts: 1

Level: Member

Country: se
Age: 24
In-game name: Adam

#1 Posted at 2016-01-11 19:09        
I'm pretty new to scripts and I'm currently making a night mission where OPFOR doesn't have any NVG, so they have to shoot flares to be able to see.

I want it to be a falling and so far I have been using this in a triggered area:
flrObj = "F_40mm_red" createvehicle ((player) ModelToWorld [0,100,200]); flrObj setVelocity [0,0,-10];

It works pretty well, but the thing is that I want the flares to keep spawning (or "firing) as long as the OPFOR squad is alive and in combat. With the script I'm using, it only spawn the flare once. I'm having problems finding the right script for this. Anyone who knows a little bit more about this who can help?

Author Message

Posts: 176

Level: Member

Country: pl
In-game name:

#2 Posted at 2016-01-11 20:22        
There are several approaches. One is a loop, for example while:
while {condition} do { code  };

in your case:

private _grp = AI GROUP HERE //< Group declaration
private _aliveCnt = {alive _x} count (units _grp); //< counting alive units for start

while {_aliveCnt > 0} do {
 private _cM = combatMode _grp; //< Check combat mode
 if (_cM != "RED") then {
   waitUntil { _cM == "RED" }; //< If not in combat mode, wait until 

 private _flrObj = "F_40mm_red" createvehicle ((player) ModelToWorld [0,100,200]); //< your code
 _flrObj setVelocity [0,0,-10];

 sleep (20 + (random 30)); //< sleep to not flood 
 _aliveCnt = {alive _x} count (units _grp); //< recalculate live units

Its just example, not tested, only to show idea. More about loops:

Also remeber to run code server side only. If you run this code on every client, there will be as many instances as players + server.