Jump to content
interectic

Random Player Spawn

Recommended Posts

I have looked all over but I haven't found an easy or direct tutorial on making a random player spawn at the beginning of a mission. I want to you this in multiplayer where the players are randomly scattered around the map. Please help!

Share this post


Link to post
Share on other sites

Create some markers around the map and then in initPlayerLocal

_spawn_pos = ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6", "marker7", "marker8", "marker9", "marker10"] call BIS_fnc_selectRandom;
waitUntil {!isnull player};
player setPos (getMarkerPos _spawn_pos);

or in init.sqf

if (hasInterface) then {

_spawn_pos = ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6", "marker7", "marker8", "marker9", "marker10"] call BIS_fnc_selectRandom;
waitUntil {!isnull player};
player setPos (getMarkerPos _spawn_pos);
};

Share this post


Link to post
Share on other sites

 

Create some markers around the map and then in initPlayerLocal

_spawn_pos = ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6", "marker7", "marker8", "marker9", "marker10"] call BIS_fnc_selectRandom;
player setpos (getMarkerPos _spawn_pos);

can this be used for multiplayer?

Share this post


Link to post
Share on other sites

Why not?

Every player executing that code will receive different (most likely) spawn point.

Share this post


Link to post
Share on other sites

Why not?

Every player executing that code will receive different (most likely) spawn point.

Thank you very much! Do you make missions a lot?

Share this post


Link to post
Share on other sites

Sometimes but big only

Well I was curious if you could help me with some stuff sometime?

Share this post


Link to post
Share on other sites

Sure i am always open to help if it will not overrun my knowledge.

 Contact me direct if you wish.

 

Anyway we have here a great community if you ask with sense you will get your answer very quickly.

Share this post


Link to post
Share on other sites

Sure i am always open to help if it will not overrun my knowledge.

 Contact me direct if you wish.

 

Anyway we have here a great community if you ask with sense you got your answer very quickly.

Yeah I can see that. Thank you.

Share this post


Link to post
Share on other sites
while {surfaceIsWater (getPos player)} do
{
	_randPos = [random 10000, random 10000, 0];
	player setPosATL _randPos;
};

Put all players in the water in the editor

Share this post


Link to post
Share on other sites
while {surfaceIsWater (getPos player)} do
{
	_randPos = [random 10000, random 10000, 0];
	player setPosATL _randPos;
};

Put all players in the water in the editor

 

Thank you man, I will try this out.

Share this post


Link to post
Share on other sites

Hello i try to do something similar for dedicated server and JIP compatible but without success.

 

I would like to create a ramdom spawn for civilian player around few other blufor player (p1,p2,p3....) so i use a marker everything work fine in the editor the marker auto update randomly around the selected unit but nothing work on dedicated, the marker don't move

 

I use this in the init.sqf

if ((!isServer) && (player != player)) then {waitUntil {player == player};};

[] spawn {
while{not isnull selectRandom [p1,p2,p3,p4,p5]} do {"respawn_civilian" setmarkerpos (selectRandom [p1,p2,p3,p4,p5] getpos [500, random 360]); sleep 5;};
};

 

I think its because the marker don't find any of this player when the server start (p1,p2...) and stop working.

 

My question there is a simple way to make a random respawn for a specific side around player with variable name ? 

 

 

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

×