Jump to content
Sign in to follow this  
peppy

Detecting if an object exisits?

Recommended Posts

I am looking for a way to detect if an object exists, and if it does to delete it.

For example, I spawn a helo, and later on in a script I want it to detect if it exists and if so delete it.

I have searched to no avale.

Share this post


Link to post
Share on other sites

Assuming you have a reference to the object, i.e. by a variable such as myHelo, you can check if it exists and then delete it by doing the following:

if (!isNull(myHelo)) then {deleteVehicle(myHelo);};

Share this post


Link to post
Share on other sites

I have ran in to a bit of a snag, this has worked wonders for me, how ever I am confused on how to check and delete any created Markers, Way points or what have you.

Basically this is a Recycle script that Cleans all the Variables, and removes all script created objects.

This is what it looks like:


caller = _this select 0;
_WpGrp = group Spook;

caller removeaction menu;
caller removeaction Men1;
caller removeaction Men2;
caller removeaction Men3;
caller removeaction Men4;
caller removeaction Men5;
caller removeaction Men6;

caller removeaction Menex1;
caller removeaction Menex2;
caller removeaction Menex3;
caller removeaction Menex4;
caller removeaction Menex5;


if (!isNull(SpokLz)) then {deleteVehicle(SpokLz);};
if (!isNull(_Spokmok0)) then {deleteVehicle(_Spokmok0);};
if (!isNull(_Spokmok1)) then {deleteVehicle(_Spokmok1);};
if (!isNull(_Spokmok2)) then {deleteVehicle(_Spokmok2);};
if (!isNull(_Spokmok3)) then {deleteVehicle(_Spokmok3);};
if (!isNull(_Spokmok4)) then {deleteVehicle(_Spokmok4);};
if (!isNull(_Spokmok5)) then {deleteVehicle(_Spokmok5);};
if (!isNull(_Spokmok6)) then {deleteVehicle(_Spokmok6);};
if (!isNull(_Spokmok7)) then {deleteVehicle(_Spokmok7);};

if (!isNull(_ReconMapPos)) then {deleteMarker _ReconMapPos;};
if (!isNull(_ReconStartM)) then {deleteMarker _ReconStartM;};
if (!isNull(_ReconEndM)) then {deleteMarker _ReconEndM;};

if (!isNull(_waypoint1)) then {deleteWaypoint [_WpGrp, 1];};
if (!isNull(_waypoint2)) then {deleteWaypoint [_WpGrp, 2];};
if (!isNull(_waypoint3)) then {deleteWaypoint [_WpGrp, 3];};


_WpGrp = group _grpNull;
_WpPos = 0;
GetClick = true;

exit;
[/Code]

Edited by Peppy

Share this post


Link to post
Share on other sites

if (getMarkerColor "mrk1" == "ColorOPFOR") then {deleteMarker "mrk1";};

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  

×