FederalRazer89 7 Posted November 13, 2016 Helloi adding some ambient units to a mission scenario, they spawn at random locations around the player. The problem is that the script dont delete the ai squads that have spawned when i use the "if" command to trigger the "deleteVehicle" code. The script is meant to delete the ai squad or squads when they get too far away from the player. I have used a simlar script to create zombies that spawn and get deleted when they get seperated from the player, but that used a agent to create so that might be diffrent. I dont know why but almost every time that i use a "if" command, it dosent work and have to look for other ways. If its easier to delete them with a waypoint script or just add a large explosion on there position. I dont have a programming background so i have some gap in my knowledge, any suggestions would be nice. The script: while {true} do { sleep 300; _radius = random [500,600,700]; _spawnPos = [player, _radius, (RANDOM 360)] call BIS_fnc_relPos; _spawnPos = [_spawnPos, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos; _grp = [_spawnPos, EAST,["I_C_Soldier_Para_2_F","I_Soldier_LAT_F","B_sniper_F","I_G_Soldier_A_F","O_Soldier_A_F","B_Soldier_A_F"]] call BIS_fnc_spawnGroup; _grp setBehaviour "CARELESS"; _wp = _grp addWaypoint [position player, _radius]; _wp1 = _grp addWaypoint [position player, _radius]; _wp2 = _grp addWaypoint [position player, _radius]; _wp3 = _grp addWaypoint [position player, _radius]; _wp3 setWaypointType "CYCLE"; if ((player distance (leader _grp)) >= 1000)then{{deleteVehicle _x} forEach units _grp; };}; Share this post Link to post Share on other sites
Grumpy Old Man 3547 Posted November 13, 2016 Hello i adding some ambient units to a mission scenario, they spawn at random locations around the player. The problem is that the script dont delete the ai squads that have spawned when i use the "if" command to trigger the "deleteVehicle" code. The script is meant to delete the ai squad or squads when they get too far away from the player. I have used a simlar script to create zombies that spawn and get deleted when they get seperated from the player, but that used a agent to create so that might be diffrent. I dont know why but almost every time that i use a "if" command, it dosent work and have to look for other ways. If its easier to delete them with a waypoint script or just add a large explosion on there position. I dont have a programming background so i have some gap in my knowledge, any suggestions would be nice. The script: while {true} do { sleep 300; _radius = random [500,600,700]; _spawnPos = [player, _radius, (RANDOM 360)] call BIS_fnc_relPos; _spawnPos = [_spawnPos, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos; _grp = [_spawnPos, EAST,["I_C_Soldier_Para_2_F","I_Soldier_LAT_F","B_sniper_F","I_G_Soldier_A_F","O_Soldier_A_F","B_Soldier_A_F"]] call BIS_fnc_spawnGroup; _grp setBehaviour "CARELESS"; _wp = _grp addWaypoint [position player, _radius]; _wp1 = _grp addWaypoint [position player, _radius]; _wp2 = _grp addWaypoint [position player, _radius]; _wp3 = _grp addWaypoint [position player, _radius]; _wp3 setWaypointType "CYCLE"; if ((player distance (leader _grp)) >= 1000)then{{deleteVehicle _x} forEach units _grp; };}; The script is a bit nonsensical in execution. At first you define _grp then immediately check if the _grp is >= 1000m away from the player, which will never return true. Then the loop goes into the second iteration, spawning another group defined as _grp, so the first created group goes into the nether and will therefore never be checked for distance. You can either add the delete check as setWaypointScript or you could add each group into a global array and check the array every 300 seconds. Cheers 1 Share this post Link to post Share on other sites
FederalRazer89 7 Posted November 13, 2016 So the "if" command only check the distance relative to the player once at the start?If its thats how it work then i am not supprised that i didnt get it to work.Thank you. Now i know how to work with it. Share this post Link to post Share on other sites
killzone_kid 1333 Posted November 13, 2016 You spawn a group < 700 + 150 = 850m, but want to delete it, if it is > 1000m? It is not, so it doesn't delete. Share this post Link to post Share on other sites