Jump to content
Sign in to follow this  
kibaBG

Reinforcements and IF statement

Recommended Posts

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

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.

  • Thanks 1

Share this post


Link to post
Share on other sites

I am so dumb :face_palm: 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

Unfortunately, as our last mission showed, no reinforcements were spawned this way ... :hang: 

Share this post


Link to post
Share on other sites
On 2/10/2024 at 4:50 AM, kibaBG said:

Unfortunately, as our last mission showed, no reinforcements were spawned this way ... :hang: 

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×