Jump to content
Sign in to follow this  
clydefrog

adding +1 to a variable multiple times then counting not working

Recommended Posts

I changed the group names to the names of the groups I'm using

so scud1, scud2, scud3, scud4, scud5

all the group names are defined in the scripts that spawns each of them and they work because the final trigger checks the number of alive units is 0 for each of those groups then gives a task completed hint.

But if it works for you I must be doing something wrong.

The script could be easily implemented in to the SCUD-spawning code. Do you mind if I have a look at it? The problem is that the forEach is trying to loop trough undefined variables, since the SCUD's or their groups have not spawned yet.

Share this post


Link to post
Share on other sites

Ahh right. Yes well there are 2 scripts, the one that actually makes everything work then the one that you select the vehicle/group of vehicles with and set parameters for them.

Here is the main script (VehPatrol_fnc.sqf):

if (!isServer) exitWith {};

RYD_RandomAround = 
   {
   private ["_pos","_posX","_posY","_posZ","_radius"];

   _pos = _this select 0;
   _radius = _this select 1;

   _posX = (_pos select 0) + (2 * (random _radius)) - _radius;
   _posY = (_pos select 1) + (2 * (random _radius)) - _radius;
   _posZ = 0;
   if ((count _pos) == 3) then {_posZ = (_pos select 2) + (random _radius) - (_radius/2)};

   while {([_posX,_posY,_posZ] distance _pos) > _radius} do
       {
       _posX = (_pos select 0) + (2 * (random _radius)) - _radius;
       _posY = (_pos select 1) + (2 * (random _radius)) - _radius;
       if ((count _pos) == 3) then {_posZ = (_pos select 2) + (2 * (random _radius)) - _radius};
       };

   _pos = [_posX,_posY,_posZ];

   _pos    
   };

RYD_NearestCross = 
   {
   private ["_crosses","_pos","_chosen","_dist","_distC"];
   _crosses = _this select 0;
   _pos = _this select 1;

   _chosen = _crosses select 0;
   _distC = (getPosASL _chosen) distance _pos;

       {
       _dist = (getPosASL _x) distance _pos;
       if (_dist <_distC) then {_chosen = _x;_distC = _dist} 
       }
   foreach _crosses;

   _chosen
   };

RYD_CrossroadsNear = 
   {
   private ["_pos","_radius","_roads","_cross"];

   _pos = _this select 0;
   _radius = _this select 1;

   _roads = _pos nearRoads _radius;
   _cross = [];

       {
       if (count (roadsConnectedTo _x) > 2) then {_cross set [(count _cross),_x]};
       }
   foreach _roads;

   _cross
   };

