Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
redmotion

Setting random start location for player using markers

Recommended Posts

I've tried various ways of doing this based on the chapter in the Arma editing guide (Chapter 6.5 "Dynamic Start Points"). The code in the manual crashes Arma 2 because the syntax seems wrong.

I've come up with this:

StartR = random 3; 
if (StartR < 1) then {Player setPos getPos Start1};  
if (StartR < 2) then {Player setPos getPos Start2};  
if (StartR < 3) then {Player setPos getPos Start3};

To position the player at one of the three markers named Start1, Start2 and Start3. This doesn't work. I've tried putting it in the players init box in the editor and as a "randomstart.sqf" file.

I've not found anything that works yet. Should this code work? Am I sticking it in the wrong place?

Would appreciate any ideas?!

Thanks.

Share this post


Link to post
Share on other sites

Markernames have to be strings

"MarkerName"

Second to get marker positions, use getMarkerPos

And finally

_markers = ["Start1", "Start2", "Start3"];
player setpos (getMarkerPos (_markers select (floor(random(count _markers)))));

Share this post


Link to post
Share on other sites

Thanks for that. That works fine but the problem is that I'd like to reposition the whole squad along with the player.

I'm guessing the most efficient way would be to setPos of the Group rather than do it for each member individually.

So replacing the first part of this line ("player"):

[b]player[/b] setpos (getMarkerPos (_markers select (floor(random(count _markers)))));

with the reference to the group instead seems logical.

I'm guessing I can either use "units" or "group" but the docs are so "lite" I just can't work it out.

_playerGrp = group player;
_playerGrp setpos (getMarkerPos (_markers select (floor(random(count _markers)))));

Doesn't seem to work.

Edited by redmotion

Share this post


Link to post
Share on other sites

Of course it doesn't work, Setpos expects a single object, not a group.

For this purpose, this code should work:

_pos = getMarkerPos (_markers select (floor(random(count _markers))));
{_x setpos _pos} foreach group player;

Share this post


Link to post
Share on other sites

Instead of use a script, cant you group the leader with the markers and they will spawn randomly. I think thats the way it is done.

As long as the units in the group are in formation they will spawn at the same place as the leader.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×