Jump to content
Sign in to follow this  
Antorugby

Random Spawn

Recommended Posts

Hello guys, I'm trying to make a script for a multiplayer mission that will randomly spawn the players inside an area, I'm using SHK_pos, so this is the script and it seems to work just fine:

call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
_newpos = ["mrkGreen",0,["mrkRed","mrkYellow"]] call SHK_pos;
player setposATL _newpos;

Now it begins the difficult part, I want the possibility that someone will spawn with another player so I was thinking about this:

if ( random 1 < 0.70 ) then {
call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
_newpos = ["mrkGreen",0,["mrkRed","mrkYellow"]] call SHK_pos;
player setposATL _newpos;
} else {
call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
posgroup = ["mrkGreen",0,["mrkRed","mrkYellow"]] call SHK_pos;
player setposATL posgroup;
};

I haven't tested it but this shouldn't work because every player that execute the init will create a different "posgroup" right?

What is the right way to do it? If I use "if (isServer)" the script will run only one time and the "posgroup" will be global for everyone?

I'm a noob scripting for multiplayer so I'm sorry if asked something dumb, thank you!

Edited by Antorugby

Share this post


Link to post
Share on other sites

Nobody? Any tips?

Inviato dal mio GT-I9300 utilizzando Tapatalk

Share this post


Link to post
Share on other sites

What i do is just make a whole mess of markers and put them in an array and select them at random

Share this post


Link to post
Share on other sites

Could always borrow the ideas behind BTC's Mobile HQ script and modify it a bit. A marker in the center point of your area, X and Y values of your marker plus randomly calculated numbers and a Z value for elevation at the end. Just increase the numbers (25) for longer distances. Just an idea, hope it gets the brain juices flowing.

_pos = getMarkerPos "mkr1";

player setPos [(_pos select 0) + ((random 25) - (random 25)), (_pos select 1) + ((random 25) - (random 25)), 0];

Share this post


Link to post
Share on other sites
What i do is just make a whole mess of markers and put them in an array and select them at random

Yeah that's probably what I'll do because it seems the only way.

Could always borrow the ideas behind BTC's Mobile HQ script and modify it a bit. A marker in the center point of your area, X and Y values of your marker plus randomly calculated numbers and a Z value for elevation at the end. Just increase the numbers (25) for longer distances. Just an idea, hope it gets the brain juices flowing.

_pos = getMarkerPos "mkr1";

player setPos [(_pos select 0) + ((random 25) - (random 25)), (_pos select 1) + ((random 25) - (random 25)), 0];

I got the random spawn already working, what I want to achieve is the possibility that someone can spawn with another player.

Inviato dal mio GT-I9300 utilizzando Tapatalk

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  

×