RYD_SummonV =     
   {
   private ["_types","_type","_specific","_mono","_side","_place","_nbr","_state","_lock","_cType","_westC","_eastC","_resC","_HQ","_SummonedGrp","_veh","_ifOA160",
   "_frPos","_crew0","_crew1","_crew2","_dir","_cargoN","_sets","_Cgrp","_ldr","_uCg","_kind","_crewClass","_spd","_plZ","_mpl"];

   _specific = _this select 0;
   _side = _this select 1;
   _place = _this select 2;
   _nbr = _this select 3;
   _state = _this select 4;
   _lock = _this select 5;
   _kind = _this select 6;
   _crewClass = "";
   if ((count _this) > 7) then {_crewClass = _this select 7};

   _cType = _crewClass;
   _westC = _crewClass;
   _eastC = _crewClass;
   _resC = _crewClass;

   if (_crewClass == "") then
       {
       switch (_kind) do
           {
           case ("AIR") : {_westC = "USMC_Soldier_Pilot";_eastC = "RU_Soldier_Pilot";_resC = "GUE_Soldier_Pilot"};
           case ("TANK") : {_westC = "USMC_Soldier_Crew";_eastC = "RU_Soldier_Crew";_resC = "GUE_Soldier_Crew"};
           case ("LIGHT") : {_westC = "USMC_Soldier";_eastC = "RU_Soldier";_resC = "GUE_Soldier_1"};
           default {_westC = "USMC_Soldier_Crew";_eastC = "RU_Soldier_Crew";_resC = "GUE_Soldier_Crew"}
           }
       };

   switch (_side) do
       {
       case (west) : {_cType = _westC};
       case (east) : {_cType = _eastC};
       default {_cType = _resC};
       };

   _type = "";

   _HQ = createCenter _side;
   _SummonedGrp = createGroup _side;
   while {(_nbr > 0)} do
       {
       if not ((count _specific) == 0) then {_type = _specific select (floor (random (count _specific)))};
       _veh = createVehicle [_type, _place, [], 0, _state];
       _ifOA160 = Alldead;
       if not (isNil ("_ifOA160")) then {_veh allowCrewInImmobile true};

       _frPos = _veh emptyPositions "commander";
       if (_frPos > 0) then 
           {
           _crew0 = _SummonedGrp createUnit [_cType, _place, [], 0, "NONE"];
           _crew0 assignAsCommander _veh;
           _crew0 moveInCommander _veh;
           _crew0 setSkill (0.4 + (random 0.2) + (random 0.2))
           };

       _frPos = _veh emptyPositions "driver";
       if (_frPos > 0) then 
           {
           _crew1 = _SummonedGrp createUnit [_cType, _place, [], 0, "NONE"];
           _crew1 assignAsDriver _veh;
           _crew1 moveInDriver _veh;
           _crew1 setSkill (0.4 + (random 0.25) + (random 0.25))
           };

       _frPos = _veh emptyPositions "gunner";
       if (_frPos > 0) then 
           {
           _crew2 = _SummonedGrp createUnit [_cType, _place, [], 0, "NONE"];
           _crew2 assignAsGunner _veh;
           _crew2 moveInGunner _veh;
           _crew2 setSkill (0.4 + (random 0.25) + (random 0.25))
           };

       _nbr = _nbr - 1;

       _plZ = 0;
       _mpl = 1;

       if (_lock) then {_veh lock true};

       if (_state == "FLY") then 
           {
           _dir = direction _veh;
           _spd = (getNumber (configFile>>"cfgvehicles">>_type>>"maxspeed") + getNumber (configFile>>"cfgvehicles">>_type>>"landingSpeed")) / 7.2;
           _veh setVelocity [(sin _dir) * _spd,(cos _dir) * _spd,0];
           _mpl = 2;
           _plZ = (_place select 2) + 25 * _mpl;
           };

       _place = [(_place select 0) + 8 * _mpl,(_place select 1) + 8 * _mpl,_plZ];
       };

   _SummonedGrp
   };

RYD_PatrolPointsAround = 
   {
   private ["_sourceP","_radiusMin","_radiusMax","_min","_above","_points","_minPC","_point","_posX","_posY","_pos","_ct","_isFlat"];
   _sourceP = [];

   if ((typename (_this select 0)) == 'OBJECT') then 
       {
       _sourceP = getPosASL (_this select 0);
       } 
   else 
       {
       _sourceP = _this select 0;
       };

   _radiusMin = _this select 1;
   _radiusMax = _this select 2;
   _min = _this select 3;
   _above = _this select 4;

   _points = [];
   _minPC = _min + (round (random _above));
   while {((count _points) < _minPC)} do
       {
       _point = [_sourceP,_radiusMax] call RYD_RandomAround;
       _posX = _point select 0;
       _posY = _point select 1;
       _pos = [_posX,_posY];
       _ct = 0;

       _isFlat = _pos isFlatEmpty [5,0,1,5,0,false,objNull];

       while {((((_pos distance _sourceP) < _radiusMin) or not ((count _isFlat) == 0)) and (_ct < 500))} do
           {
           _point = [_sourceP,_radiusMax] call RYD_RandomAround;
           _posX = _point select 0;
           _posY = _point select 1;
           _pos = [_posX,_posY];
           _isFlat = _pos isFlatEmpty [5,0,1,5,0,false,objNull];
           _ct = _ct + 1;
           };

       _points set [(count _points),_pos];
       };

   _points
   };

