Jump to content
Sign in to follow this  
UltimateBawb

Help with Patrol Script

Recommended Posts

I've made a short patrol script for car patrols in north and south Stratis, but units don't seem to move anywhere. Can anyone help?

Placed in car's init:

null = [this, "North"] execVM "carPatrol.sqf";

carPatrol.sqf:

_car = _this select 0;
_setType = _this select 1;


while ((alive _car) && !(unitReady _car)) do 
{ 
   sleep 2;
};

while (alive _car) do 
{ 
   if (_locationArray == "North") then {_locationArray = ["markerPatrolNorth", "markerPatrolNorth_1", "markerPatrolNorth_2", "markerPatrolNorth_3", "markerPatrolNorth_4", "markerPatrolNorth_5", "markerPatrolNorth_6", "markerPatrolNorth_7", "markerPatrolNorth_8", "markerPatrolNorth_9"} 
   else {_locationArray = ["markerPatrolSouth", "markerPatrolSouth_1", "markerPatrolSouth_2", "markerPatrolSouth_3", "markerPatrolSouth_4", "markerPatrolSouth_5", "markerPatrolSouth_6", "markerPatrolSouth_7", "markerPatrolSouth_8", "markerPatrolSouth_9"};

   _selectLocation = _locationArray call BIS_fnc_selectRandom;

   (group _car) move (getMarkerPos _selectLocation);

   while {((alive _car) && !(unitReady _car))} do 
   { 
       sleep 2; 
   };
}; 

Edited by UltimateBawb

Share this post


Link to post
Share on other sites

You are missing some semi colons. Try running this through squint or a notepad++ program and it will show the errors.

Share this post


Link to post
Share on other sites

AH SHIT! I completely missed the local variables, guess I just rushed through them. And I am using NP++ by the way. ;)

Thanks, checking now.

EDIT: OP editted to add semicolons, still dosen't work. :/

Edited by UltimateBawb

Share this post


Link to post
Share on other sites

Check your while commands, missing some brackets. I would recommend using squint. :)

Share this post


Link to post
Share on other sites

Ah, fixed. Can't test until tomorrow though. Thanks again. Also, the if statement before the else doesn't need a semicolon, right?

Share this post


Link to post
Share on other sites

Missing [] in your arrays also.

---------- Post added at 01:59 ---------- Previous post was at 01:53 ----------

_car = _this select 0;
_setType = _this select 1;

while {(alive _car) && !(unitReady _car)} do {sleep 2};

while {(alive _car)} do 
{ 
if (_locationArray == "North") then 
   {
	_locationArray = ["markerPatrolNorth", "markerPatrolNorth_1", "markerPatrolNorth_2", "markerPatrolNorth_3", "markerPatrolNorth_4", "markerPatrolNorth_5", "markerPatrolNorth_6", "markerPatrolNorth_7", "markerPatrolNorth_8", "markerPatrolNorth_9"]
   } 
   else 
   {
	_locationArray = ["markerPatrolSouth", "markerPatrolSouth_1", "markerPatrolSouth_2", "markerPatrolSouth_3", "markerPatrolSouth_4", "markerPatrolSouth_5", "markerPatrolSouth_6", "markerPatrolSouth_7", "markerPatrolSouth_8", "markerPatrolSouth_9"]
   };

   _selectLocation = _locationArray call BIS_fnc_selectRandom;

(group _car) move (getMarkerPos _selectLocation);
};

while {(alive _car) && !(unitReady _car)} do {sleep 2};

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  

×