kibaBG 53 Posted February 9 My intent is to call reinforcements depending on the number of alive units. I have the reinforcements scripts made as functions. The problem is everything is spawning at the mission start. //ifs.sqf ran from initServer.sqf if ((count allUnits) < 250) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 225) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 200) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 175) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 150) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 125) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 100) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 75) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 50) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; if ((count allUnits) < 25) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; Looks like every if statement is TRUE so everything spawns, maybe ( 225 < (count allUnits) < 250) ? And one additional question, can I call a function two times if I need more reinforcements? call KIB_fnc_mehSqus; call KIB_fnc_mehSqus; Share this post Link to post Share on other sites
Harzach 2517 Posted February 9 If you have fewer than 25 units existing at mission start, all of the conditions will return true, yes. Functions are ideal for repeated calls, so yes. 1 Share this post Link to post Share on other sites
kibaBG 53 Posted February 9 I am so dumb I just have to add sleep so it counts the units after they spawn. And I made the condition like this sleep 30; if ((250 < (count allUnits)) && ((count allUnits) < 275)) then { ["reinforcements_incoming"] call BIS_fnc_showNotification; call KIB_fnc_mehSqus; call KIB_fnc_specOps; }; Thanks for the fast respond. Share this post Link to post Share on other sites
kibaBG 53 Posted February 10 Unfortunately, as our last mission showed, no reinforcements were spawned this way ... Share this post Link to post Share on other sites
mrcurry 505 Posted February 11 On 2/10/2024 at 4:50 AM, kibaBG said: Unfortunately, as our last mission showed, no reinforcements were spawned this way ... Well in the code you shown you're only checking all the conditions once, 30 s after script start, if you want it to check multiple times you have to loop the check with a while, for or multiple waitUntil's. Also, 250 units at one time, maybe my perspective is skewed but "that's a whole 'nother company"... Are your (server's) frames ok? Share this post Link to post Share on other sites
kibaBG 53 Posted February 12 So IF statement needs a loop after all, I thought it checks the condition by itself. 250 units are no problem with dedicated and one headless, 100 of them are garrisoned with dynamic simulation enabled, etc, we play with 60 fps most of the time. Share this post Link to post Share on other sites