RYD_PatrolWP = 
   {
   private ["_unit","_uG","_protected","_type","_beh","_CM","_speed","_form","_stat","_cyclic","_rMin","_rMax","_acc","_minA","_maxA","_deleteAll","_nE","_points","_points2","_WPs","_wp","_i"];
   _unit = ObjNull;
   _uG = GrpNull;

   if ((typename (_this select 0)) == "OBJECT") then 
       {
       _unit = _this select 0;
       _uG = group _unit;
       } 
   else 
       {
       _uG = _this select 0;
       _unit = leader (_uG)
       };

   _protected = _this select 1;

   if ((typename (_this select 1)) == "OBJECT") then
       {
       _protected = getPosATL _protected
       }
   else
       {
       if ((typename (_this select 1)) == "STRING") then
           {
           _protected = getMarkerPos _protected
           }
       };

   _type  = "MOVE";
   if ((count _this) > 2) then {_type = _this select 2};
   _beh = "AWARE";
   if ((count _this) > 3) then {_beh = _this select 3};
   _CM = "YELLOW";
   if ((count _this) > 4) then {_CM = _this select 4};
   _speed = "NORMAL";
   if ((count _this) > 5) then {_speed = _this select 5};
   _form = "COLUMN";
   if ((count _this) > 6) then {_form = _this select 6};
   _stat = ["true",""];
   if ((count _this) > 7) then {_stat = _this select 7};
   _cyclic = true;
   if ((count _this) > 8) then {_cyclic = _this select 8};
   _rMin = 300;
   if ((count _this) > 9) then {_rMin = _this select 9};
   _rMax = 600;
   if ((count _this) > 10) then {_rMax = _this select 10};
   _acc = 0;
   if ((count _this) > 11) then {_acc = _this select 11};
   _minA = 2;
   if ((count _this) > 12) then {_minA = _this select 12};
   _maxA = 5;
   if ((count _this) > 13) then {_maxA = _this select 13};
   _deleteAll = true;
   if ((count _this) > 14) then {_deleteAll = _this select 14};

   if (_deleteAll) then 
       {
       while {((count (waypoints _uG)) > 0)} do
           {
           deleteWaypoint ((waypoints _uG) select (count (waypoints _uG) - 1));
           }
       }
   else
       {
       deleteWaypoint ((waypoints _uG) select 0);
       };

   _points = [_protected];
   _points2 = [_unit,_rMin,_rMax,_minA,_maxA] call RYD_PatrolPointsAround;
   _points = _points + _points2;
   _WPs = [];

       {
       _wp = _uG addWaypoint [_x, _acc];
       _wp setWaypointType _type;
       _wp setWaypointBehaviour _beh;
       _wp setWaypointCombatMode _CM;
       _wp setWaypointSpeed _speed;
       _wp setWaypointFormation _form;
       _wp setWaypointStatements _stat;

       _WPs set [(count _WPs),_wp];
       }
   foreach _points;

   if (_cyclic) then 
       {
       _wp = _uG addWaypoint [(_points select 0), _acc];
       _wp setWaypointType "CYCLE";
       _wp setWaypointBehaviour _beh;
       _wp setWaypointCombatMode _CM;
       _wp setWaypointSpeed _speed;
       _wp setWaypointFormation _form;
       _wp setWaypointStatements _stat;

       _WPs set [(count _WPs),_wp];
       };

   _uG setCurrentWaypoint (_WPs select 0);

   _WPs
   };

