Maguila.gm 0 Posted August 31, 2023 I had a script to one enemy unit to ping on the map and have its position updated every 5 seconds and it worked: beaconblip1 = createMarker ["beacon1", v1]; beaconblip1 setMarkerShape "ELLIPSE"; beaconblip1 setMarkerColor "ColorGreen"; beaconblip1 setMarkerSize [15, 15]; while {true} do { "beacon1" setMarkerPos (getPos v1); sleep 5; }; I wanted do do for multiple units, i did multiple of the exemple 1 but after 20 or so it got very time consuming. So i did this and it is not working: // Define the array of enemy unit objects (replace these with your actual enemy unit objects) private _enemyUnits = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21]; // Create an empty array to hold the markers private _markers = []; // Create markers for each enemy unit { private _markerName = format ["enemyMarker%d", (_forEachIndex + 1)]; private _markerPos = getPos _x; _markers pushBack createMarker [_markerName, _markerPos]; _markers select (_forEachIndex) setMarkerShape "ELLIPSE"; _markers select (_forEachIndex) setMarkerColor "ColorRed"; // You can set this to whatever color you prefer _markers select (_forEachIndex) setMarkerSize [15, 15]; } forEach _enemyUnits; // Continuously update the marker positions based on enemy unit positions while {true} do { { private _markerName = format ["enemyMarker%d", (_forEachIndex + 1)]; _markerName setMarkerPos (getPos (_enemyUnits select _forEachIndex)); } forEach _enemyUnits; sleep 5; }; Share this post Link to post Share on other sites
pierremgi 4889 Posted August 31, 2023 Welcome on forum. 2 errors: You didn't set _markers before using it (missing line: _markers = []; ) and your format (for marker name) is wrong : replace it everywhere by: format ["enemyMarker%1", (_forEachIndex + 1)] (instead of "enemyMarker%d") Note: you need to spawn this code, using a while true loop. Anyway, you can easily avoid such names for markers. str random 1 will return different strings, no matter the number of markers. Test it. My suggest (tested): private _enemyUnits = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21]; { private _mk = createMarker [str random 1, getpos _x]; _mk setMarkerShape "ELLIPSE"; _mk setMarkerColor "colorRed"; _mk setMarkerSize [15,15]; [_mk,_x] spawn { params ["_mk","_enemy"]; while {alive _enemy} do { _mk setMarkerPos _enemy; sleep 5; }; deleteMarker _mk; }; } forEach _enemyUnits; 2 Share this post Link to post Share on other sites
Maguila.gm 0 Posted August 31, 2023 Thank you so much! i will test here Share this post Link to post Share on other sites
Maguila.gm 0 Posted September 1, 2023 private _enemyUnits = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50]; { private _mk = createMarker [str random 1, getpos _x]; _mk setMarkerShape "ELLIPSE"; _mk setMarkerColor "colorRed"; _mk setMarkerSize [15,15]; [_mk,_x] spawn { params ["_mk","_enemy"]; while {damage _enemy < 1} do { _mk setMarkerPos _enemy; sleep 5; }; deleteMarker _mk; }; } forEach _enemyUnits Sorry to bother, but the code above is not running, do you know what is wrong Share this post Link to post Share on other sites
Harzach 2517 Posted September 1, 2023 2 hours ago, Maguila.gm said: do you know what is wrong No closing semicolon and a few corrupted characters: When you paste code into a code block, corrupted/invisible characters show up as red dots. You can just delete them then recopy your code out of the code block. 1 Share this post Link to post Share on other sites
pierremgi 4889 Posted September 2, 2023 Little bit odd naming 50 units as enemies... Why not replacing this array by a side condition? 1 Share this post Link to post Share on other sites
Maguila.gm 0 Posted September 2, 2023 9 minutes ago, pierremgi said: Little bit odd naming 50 units as enemies... Why not replacing this array by a side condition? I just wanted armoured vehicles to show up. but yes haha i know nothin to very little of coding and editing so most time i do things that are not the best Share this post Link to post Share on other sites
pierremgi 4889 Posted September 2, 2023 If all these vehicles are edited (not spawned during the game), you can write something like: private _enemyUnits = vehicles select {side _x == EAST && _x isKindOf "tank"}; 1 Share this post Link to post Share on other sites
Maguila.gm 0 Posted September 3, 2023 19 hours ago, pierremgi said: If all these vehicles are edited (not spawned during the game), you can write something like: private _enemyUnits = vehicles select {side _x == EAST && _x isKindOf "tank"}; Thanks, i had no idea i could do such a thing... Share this post Link to post Share on other sites