mr_shadow 4 Posted October 19, 2013 Hello guys, I need some help with scripting. The idea is that when player from player array (for example array1= player1, player2, player3) will press on action (addaction) - the script will create marker on one of this players, but not on player who pressed on actain. And if player with marker is dead then something like hint "task failed". I will appreciate any help. _array = [c1,c2,c3,c4]; _random = _array select random; while {true} do { { deleteMarkerLocal _x; } foreach Markers; Markers = []; { if (side _x == civilian) then { _marker = createMarkerLocal _random [name _x, getpos _x]; _marker setMarkerTypeLocal "hd_dot"; _marker setMarkerColorLocal "ColorRED"; _text = format ["TARGET: %1: %2",_x,(name _x)]; _marker setMarkerTextLocal _text; Markers = Markers + [_marker]; }; } foreach playableUnits; sleep 2; } Share this post Link to post Share on other sites
blackmamb 2 Posted October 19, 2013 (edited) Untested, but here is a possible way of doing it (assuming I understood what you wanted properly, which isn't always my best skill) MS_fnc_localMarkers = { private ["_target", "_marker", "_name"]; _target = _this; _name = name _target; if (side player != civilian) exitWith {}; _marker = createMarkerLocal [_name, getposATL _target]; _marker setMarkerTypeLocal "hd_dot"; _marker setMarkerColorLocal "ColorRED"; _text = format ["TARGET: %1",_name]; _marker setMarkerTextLocal _text; while {true} do { _marker setMarkerPosLocal (getPosATL _target); if (!alive _target) exitWith {hint format ["Task failed: %1 is already dead", _name]; _marker setMarkerColorLocal "ColorBLACK";}; sleep 2; }; }; MS_fnc_actionMarkers = { _array = [c1,c2,c3,c4]; { if ((!alive _x) || {_x == player}) then { _array set [_forEachIndex, -1]; }; } forEach _array; _array = _array - [-1]; _target = _array select floor( random (count _array)); [_target, "MS_fnc_localMarkers", true, true] spawn BIS_fnc_MP; }; You addaction would go, I guess, something like : player addAction ["Choose a target", MS_fnc_actionMarkers]; Edited October 19, 2013 by BlackMamb fixed typos in the code Share this post Link to post Share on other sites
mr_shadow 4 Posted October 19, 2013 Nope, marker is not creating. Share this post Link to post Share on other sites
blackmamb 2 Posted October 19, 2013 (edited) There were a shitload of typos and leftovers from your code. Lemme fix that real quick. First post edited. Edited October 19, 2013 by BlackMamb Share this post Link to post Share on other sites
mr_shadow 4 Posted October 19, 2013 Well, still not working :\ Share this post Link to post Share on other sites
blackmamb 2 Posted October 19, 2013 Working just fine for me, so I'll assume I didn't understand what you wanted to do in the first place. Is your player a civilian? Share this post Link to post Share on other sites
mr_shadow 4 Posted October 19, 2013 Yes, my player is civ. I've added the code into my init file then added action this addAction ["Choose a target", MS_fnc_actionMarkers]; to the civ AI, that is not from array.Then pressed it, and nothing. Share this post Link to post Share on other sites
blackmamb 2 Posted October 19, 2013 Huh. Do you have your 4 civies named c1, c2, c3 and c4? Share this post Link to post Share on other sites
mr_shadow 4 Posted October 19, 2013 (edited) Ok found the problem, just added player addaction into init, Now its working. Once more question, can you please edit the code that when the target was killed marker will be removed from map? And is it possible to remove marker from target after some time?For example 10 min Edited October 19, 2013 by mr_shadow Share this post Link to post Share on other sites
blackmamb 2 Posted October 19, 2013 Of course. You just have to replace: _marker setMarkerColorLocal "ColorBLACK"; by deleteMarkerLocal _marker . Edit: that's going to remove it immediately. To remove it ten minutes later, keep the first one, add a sleep, add the second: _marker setMarkerColorLocal "ColorBLACK"; sleep 600; deleteMarkerLocal _marker . Now it turns black the target is dead, and disappears after ten minutes. If you want to keep it red, just remove _marker setMarkerColorLocal "ColorBLACK"; Share this post Link to post Share on other sites
mr_shadow 4 Posted October 19, 2013 Well thanks, and what if i want to remove it if the target is dead OR after 10 min? ---------- Post added at 17:29 ---------- Previous post was at 17:27 ---------- just figured that out. Thanks a lot! You really helped me! Share this post Link to post Share on other sites
mr_shadow 4 Posted October 20, 2013 how to setvarriable to the shooter who killed target? Share this post Link to post Share on other sites