RYD_RoadPatrol = 
   {
   private ["_uG","_type","_beh","_CM","_speed","_form","_stat","_cyclic","_radius","_minTO","_addTO","_deleteAll","_Centrum","_nC","_points","_cross","_pos","_WPs","_points2","_next","_wp"];
   _uG = _this select 0;

   _type  = "GETOUT";
   if ((count _this) > 1) then {_type = _this select 1};
   _beh = "SAFE";
   if ((count _this) > 2) then {_beh = _this select 2};
   _CM = "YELLOW";
   if ((count _this) > 3) then {_CM = _this select 3};
   _speed = "LIMITED";
   if ((count _this) > 4) then {_speed = _this select 4};
   _form = "COLUMN";
   if ((count _this) > 5) then {_form = _this select 5};
   _stat = ["true","(units (group this)) orderGetIn true;if not (isPlayer this) then {(assignedVehicle this) setFuel 1}"];
   if ((count _this) > 6) then {_stat = _this select 6};
   _cyclic = true;
   if ((count _this) > 7) then {_cyclic = _this select 7};
   _radius = 5000;
   if ((count _this) > 8) then {_radius = _this select 8};
   _minTO = 60;
   if ((count _this) > 9) then {_minTO = _this select 9};
   _addTO = 360;
   if ((count _this) > 10) then {_minTO = _this select 10};
   _deleteAll = true;
   if ((count _this) > 11) then {_deleteAll = _this select 11};

   if (_deleteAll) then 
       {
       while {((count (waypoints _uG)) > 0)} do
           {
           deleteWaypoint ((waypoints _uG) select (count (waypoints _uG) - 1));
           }
       }
   else
       {
       deleteWaypoint ((waypoints _uG) select 0);
       };

   _Centrum = position (vehicle (leader _uG));

   _WPs = [];

   _nC = nearestLocations [_Centrum, ["NameVillage","NameCity","NameCityCapital"], _radius];

   if ((count _nC) > 0) then
       {
       _points = [];

           {
           _cross = [[(position _x),500] call RYD_CrossroadsNear,(position _x)] call RYD_NearestCross;
           _pos = position _x;
           if not (isNull _cross) then {_pos = position _cross};
           _points set [(count _points),_pos]
           }
       foreach _nC;

       _points2 = _points;

           {
           _next = _points select (floor (random (count _points)));
           _points = _points - [_next];
           _wp = _uG addWaypoint [_next, 0];
           _wp setWaypointType _type;
           _wp setWaypointBehaviour _beh;
           _wp setWaypointCombatMode _CM;
           _wp setWaypointSpeed _speed;
           _wp setWaypointFormation _form;
           _wp setWaypointStatements _stat;
           _wp setWaypointTimeout [_minTO,(_minTO +_addTO)/2, _addTO];

           _WPs set [(count _WPs),_wp];

           _wp = _uG addWaypoint [_next, 0];
           _wp setWaypointType "GETIN";
           _wp setWaypointBehaviour _beh;
           _wp setWaypointCombatMode _CM;
           _wp setWaypointSpeed _speed;
           _wp setWaypointFormation _form;
           _wp setWaypointTimeout [5,5,5];

           _WPs set [(count _WPs),_wp];
           }
       foreach _points2;

       if (_cyclic) then 
           {
           _wp = _uG addWaypoint [(_points select 0), 0];
           _wp setWaypointType "CYCLE";
           _wp setWaypointBehaviour _beh;
           _wp setWaypointCombatMode _CM;
           _wp setWaypointSpeed _speed;
           _wp setWaypointFormation _form;
           _wp setWaypointStatements _stat;

           _WPs set [(count _WPs),_wp];
           };

       _uG setCurrentWaypoint (_WPs select 0)
       };

   _WPs
   };

/////////////////
//MAIN FUNCTION//
/////////////////

