Jump to content
chneemann

Random Variable Name for markers

Recommended Posts

Hi,

 

I want to use a script many times in one mission.

That's not a problem, but in this script I create a marker.

And markernames seems to be public names even when I add an "_" before.

 

That's why I had the idea to create a random name for the marker.

 

something like

_randomnumber = round(random 50);

Markername+%_randomnumber = createMarker ["Markername+%_randomnumber", position AAF_HQ];

sleep 10;

Markername+%_randomnumber setmarkerpos (getpos leader _grp1)

 

 

 

But of Course >Markername+%_randomnumber< will not work.

 

Any idea?

 

 

Share this post


Link to post
Share on other sites

You could format the name like this:

createMarker ["Markername" + (str _randomnumber), position AAF_HQ];

or of course with the actual format command.

But I can't see why the variable name should be random. Maybe just use _marker?

 

Only 51 possible random names may create conflicts though. How about something like random 100000 without rounding?

Share this post


Link to post
Share on other sites

one way to have unique marker name is use the position:

_pos = position AAF_HQ;
_marker = "Markername" + (str _pos);
createMarker [_marker,_pos];

_marker setmarkerpos (getpos leader _grp1);
  • Like 1

Share this post


Link to post
Share on other sites

i usually use the position as a name since i assume there's only going to be one marker at that position at a time.

_pos = getpos AAF_HQ;

createMarker [str _pos, _pos];

EDIT: goddamn ninjas! :ph34r:

  • Like 1

Share this post


Link to post
Share on other sites

if there are more markers at same position (very unlikely) then u could do this to avoid double marker names:

_unique_name = false;
while(!_unique_name)
{
 _randomnumber = floor random 100000;
 _name = "Markername" + (str _randomnumber);

 if(!(_name in allMapMarkers)) then {_unique_name = true;};
}
createMarker [_name, position AAF_HQ];
  • Like 2

Share this post


Link to post
Share on other sites

The marker is always going to be at the position of the AAF_HQ right?  Why not just place it on the map (or spawn it once) and move it as the HQ moves instead of randomly creating it every time?

  • Like 1

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

×