RS30002 28 Posted June 13, 2022 So...have this script that id like to "featurify" //nul = execVM "scripts\Convoy.sqf"; if (isServer) then { _spawn = selectRandom [[8160.49,9756.76,0],[5627.6,11179.5,0],[6192.19,8574.57,0],[5387.58,9308.15,0],[7221.36,10170.5,0],[7235.13,8206.8,0]]; _destinations = selectRandom [[3041.08,6268.01,0],[5724.09,3534.61,0],[7910.19,4112.91,0],[8277.03,6040.78,0],[3688.16,3397.91,0],[1157.59,596.056,0]]; _centerspawn = selectRandom [[5663.42,6979.83,0],[7092.33,6241.3,0],[3650.26,8450.71,0],[4978.65,7449.72,0]]; _truck = selectRandom ["O_T_MRAP_02_hmg_ghex_F","O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F"] createVehicle _spawn; truck = _truck; sleep 0.1; _2ndspawn = (_truck getrelPos [-10, 0]); _truck2 = selectRandom ["O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F"] createVehicle _2ndspawn; truck2 = _truck2; sleep 0.1; truckers1 = creategroup east; "O_T_Soldier_F" createUnit [[1,0,0],truckers1,"trucker1 = this; trucker1 moveindriver truck",0.8,"corporal"]; "O_T_Soldier_F" createUnit [[0,1,0],truckers1,"trucker2 = this; trucker2 moveindriver truck2",0.6,"private"]; if (truck isEqualTo "O_T_MRAP_02_hmg_ghex_F") then { "O_T_Soldier_F" createUnit [[1.5,0,0],truckers1,"trucker5 = this; trucker5 moveingunner truck",0.8,"private"]}; truckers1 setbehaviour "careless"; truckers1 setformation "column"; //_cycle1 = (_spawn getrelPos [0.2, 0]); _wp = truckers1 addWaypoint [_destinations, 0]; _wp setWaypointType "MOVE"; _wp setWaypointSpeed "LIMITED"; _wp1 = truckers1 addWaypoint [_spawn, 0]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointSpeed "LIMITED"; _wp2 = truckers1 addWaypoint [_spawn, 0]; _wp2 setWaypointType "CYCLE"; _wp2 setWaypointSpeed "LIMITED"; _truck3 = selectRandom ["O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F","O_T_MRAP_02_hmg_ghex_F"] createVehicle _destinations; truck3 = _truck3; sleep 0.1; _4thspawn = (_truck3 getrelPos [-10, 0]); _truck4 = selectRandom ["O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F"] createVehicle _4thspawn; truck4 = _truck4; sleep 0.1; truckers2 = creategroup east; "O_T_Soldier_F" createUnit [[1,0,0],truckers2,"trucker3 = this; trucker3 moveindriver truck3",0.8,"corporal"]; "O_T_Soldier_F" createUnit [[0,1,0],truckers2,"trucker4 = this; trucker4 moveindriver truck4",0.6,"private"]; if (truck3 isEqualTo "O_T_MRAP_02_hmg_ghex_F") then { "O_T_Soldier_F" createUnit [[1.5,0,0],truckers2,"trucker6 = this; trucker6 moveingunner truck3",0.8,"private"]}; truckers2 setbehaviour "careless"; truckers2 setformation "column"; //_cycle2 = (_destinations getrelPos [0.2, 0]); _wp3 = truckers2 addWaypoint [_spawn, 0]; _wp3 setWaypointType "MOVE"; _wp3 setWaypointSpeed "LIMITED"; _wp4 = truckers2 addWaypoint [_destinations, 0]; _wp4 setWaypointType "MOVE"; _wp4 setWaypointSpeed "LIMITED"; _wp5 = truckers2 addWaypoint [_destinations, 0]; _wp5 setWaypointType "CYCLE"; _wp5 setWaypointSpeed "LIMITED"; _truck5 = selectRandom ["O_T_MRAP_02_hmg_ghex_F","O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F"] createVehicle _centerspawn; truck5 = _truck5; sleep 0.1; _6thspawn = (_truck5 getrelPos [-10, 0]); _truck6 = selectRandom ["O_T_Truck_03_covered_ghex_F","O_T_Truck_02_Box_F","O_T_Truck_02_F","O_T_Truck_03_transport_ghex_F"] createVehicle _6thspawn; truck6 = _truck6; sleep 0.1; truckers3 = creategroup east; "O_T_Soldier_F" createUnit [[1,0,0],truckers3,"trucker7 = this; trucker7 moveindriver truck5",0.8,"corporal"]; "O_T_Soldier_F" createUnit [[0,1,0],truckers3,"trucker8 = this; trucker8 moveindriver truck6",0.6,"private"]; if (truck5 isEqualTo "O_T_MRAP_02_hmg_ghex_F") then { "O_T_Soldier_F" createUnit [[1.5,0,0],truckers3,"trucker9 = this; trucker9 moveingunner truck5",0.8,"private"]}; truckers3 setbehaviour "careless"; truckers3 setformation "column"; if (player side == east) then {player moveincargo truck}; _wp6 = truckers3 addWaypoint [_spawn, 0]; _wp6 setWaypointType "MOVE"; _wp6 setWaypointSpeed "LIMITED"; _wp7 = truckers3 addWaypoint [_destinations, 0]; _wp7 setWaypointType "MOVE"; _wp7 setWaypointSpeed "LIMITED"; _wp8 = truckers3 addWaypoint [_centerspawn, 0]; _wp8 setWaypointType "CYCLE"; _wp8 setWaypointSpeed "LIMITED"; 0 = [] spawn { [west,["taskConvoyRandom"],["Prevent the PLA from resupplying the occupation force and reinforcing their positions.","Destroy the cargo trucks traversing the island.",""], getPosATL pole ,1,2,true,"destroy"] call BIS_fnc_taskCreate; waitUntil {!(alive truck) AND !(alive truck2) AND !(alive truck3) AND !(alive truck4) AND !(alive truck5) AND !(alive truck6)}; ["taskConvoyRandom", "SUCCEEDED",true] spawn BIS_fnc_taskSetState; }; }; It's 3x2 trucks with random spawn/waypoints and task My questions/wants: -When the script comes to a waypoint array (_spawn, _destinations...) does it calculate a random position every time or just once on init and then uses those positions for the remainder of staying active? In other words is _spawn at _wp1 same as _spawn at wp2???? I dont think it cycles if it picks the cycle wp again at random from _spawn and they are different coords? idk _wp1 = truckers1 addWaypoint [_spawn, 0]; _wp1 setWaypointType "MOVE"; _wp1 setWaypointSpeed "LIMITED"; _wp2 = truckers1 addWaypoint [_spawn, 0]; _wp2 setWaypointType "CYCLE"; _wp2 setWaypointSpeed "LIMITED"; --------------------------------------------------------------------------------------------------------- -//_cycle1 = (_spawn getrelPos [0.2, 0]); ...i tried to remedy not knowing the answer to the first question by simply putting the cycle wp near the last move wp but it didnt work. 😔 ----------------------------------------------------------------------------------------------------------- -if (truck isEqualTo "O_T_MRAP_02_hmg_ghex_F") then { "O_T_Soldier_F" createUnit [[1.5,0,0],truckers1,"trucker5 = this; trucker5 moveingunner truck",0.8,"private"]}; im not sure if this is happening....if the syntax is correct in telling to the game if a chosen type is a MG equipped vehicle it should spawn a gunner for it. ----------------------------------------------------------------------------------------------------------- -i would also like "if truckX isequalto KamazFlatbed then attach a static MG to truckX, create gunner in the driver's group, move him to mg and off they go" but i don't know how to write it..... Any insight is much appreciated! Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 13, 2022 truck is an object which you created by using createVehicle. Always look at biki pls to get to know what arguments a command needs and what the return value will be. as told above createVehicle returns an object - just the vehicle object. Comparing an object with a string does not have any sense. The answer will always be false because an object can't be a string. But in this line you do exactly that. You are comparing an object with a string: if (truck isEqualTo "O_T_MRAP_02_hmg_ghex_F") then ... what you could do in this case is to get the classname string of the truck object and compare that with your string: if ( typeOf truck isEqualTo "O_T_MRAP_02_hmg_ghex_F" ) then ... As you can see in the biki typeOf is returning the classname string of the object given as argument. 1 Share this post Link to post Share on other sites