RYD_Patrol = 
   {
   private ["_types","_side","_place","_nbr","_state","_lock","_kind","_crewClass","_grp","_WPs","_onRoads","_radius",
   "_type","_beh","_CM","_speed","_form","_stat","_cyclic","_rMin","_rMax","_acc","_minA","_maxA","_deleteWP","_minTO","_addTO"];

//spawning config

   _types = _this select 0;//array of vehicle classes to random choose from
   _side = _this select 1;//side of patrol
   _place = _this select 2;//point of spawn
   _nbr = _this select 3;//vehicles amount
   _state = _this select 4;//"CAN_COLLIDE","FORM","NONE" or "FLY"
   _lock = _this select 5;//if is locked
   _kind = _this select 6;//"LIGHT","TANK" or "AIR". Matters, when crew class is not defined
   _crewClass = "";
   if ((count _this) > 7) then {_crewClass = _this select 7};//optional - class of crew members, set as empty string if not used

//patrol config

   _type  = "MOVE";
   if ((count _this) > 8) then {_type = _this select 8};//optional. Type of waypoints. Default: "MOVE"
   _beh = "SAFE";
   if ((count _this) > 9) then {_beh = _this select 9};//optional. Behavior of waypoints. Default: "SAFE" (recommended for "onRoads" mode)
   _CM = "YELLOW";
   if ((count _this) > 10) then {_CM = _this select 10};//optional.Combat mode of waypoints. Default: "YELLOW"
   _speed = "NORMAL";
   if ((count _this) > 11) then {_speed = _this select 11};//optional. Speed of waypoints. Default: "NORMAL"
   _form = "COLUMN";
   if ((count _this) > 12) then {_form = _this select 12};//optional. Type of waypoints. Default: "COLUMN"
   _stat = ["true",""];
   if ((count _this) > 13) then {_stat = _this select 13};//optional. Type of waypoints. Default: ["true",""]
   _cyclic = true;
   if ((count _this) > 14) then {_cyclic = _this select 14};//optional. If patrol should be looped. Default: true
   _deleteWP = true;
   if ((count _this) > 15) then {_deleteWP = _this select 15};//optional. If should be deleted initially added to that group waypoint(s). Default: true
   _onRoads = false;
   if ((count _this) > 16) then {_onRoads = _this select 16};//optional. If patrol should move from nearby town to town using roads. Default: false
   _rMin = 100;
   if ((count _this) > 17) then {_rMin = _this select 17};//optional. Matters only, when patrol is not in "onRoads" mode. Minimum distance of each waypoint from starting point. Default: 100
   _rMax = 2000;
   if ((count _this) > 18) then {_rMin = _this select 18};//optional. Matters only, when patrol is not in "onRoads" mode. Maximum distance of each waypoint from starting point. Default: 2000
   _acc = 0;
   if ((count _this) > 19) then {_acc = _this select 19};//optional. Matters only, when patrol is not in "onRoads" mode. Random placement radius for each waypoint. Default: 0
   _minA = 3;
   if ((count _this) > 20) then {_minA = _this select 20};//optional. Matters only, when patrol is not in "onRoads" mode. Minimum number of waypoints (excluding start and cycle at end if looped). Default: 3
   _maxA = 10;
   if ((count _this) > 21) then {_maxA = _this select 21};//optional. Matters only, when patrol is not in "onRoads" mode. From this value is randomized number of additional (above minimum) number of waypoints. Set to 0 to achieve exact, minimal number of waypoints each time. Default: 10
   _radius = 5000;
   if ((count _this) > 22) then {_radius = _this select 22};//optional. Matters only, when patrol is in "onRoads" mode. Radius for towns search (maximum patrol checkpoints radius). Default: 5000
   _minTO = 0;
   if ((count _this) > 23) then {_minTO = _this select 23};//optional. Matters only, when patrol is in "onRoads" mode. Minimum pause time in seconds at each waypoint. Default: 0
   _addTO = 0;
   if ((count _this) > 24) then {_minTO = _this select 24};//optional. Matters only, when patrol is in "onRoads" mode. Maximum pause time in seconds at each waypoint (in each town). Default: 0

   _WPs = [];

   _grp = [_types,_side,_place,_nbr,_state,_lock,_kind,_crewClass] call RYD_SummonV;

   if not (_onRoads) then
       {
       _WPs = [_grp,_place,_type,_beh,_CM,_speed,_form,_stat,_cyclic,_rMin,_rMax,_acc,_minA,_maxA,_deleteWP] call RYD_PatrolWP
       }
   else
       {
       _WPs = [_grp,_type,_beh,_CM,_speed,_form,_stat,_cyclic,_radius,_minTO,_addTO,_deleteWP] call RYD_RoadPatrol;
       };

   [_grp,_WPs]
   };  

