Koni 1 Posted March 21, 2012 Is there a way to delete leftover surviving crew from destroyed vehicles within a trigger area. I have a trigger set to spawn OPFOR Armoured units if no OPFOR are present, but any remaining crew members that still live within the area obviously stop anymore Armoured unit from spawning. How can I fix this ? Thanks Share this post Link to post Share on other sites
bigshotking 10 Posted March 21, 2012 Made this for you, tested and it works! // remove_tankcrew.sqf // Made by: 42nd|Bigshot if (!isServer) exitWith {}; private ["_position", "_radius", "_x"]; _position = (_this select 0); _radius = (_this select 1); { if (side _x != side player) then { deleteVehicle _x; }; } forEach nearestObjects [_position, ["Man"], _radius]; Share this post Link to post Share on other sites
PELHAM 10 Posted March 22, 2012 (edited) You can get the trigger area with the following: triggerArea Returns trigger area in the form [radius_a, radius_b, angle, rectangle]. Mathematically it helps if the trigger is a circle. nul = [triggerNameHere] execVM "some.sqf"; _atrigger = _this select 0;//gets the trigger name from exec _Pos = getPos _atrigger; _tankzone = triggerArea _atrigger; _radius = tankzone select 0;//trigger area must be circle Edited March 22, 2012 by PELHAM Share this post Link to post Share on other sites
Koni 1 Posted March 22, 2012 // remove_tankcrew.sqf // Made by: 42nd|Bigshot if (!isServer) exitWith {}; private ["_position", "_radius", "_x"]; _position = (_this select 0); _radius = (_this select 1); { if (side _x != side player) then { deleteVehicle _x; }; } forEach nearestObjects [_position, ["Man"], _radius]; Thanks for the reply bigshotking but it's throwing an error on line 8 "undefined variable in expression #_this and dose not delete any living crew that have abandoned their disabled vehicles. Share this post Link to post Share on other sites
borg117 1 Posted March 22, 2012 you could try this: deleteVehicle (driver enemyunit); i think you can replace 'driver' with other commands such as gunner etc. ---------- Post added at 10:46 AM ---------- Previous post was at 10:43 AM ---------- sorry, also forgot to mention you execute the command for everyone within trigger radius using this: {deleteVehicle (driver _x)} forEach list triggername; make sure your trigger is set to opfor and present and it will delete everyunit (or every driver) in the trigger radius who is opfor and present (alive). Share this post Link to post Share on other sites
PELHAM 10 Posted March 22, 2012 Thanks for the reply bigshotking but it's throwing an error on line 8 "undefined variable in expression #_this and dose not delete any living crew that have abandoned their disabled vehicles. you need to call it with: nul = [input1,input2] execVM "yourscript.sqf"; input 1 needs to be a position (or object?) input 2 needs to be a number eg 200 If you have problems with the position change it to the trigger name and use: _atrigger = _this select 0;//gets the trigger name from exec _radius = _this select 1;//gets the radius from exec _Pos = getPos _atrigger; Share this post Link to post Share on other sites
Koni 1 Posted March 22, 2012 Right, just to make sure if I am doing this correctly here's what I'm doing. I have a baseball named "H" as the position\object for Imput1, I then have a trigger set to OPFOR PRESENT - THIS - Repeatedly with a radius of 350x350 Ellipse In the On Activation I have nul = [h,350] execVM "scripts\removecrew.sqf"; So h should be the Imput1 for position/object, and 350 =Imput2 which is the radius around Imput1 which is the baseball named "H", yeah ?! and the removecrew.sqf which is executed from the nul = [h,350] execVM "scripts\removecrew.sqf" is... // remove_tankcrew.sqf // Made by: 42nd|Bigshot if (!isServer) exitWith {}; private ["_position", "_radius", "_x"]; _position = (_this select 0); _radius = (_this select 1); { if (side _x != side player) then { deleteVehicle _x; }; } forEach nearestObjects [_position, ["Man"], _radius]; I no longer get any error, but the crew still remain alive once they bail from their vehicles. I know you said about trying a trigger as well, but I wanted to find out if I was actually doing this correctly first. Does the baseball and radius not need to be mentioned in the script at all then ? or should I be changing anything in the script to h and 350 etc ?! Thanks Share this post Link to post Share on other sites
borg117 1 Posted March 22, 2012 well i can't see anything wrong with it and if there are no errors in the error log then i would take a guess that it is to do with 'foreach nearestObjects' be careful that nearest objects is used in two different methods http://community.bistudio.com/wiki/nearestObject and http://community.bistudio.com/wiki/nearestObjects Also take note to the fact that the command can only be used to return a list, so you have two options to try, do: objectList = nearestObjects [_position, ["Man"], _radius]; along with your position and radius assignments and then change the forEach to 'forEach objectList'. OR you could use the idea of keeping with the trigger. i can understand that you may only want infantry units to be deleted, however you could use my idea as a one time check at the end of the wave or adapt a simple forEach command that includes typeOf which i'm not sure would work or not. in my experience you can adapt several commands for the forEach. Share this post Link to post Share on other sites
PELHAM 10 Posted March 22, 2012 (edited) Oh did you not put it in a loop? Running that as is only calls it once. If you need to keep checking through the mission you need something like this: http://community.bistudio.com/wiki/Control_Structures // remove_tankcrew.sqf // Made by: 42nd|Bigshot if (!isServer) exitWith {}; while {true} do { private ["_position", "_radius", "_x"]; _position = (_this select 0); _radius = (_this select 1); { if (side _x != side player) then { deleteVehicle _x; }; } forEach nearestObjects [_position, ["Man"], _radius]; sleep 1; }; I would replace deleteVehicle _x; with _x setDamage 1; That will kill the crews as they exit instead of vapourising them. Edited March 22, 2012 by PELHAM Share this post Link to post Share on other sites
borg117 1 Posted March 22, 2012 btw forgot to mention that bigshotking's way of doing could i believe alllow you to actually place the entire command in a 'while {}' and then execute removecrew.sqf from the init.sqf. that way you scrap the trigger, you just have a baseball and the radius which is all you need and the while can constantly check for you. Share this post Link to post Share on other sites
bigshotking 10 Posted March 22, 2012 Just a little FYI, when I was testing that script if you call it and there is no soldier in the radius of where you are calling it errors out due to that. So if you want to loop it then do it this way: Put this in your init.sqf: while {true} do { null = [h,350] execVM "scripts\removecrew.sqf"; sleep 2; }; That way the script won't exit due to not having all the parameters if no soldiers are within the radius. Hope that helps, and sorry for not posting on how to call it my bad! Share this post Link to post Share on other sites