thecoolsideofthepillow 22 Posted August 20, 2015 I want to select a random group of things and delete those not selected. I made a script to put everything I wanted deleted in an array, and then delete the things. It works just fine... Just not if ran from init. If I run it again after I am in control of a player character, it works fine. It puts everything in the array and does everything else I want except for deleting the things, including things told to be done after the deletion of the things, like marking the remaining things on the map. I am not sure where I should move the bit that deletes the things or how to check if it's okay to delete the things I want to delete. I am assuming maybe some kind of wait until/for something else happens, but am not sure. Share this post Link to post Share on other sites
jshock 513 Posted August 20, 2015 Well, when exactly do you want to delete the "things", I can assume since you tried it in the init, that you want to delete them at mission start? Share this post Link to post Share on other sites
R3vo 2654 Posted August 20, 2015 Post the complete script here and tell us the exactly when the script should be executed. It could be possible that some of the objects/entities do not exist at mission start, that they get created a short moment after.( Just a wild guess) Share this post Link to post Share on other sites
thecoolsideofthepillow 22 Posted August 20, 2015 Here is the script in question: //Variables objectiveStart = [Obj1Area, Obj1Area_1, Obj1Area_2, Obj1Area_3, Obj1Area_4, Obj1Area_5, Obj1Area_6, Obj1Area_7, Obj1Area_8, Obj1Area_9, Obj1Area_10, Obj1Area_11, Obj1Area_12, Obj1Area_13, Obj1Area_14, Obj1Area_15, Obj1Area_16, Obj1Area_17, Obj1Area_18, Obj1Area_19, Obj1Area_20, Obj1Area_21, Obj1Area_22, Obj1Area_23, Obj1Area_24, Obj1Area_25, Obj1Area_26, Obj1Area_27, Obj1Area_28]; objectiveMid = [Obj2Area, Obj2Area_1, Obj2Area_2, Obj2Area_3, Obj2Area_4, Obj2Area_5, Obj2Area_6, Obj2Area_7]; selectedStart = []; selectedMid = objectiveMid call BIS_fnc_selectRandom; cleanup = []; //Code for "_i" from 1 to 3 do {_rndObj1 = objectiveStart call BIS_fnc_selectRandom; selectedStart pushBack _rndObj1}; { if !(_x in selectedStart) then { cleanup pushBack _x; }; } forEach objectiveStart; { if !(_x isEqualTo selectedMid) then { cleanup pushBack _x; }; } forEach objectiveMid; { { deleteVehicle _x; } forEach list _x; } forEach cleanup; { _tskName = format ["taskObj_%1", _x]; _tsk = player createSimpleTask [_tskName]; _tsk setSimpleTaskDescription ["Find and collect the intelligence in the area. Be prepared for hostile contact.", "Gather Intel", "Search Area for Intel"]; _tsk setSimpleTaskDestination (getPos _x); _tsk setTaskState "Assigned"; } forEach selectedStart; //Comment/Uncomment for Debugging { _mkrName = format ["taskMkr_%1", _x]; _mkr = createMarker [_mkrName, getPos _x]; _mkrName setMarkerShape "ICON"; _mkrName setMarkerType "mil_dot"; _mkrName setMarkerColor "colorRed"; _mkrName setMarkerAlpha 1; } forEach selectedStart; _mkr2 = createMarker ["mkrNameMid", getPos selectedMid]; _mkr2 setMarkerShape "ICON"; _mkr2 setMarkerType "mil_dot"; _mkr2 setMarkerColor "colorRed"; _mkr2 setMarkerAlpha 1; hint str cleanup; systemChat str objectiveStart; player sideChat str selectedStart; ​ I am trying to delete the units within the trigger areas of the zones not selected to keep, and I want to do this at the beginning of the mission since it's tied to how I am setting up tasks. Normally I would just spawn what I needed instead of deleting what I don't, but I need the units I want to keep in very specific spots (on/in buildings) so I used MCC to place them in Zeus and save to the .SQM so they'd be in the right position at every instance, every time. All the things I want to delete are already on the map (in the editor, anyway). I don't know exactly when the init.sqf runs compared to when the units are actually available to be played with, but I have also tried executing the script from a game logic object's init line with the theory that if that is ready to run its init, then surely the units are there to be deleted, but it didn't work either. Share this post Link to post Share on other sites
jshock 513 Posted August 20, 2015 Moving the call to this script to the initPlayerLocal.sqf should fix the issue, if not then at the top of the init/initPlayerLocal put: waitUntil {!isNull player && time > 3}; Share this post Link to post Share on other sites
thecoolsideofthepillow 22 Posted August 20, 2015 Sweet! That worked. Much thanks :D Share this post Link to post Share on other sites