and here is the script where the scud and it's parameters are spawned from and it's group is named (scud1.sqf):



_config = 
       [
       ["MAZ_543_SCUD_TK_EP1"],    //array of vehicle classes to random choose from
       east,                    //side of patrol
      getmarkerpos "scud1start",            //point of spawn
       1,                    //vehicles amount
       "FORM",            //"CAN_COLLIDE","FORM","NONE" or "FLY"
       false,                    //if is locked
       "TANK",                    //"LIGHT","TANK" or "AIR". Matters, when crew class is not defined. Determines kind of crew units
       "TK_Soldier_Crew_EP1",            //optional - class of crew members, set as empty string if not used

       "MOVE",                //optional. Type of waypoints. Default: "MOVE"
       "SAFE",                //optional. Behavior of waypoints. Default: "SAFE" (recommended for "onRoads" mode)
       "YELLOW",                //optional.Combat mode of waypoints. Default: "YELLOW"
       "LIMITED",                //optional. Speed of waypoints. Default: "NORMAL"
       "COLUMN",                //optional. Type of waypoints. Default: "COLUMN"
       ["true","(units (group this)) orderGetIn true;if not (isPlayer this) then {(assignedVehicle this) setFuel 1}"],            //optional. Type of waypoints. Default: ["true",""];
       true,                    //optional. If patrol should be looped. Default: true
       true,                    //optional. If should be deleted initially added to that group waypoint(s). Default: true
       true,                //optional. If patrol should move from nearby town to town using roads. Default: false
       250,                    //optional. Matters only, when patrol is not in "onRoads" mode. Minimum distance of each waypoint from starting point. Default: 100
       1000,                    //optional. Matters only, when patrol is not in "onRoads" mode. Maximum distance of each waypoint from starting point. Default: 2000
       100,                    //optional. Matters only, when patrol is not in "onRoads" mode. Random placement radius for each waypoint. Default: 0
       3,                    //optional. Matters only, when patrol is not in "onRoads" mode. Minimum number of waypoints (excluding start and cycle at end if looped). Default: 3
       5,                    //optional. Matters only, when patrol is not in "onRoads" mode. From this value is randomized number of additional (above minimum) number of waypoints. Set to 0 to achieve exact, minimal number of waypoints each time. Default: 10
       2000,                    //optional. Matters only, when patrol is in "onRoads" mode. Radius for towns search (maximum patrol checkpoints radius). Default: 5000
       30,                    //optional. Matters only, when patrol is in "onRoads" mode. Minimum pause time in seconds at each waypoint. Default: 0
       60                    //optional. Matters only, when patrol is in "onRoads" mode. Maximum pause time in seconds at each waypoint (in each town). Default: 0
       ];

   scud1 = (_config call RYD_Patrol) select 0;  

There is also this line in the init.sqf which calls the main script at the start:

call compile preprocessfile "VehPatrol_fnc.sqf";

Edited by clydefrog

Share this post


Link to post
Share on other sites

You can get it working by doing the following in init.sqf:

1)

[color=#333333]call compile preprocessFile "VehPatrol_fnc.sqf";[/color]

2)

