Jump to content
Sign in to follow this  
Llano

Respawn at random locations.

Recommended Posts

Hi!

I'm trying to make a script that if you die, you will respawn at random locations. I have put out some markers that i would like to be possible to spawn at.

I made a "addEveneHandler" in the init.sqf file:

_respawn = player addEventHandler ["respawn", {_this exec "respawned.sqf"}];

And a respawned.sqf:

_unit = _this select 0;

_markers = ["markerOne", "markerTwo", "markerThree", "markerFour", ""markerFive", "markerSix", "markerSeven", "markerEight", "markerNine", "markerTen"];

_random = random(9);
_position = getMarkerPos (_markers select _random);
_unit setPos (_markers select _random)

Now, this obviously don't work because i have to pass the markers to this sqf-file? How do i do that? And is this the easiest way to achive what i want?

Thank you.

Share this post


Link to post
Share on other sites

can't test but there are a few mistakes

_respawn = player addEventHandler ["respawn", {_this exec "respawned.sqf"}];

exec is for .sqs and execvm is for .sqf type files

you don't need to pass the markers to the script as you have them set up in an array, you do need to change random to give only whole numbers

not tested but something like this should be all that is needed

_unit = _this select 0;

_markers = ["markerOne", "markerTwo", "markerThree", "markerFour", ""markerFive", "markerSix", "markerSeven", "markerEight", "markerNine", "markerTen"];

_random = floor random (9);

_unit setPos getMarkerPos (_markers select _random);

Share this post


Link to post
Share on other sites

From what I know, you don't need a script for this unless you want more customization.

Placing multiple respawn-markers in this format should be enough: "respawn_west1","respawn_west2","respawn_west3",...

Documented here:

http://community.bistudio.com/wiki/Description.ext#respawn

Aside from that, your script should basically work. Except for some minor errors, see below:

_unit = _this select 0;

_markers = ["markerOne", "markerTwo", "markerThree", "markerFour", ""markerFive", "markerSix", "markerSeven", "markerEight", "markerNine", "markerTen"];

_random = floor(random (count _markers));

_position = getMarkerPos (_markers select _random);

_unit setPos _position;

Edited by Tajin

Share this post


Link to post
Share on other sites
can't test but there are a few mistakes

_respawn = player addEventHandler ["respawn", {_this exec "respawned.sqf"}];

exec is for .sqs and execvm is for .sqf type files

you don't need to pass the markers to the script as you have them set up in an array, you do need to change random to give only whole numbers

not tested but something like this should be all that is needed

_unit = _this select 0;

_markers = ["markerOne", "markerTwo", "markerThree", "markerFour", ""markerFive", "markerSix", "markerSeven", "markerEight", "markerNine", "markerTen"];

_random = floor random (9);

_unit setPos getMarkerPos (_markers select _random);

Thank you so much! It works perfectly now.

Btw, is this the easiest way to do this? i.e setting their position after they have spawned in "BASE"?

Share this post


Link to post
Share on other sites

1. Make markers named respawn_west1, respawn_west2, respawn_east1, respawn_east2 etc. - for every possible respawn the name has to be either respawn_west or respawn_east with a number behind it

2. Make a text file named description.ext in your my documens / arma 3 - mission folder

3. In this text file put:

respawn = 3; // 3 = BASE (blufor will respawn at markers called respawnWestX, opfor at respawnEastX)
respawnDelay = 5; // as in seconds

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  

×