Jump to content
Sign in to follow this  
1para{god-father}

Check to see if it Exists ISNULL ?

Recommended Posts

I need to check to see if a marker exists if not create it , how can i check to see if it exists I thought the variable would return NULL is that correct ?

is this correct ?


//Might be created above but if not create it

if (ISNULL _marker )then
{
Does not exist so create it 

} else {

just add stuff as it exists

};

Share this post


Link to post
Share on other sites

All depends how you get _marker ??

_marker = markerPos "mkr1";

returns [0,0,0] if mkr1 does not exist. Thats why you spawn in the bottom left corner of the map when you miss a , out of a list of marker names in an array lol.

isNil and isNull will not work with arrays, isNull will not work at all with markers as it requires an object.

_marker = markerPos "mkr1";
if ({_x==0} count _marker==3) then {hint "doesn't exist, unless marker is really at that pos?"};

That will check for the [0,0,0] array. Another way is:

_marker = getMarkerType "mkr1";
if (isNil _marker) then {hint "doesn't exist"};

That will check for an undefined string.

Edited by PELHAM

Share this post


Link to post
Share on other sites

I am creating a marker as follows:-

_marker = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];

But the problem is it might not even get created so _marker will not even exist, so if _marker does not exist what would it return ? or would i just get an error ?

Share this post


Link to post
Share on other sites
I am creating a marker as follows:-

_marker = createMarker ["sZoneLocal", [(position player select 0), (position player select 1) +1500 , 0]];

But the problem is it might not even get created so _marker will not even exist, so if _marker does not exist what would it return ? or would i just get an error ?

To check if it doesn't exist use the 2nd example from post 2 - isNil will check if _marker is an undefined string. If it exists it will return "sZoneLocal".

if (isNil _marker) then {hint "doesn't exist"};

Edited by PELHAM

Share this post


Link to post
Share on other sites

This will return whether the marker exists:

markerType marker != ""

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  

×