{[color=#333333]call compile [/color][color=#333333]preprocessFile _x[/color][color=#333333]} forEach ["[/color][color=#333333]scud1.sqf", [/color][color=#333333]"[/color][color=#333333]scud2.sqf", [/color][color=#333333]"[/color][color=#333333]scud3.sqf", [/color][color=#333333]"[/color][color=#333333]scud4.sqf", [/color][color=#333333]"[/color][color=#333333]scud5.sqf"];[/color]

3)

if (isServer) then {
   vehicles_destroyed = 0;
   publicVariable "vehicles_destroyed";


   {
       if ((count (units _x)) == 1) then {
           (vehicle (leader _x)) addEventHandler ["Killed", 
               {
                   vehicles_destroyed = vehicles_destroyed + 1;
                   publicVariable "vehicles_destroyed";


                   hint format ["Vehicle destroyed, %1 vehicles remaining.", (5 - vehicles_destroyed)];
               }
           ];
       };
   } forEach [grpOne, grpTwo, grpThree];
};


waitUntil {!(isNil "vehicles_destroyed")};
"vehicles_destroyed" addPublicVariableEventHandler {
   hint format ["Vehicle destroyed, %1 vehicles remaining.", (5 - vehicles_destroyed)];
};

Edit:

Step one and two you might want to only run on the server like so:

if (isServer) then {
   call compile preprocessFile "VehPatrol_fnc.sqf";
   {call compile preprocessFile _x} forEach ["scud1.sqf", "scud2.sqf", "scud3.sqf", "scud4.sqf", "scud5.sqf"];
};

And then add rest of the code.

Edited by qbt

Share this post


Link to post
Share on other sites

Ok it's working now but there's a problem, all the scuds spawn when the mission starts but I want them to spawn through a script when a blufor trigger is activated.

e.g.

Blufor present

condition: this

onAct: null = [this] execVM "scudspawns.sqf":

nul = [this] execVM "scud1.sqf";
sleep 10;
nul = [this] execVM "scud2.sqf";
sleep 10;
nul = [this] execVM "scud3.sqf";
sleep 10;
nul = [this] execVM "scud4.sqf";
sleep 10;
nul = [this] execVM "scud5.sqf";

Edited by clydefrog

Share this post


Link to post
Share on other sites
Ok it's working now but there's a problem, all the scuds spawn when the mission starts but I want them to spawn through a script when a blufor trigger is activated.

e.g.

Blufor present

condition: this

onAct: null = [this] execVM "scudspawns.sqf":

nul = [this] execVM "scud1.sqf";
sleep 10;
nul = [this] execVM "scud2.sqf";
sleep 10;
nul = [this] execVM "scud3.sqf";
sleep 10;
nul = [this] execVM "scud4.sqf";
sleep 10;
nul = [this] execVM "scud5.sqf";

No problem!

init.sqf

if (isServer) then {
   vehicles_destroyed = 0;
   publicVariable "vehicles_destroyed";
};


waitUntil {!(isNil "vehicles_destroyed")};
"vehicles_destroyed" addPublicVariableEventHandler {
   hint format ["Vehicle destroyed, %1 vehicles remaining.", (5 - vehicles_destroyed)];
};

scudspawns.sqf

{
   call compile preprocessFile _x; sleep 10
} forEach ["scud1.sqf", "scud2.sqf", "scud3.sqf", "scud4.sqf", "scud5.sqf"];


{
   (vehicle (leader _x)) addEventHandler ["Killed", 
       {
           vehicles_destroyed = vehicles_destroyed + 1;
           publicVariable "vehicles_destroyed";

           hint format ["Vehicle destroyed, %1 vehicles remaining.", (5 - vehicles_destroyed)];
       }
   ];
} forEach [scud1, scud2, scud3, scud4, scud5];

Edited by qbt
Updated script.

Share this post


Link to post
Share on other sites

Now it's not working again, a hint comes up at the mission start saying "vehicle destroyed, 5 vehicles remaining" and then no hints come up when I actually destroy the vehicles, I don't really want to take any more of your time over this though.

Share this post


Link to post
Share on other sites
Now it's not working again, a hint comes up at the mission start saying "vehicle destroyed, 5 vehicles remaining" and then no hints come up when I actually destroy the vehicles, I don't really want to take any more of your time over this though.

I made too many iterations and got confused myself. I updated the script in my last post, it should work now!

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  

×