Jump to content
Sign in to follow this  
roguetrooper

Dynamic script for map-markers

Recommended Posts

I want a script that creates radar-dots on the map at the positions of each living east unit.

Creating moving markers for known units is no problem. But here it is about units that are created on the fly.

I have tried something like this, with hundred variable combinations of _m, _mn, m, mn and so on. But I just don't get it to work. The markers don't show up at all. The forEach-code is a single line in my script. Here the lines are just devided for overview.

_n = 0;
_mn = "m1";

#start
_liste = [];

{if (side _x == east) then { 
_n = _n+1;
_mn = format ["m%1",_n];
_m = createMarkerLocal [_mn, position _x];
_mn setMarkerColorLocal "ColorRed";
_liste = _liste + [_m]};
} forEach allunits;

~0.5
{deleteMarkerLocal _x} forEach _liste;
goto "start";

Share this post


Link to post
Share on other sites

Hi there,

TAG_mainArray = [];

private ["_side", "_delay"];
_side = EAST;
_delay = 1;

while { true } do 
{
  {
     if ((side _x == _side) && !(_x in TAG_mainArray)) then
     {
        private ["_pos", "_mkr"];
        _pos = getPos _x;
        _mkr = createMarkerLocal [("TAG_mkr_" + format ["%1", _pos select 0 + _pos select 1]), _pos];
        _mkr setMarkerTypeLocal "mil_dot";
        _mkr setMarkerColorLocal "ColorRed";

        [_x, _mkr] spawn
        {
            private ["_u", "_m"];
            _u = _this select 0;
            _m = _this select 1;

            while { alive _u } do
            {
                _m setMarkerPosLocal (getPos _u);
                sleep 0.5;
            };

            deleteMarkerLocal _m;

            if (_u in TAG_mainArray) then
            {
                TAG_mainArray set [(TAG_mainArray find _u), "delete"];
                TAG_mainArray = TAG_mainArray - ["delete"];
            };
        };
     };
  } forEach allUnits;

  sleep _delay;
};

Not tested but basically it will check which units from EAST side that have no marker (not in the TAG_mainArray) and create one and make the marker follow until unit is dead.

_neo_

Share this post


Link to post
Share on other sites

Thanks, but unfortunately it doesn't work. Markers neither show up for east units placed in the editor nor for those created on the fly.

I have copy-and-pasted your code into a file "enemymarker.sqf" and call it with [] exec "enemymarker.sqf"; It also does not work with sqS. I've tried it with "and" instead of your "&&" as well.

Does the code need to be arranged in another way (tabs, lines and such) ?

I've also never understood the differences between sqf, sqs, exec, execVM.

Share this post


Link to post
Share on other sites
Thanks, but unfortunately it doesn't work. Markers neither show up for east units placed in the editor nor for those created on the fly.

I have copy-and-pasted your code into a file "enemymarker.sqf" and call it with [] exec "enemymarker.sqf"; It also does not work with sqS. I've tried it with "and" instead of your "&&" as well.

Does the code need to be arranged in another way (tabs, lines and such) ?

I've also never understood the differences between sqf, sqs, exec, execVM.

Hi,

See .sqf and .sqs differences, but basically, .sqs syntax is deprecated, and .sqf should be used instead.

exec and execVM works the same way has above, exec is to spawn .sqs scripts, and execVM is for .sqf scripts.

Hope this helps.

_neo_

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  

×