sabot10.5mm 47 Posted April 20, 2017 this script counts units from LVgroup7 on script start, i tried... but lvgroup isnt a variable and i do not know how to get it to wait till they spawn before counting. waitUntil { {alive _x} count (units LVgroup) == 0 }; _Count = {alive _x} count units LVgroup7; //that same math again _Limit = round(_Count * .20); while{true}do{ //infinite loop _Count = {alive _x} count units LVgroup7; //update alive count on each time this loops if(_Count <= _Limit)then{ //if less than 30%, create new instance of reinforcementChopper with same ID (8) hint "Airbourne reinforcements incoming"; nul = ["myMarker3",1,true,false,1000,245,true,200,150,15,0.5,50,false,false,false,true,["myMarker2","myMarker5","myMarker6","myMarker7","myMarker8",250],true,"default",nil,nil,7,false] execVM "LV\heliParadrop.sqf"; waitUntil{sleep 1; ({alive _x} count units LVgroup7)>_Limit}; //to be safe, let's again wait for units to spawn before script continues }; sleep 60; //loops in 4s cycle }; sleep 1; Share this post Link to post Share on other sites
pierremgi 4739 Posted April 20, 2017 LVgroup7 must be a group. LVgroup also. units refers to a group (or object). You can use these variables after naming the groups in editor, or spawning them in a script. For example: LVgroup7 = [ [4774, 473, 150], west, ["uns_ch47_m60_1ac"], [], [], [], [], [], 0] call BIS_fnc_spawnGroup; Then, you can count the units when you need it. If you're scripting a loop which can start before the spawn: [] spawn { waitUntil {sleep 1; !isnil "LVGroup7"}; _LVgrp7cnt = count units LVGroup7; while {true} do { waitUntil {sleep 1; count units LVGroup7 < (_LVgrp7cnt *0.3)}; <your code here>; // nothing more, as you replenish the group (i think) } }; Share this post Link to post Share on other sites
sabot10.5mm 47 Posted April 20, 2017 i tried this [] spawn { } caused the script to not funtion at all, taking out that command made it run but hint "works 3'; never fires. its like the while command doesnt work? [] spawn { waitUntil {sleep 1; !isnil "LVGroup7"}; hint "works 1"; sleep 5; _LVgrp7cnt = count units LVGroup7; hint "works 2"; while {true} do { hint "works 3"; sleep 3; waitUntil {sleep 1; count units LVGroup7 > (_LVgrp7cnt *0.3)}; { //if less than 30%, create new instance of reinforcementChopper with same ID (8) hint "Airbourne reinforcements incoming"; nul = ["myMarker3",1,true,false,1000,245,true,200,150,15,0.5,50,false,false,false,true,["myMarker2","myMarker5","myMarker6","myMarker7","myMarker8",250],true,"default",nil,nil,7,false] execVM "LV\heliParadrop.sqf"; };}; Share this post Link to post Share on other sites
sabot10.5mm 47 Posted April 20, 2017 im happy with this. it first waits for the group to be created and moves on from there.. thanks you for that waitUntil {sleep 1; !isnil "LVGroup7"}; _Count = {alive _x} count units LVgroup7; //that same math again //_Limit = round(_Count * .20); while{true}do{ //infinite loop _Count = {alive _x} count units LVgroup7; //update alive count on each time this loops if(_Count <= 4)then{ //if less than 30%, create new instance of reinforcementChopper with same ID (8) hint "Airbourne reinforcements incoming"; nul = ["myMarker3",1,true,false,1000,245,true,200,150,15,0.5,50,false,false,false,true,["myMarker2","myMarker5","myMarker6","myMarker7","myMarker8",250],true,"default",nil,nil,7,false] execVM "LV\heliParadrop.sqf"; waitUntil{sleep 1; ({alive _x} count units LVgroup7)>5}; //to be safe, let's again wait for units to spawn before script continues }; sleep 4; //loops in 4s cycle }; Share this post Link to post Share on other sites