bertram 11 Posted March 20, 2014 I've been trying to make a mission similar to the game "The Ship" which is a game where each player is assigned a target, or quarry, that they must eliminate within a certain time limit. However I'm not entirely sure how to go about creating a script where each player is assigned another player at random as a target. I tried creating an array of all the playable units _randomtarget = playableUnits; and then using _target = _randomtarget call BIS_fnc_selectRandom; to chose a random value in that array, however I'm believe I'm going about this the wrong way as I'm getting 'any' as my return value. If anyone could provide some insight that would be much appreciated. Share this post Link to post Share on other sites
Jigsor 176 Posted March 21, 2014 Give a unique name to all the playable units in the editor This has been working for me. It returns a randomly chosen playable unit name. _randomtarget = playableUnits; _target = _randomtarget select (floor (random (count _randomtarget))); Share this post Link to post Share on other sites
bertram 11 Posted March 21, 2014 I've used your suggestion but I'm still getting an undefined value returned when I look at the RPT. This is the code I'm currently using _randomtarget = playableUnits; _target = _randomtarget select (floor (random (count _randomtarget))); if (side player == civilian) then {hint format["Your target is %1",_target];}; And the RPT Error in expression <) then {hint format["Your target is %1",_target];};> Error position: <_target];};> Error Undefined variable in expression: _target Share this post Link to post Share on other sites
Jigsor 176 Posted March 21, 2014 Maybe you are having locality issues? Can't really tell, no idea how you are running that code. Maybe try running this script for each player that needs a random target. Change the playable unit names to suit you. This has worked for me as well. if (isServer) exitWith{}; _human_target = { _west_players = []; if (isPlayer SLreserved) then {_west_players = _west_players + [sLreserved];}; if (isPlayer BravoTL) then {_west_players = _west_players + [bravoTL];}; if (isPlayer superman) then {_west_players = _west_players + [superman];}; if (isPlayer FoxtrotCL) then {_west_players = _west_players + [FoxtrotCL];}; if (isPlayer GolfTL) then {_west_players = _west_players + [GolfTL];}; if (isPlayer HotelTL) then {_west_players = _west_players + [HotelTL];}; if (isPlayer LimaTL) then {_west_players = _west_players + [LimaTL];}; if (isPlayer RazorTL) then {_west_players = _west_players + [RazorTL];}; _random_w_player = _west_players select (floor (random (count _west_players))); //diag_log text format ["Variable West Human Target: %1", _random_w_player]; _random_w_player; }; _acquired_target = []; if (!(count __acquired_target == 0)) then {_acquired_target set [];}; _acquired_target = _acquired_target + call _human_target; _new_acquired_target = _acquired_target select 0; hint format["Your target is %1",_new_acquired_target]; That could probably also be simplified. by someone with more skills. Share this post Link to post Share on other sites
blazededge 1 Posted May 11, 2014 Has someone figured out how to do this? I can't seem to find much about getting markers to attach to players and then reset once a player is dead? Or is there a mission we can download then edit it to your own standands? Share this post Link to post Share on other sites
toxicspare 10 Posted January 15, 2015 Me and my friend had a look at this and tested it out. _randomtarget = ["q1","q2","q3","q4","q5","q6","q7","q8"]; [color="#FF0000"]// q1, q2 etc. is the player name that we gave the characters[/color] _target = _randomtarget select (floor (random (count _randomtarget))); if (side player == civilian) then {hint format["Your target is %1",_target];}; This is the single player code that we got working, It defines who "_randomtarget" is and then assigns a unit to it. However the code you had before, _randomtarget = playableUnits; _target = _randomtarget select (floor (count _randomtarget))); if (side player == civilian then {hint fromat["Your target is %1, _target];}; Works in multiplayer if there are AI or humans spawned in as the characters. One problem with the script, it doesn't redefine the target when a target is killed. We tried getting around that problem with this: if (_randomtarget !alive) then {hint format["Your target is %1",_target];}; It didn't work :( Share this post Link to post Share on other sites