Jump to content
Sign in to follow this  
quintusairborne

Using the sleep command inside an sqf script

Recommended Posts

Hello boys.

I have a problem; I'm making a mission that requires a group of players to gradually fall back in front of waves of enemys, spawned using a sqf script.

That script works fine, it even loops when I tell him to, while I preview it or I host it without other players; but each time I host it with my friends everything goes to hell. The enemyes spawn in a continuoos river leading to, well, interesting situations, lack of ammunitons and crashes. :confused:

The problem, as I think I have understand, is in the sleep command, that is ignored while I run in MP that script. It seems not to matter whether I start it in the init file or via trigger.

Anybody will be so kind to teach me a way to solve this problem? I checked in the forum but I did not find a solution, and I'm pretty new to scripting so I may have made some ridicously simple mistake.

This is the script I'm working with:

if (isServer) then {

waituntil {fallback1};

while {fallback1} do {

grp1= Creategroup resistance;

_Unit1= grp1 createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit2= grp1 createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit3= grp1 createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit4= grp1 createUnit ["zetaborn_alien5",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

_unit1 setunitrank "CAPTAIN";

_unit1=leader grp1;

{_x setCombatMode "RED"} forEach units grp1;

{_x setBehaviour "AWARE"} forEach units grp1;

sleep 1;

_wp0 = grp1 addWaypoint [getpos pa_1, 0];

_wp0 setWaypointType "SAD";

_wp0 setWaypointSpeed "NORMAL";

sleep 20;

grp1b= Creategroup resistance;

_Unit5= grp1b createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit6= grp1b createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit7= grp1b createUnit ["zetaborn_alien2",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

sleep 1;

_Unit8= grp1b createUnit ["zetaborn_alien5",[getPos startpoint_1 select 0, getPos startpoint_1 select 1,0],[],0,"FORM"];

_unit5 setunitrank "CAPTAIN";

_unit5=leader grp1b;

{_x setCombatMode "RED"} forEach units grp1b;

{_x setBehaviour "AWARE"} forEach units grp1b;

sleep 1;

_wp0 = grp1b addWaypoint [getpos pa_1, 0];

_wp0 setWaypointType "SAD";

_wp0 setWaypointSpeed "NORMAL";

sleep 90;

};

};

};

The script is called in the init file:

fallback1 = false;

_null = [] execVM "red1.sqf";

and activated when a trigger sets fallback1 = true.

And yes, those are aliens, of the Zetaborn mod. Sometimes you need to shoot at something different. :greetings:

Edited by QuintusAirborne

Share this post


Link to post
Share on other sites

Hi.

If you execute a script in the init.sqf, everyone will execute it. Which means that (in multiplayer) all the pc's are fighting each other; telling where the AI should go.

Instead, you could try and change the red1.sqf line into this:

if (isServer) then {
fallback1 = false;
_null = [] execVM "red1.sqf";
};

Test that and see what happens :)

Share this post


Link to post
Share on other sites

You are welcome.

---------- Post added at 15:20 ---------- Previous post was at 15:14 ----------

One other tip: do not put any code inside the isServer check if it is requiring action from a real person. That way, it won't work on a dedicated server.

Any other scripts (like for example the one you have) should be fine.

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  

×