Jump to content
Coladebote

Random spawn group of players

Recommended Posts

Hello guys:
The group of players (8 riflemen grouped to the leader) must appear at the beginning of each mission at a different point in Altis. I have distributed five empty markers grouped to the leader on the map. When all roles are filled by players, the leader does appear randomly at any point, but the rest of the players stay where they were placed in the editor.

I have used these two lines of code separately and they don't work.

 

TEST 1.-

{vehicle _x setpos formationposition _x} foreach units this ;

 

TEST 2.-

this setpos (getMarkerPos (selectRandom ["marker_1", "marker_2", "marker_3", "marker_4", "marker_5", "marker_6"]));

 

Can somebody help me?

Thank you

Share this post


Link to post
Share on other sites

The leader:  Name the leader blue1.

Place 5 markers on the map as you have done and he will start at one of 5 places at random.

At each of the five locations, place a trigger.  The trigger is fired by blue1.

 

The other soldiers are named:  blue2  through to blue8

 

In each of the triggers type code:

blue2 setpos getpos blue1

blue3 setpos getpos blue1

etc etc

blue8 setpos getpos blue1

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

 Just sync all markers to all units, rather than just the group leader.

  • Like 1

Share this post


Link to post
Share on other sites

This weekend I do the tests and I already comment.

Thanks guys.

Share this post


Link to post
Share on other sites

Harzach gives you a solution spreading randomly all your units.


If you want to teleport a group, you need to script something. The "set random start"  link is useful in SP, for the leader, then:
0 = this spawn {waitUntil {sleep 1; isPlayer leader _this}; {_x setpos (leader _this getpos [random (15 * sqrt 1),random 360])} count units _this};

in init field of the group icon.

 

In MP, it's a little bit more difficult. First of all you want to stay at initial position, even leader, at start, until all roles are played.

So, i suggest you no link on triggers, and add a trigger: none none not repeatable, SERVER ONLY;

cond:                {isPlayer _x} count units yourGroup == count units yourGroup

on act:              leader yourGroup setPos getMarkerPos (selectRandom yourMarkerArray); {_x setpos (leader yourGroup getpos [random (15 * sqrt 1),random 360])} forEach units yourGroup

  • Like 1

Share this post


Link to post
Share on other sites

Hello:
With Harzach's recommendation, each unit in the group appears at one point on the map, not all together on the same empty marker.

Can you tell me, Pierre, what code, exactly, should I insert in the trigger: 'condition' and 'when activated'?

It is that with the lines that you have indicated, it gives errors.

Excuse me, but you know that my knowledge in this matter is very poor.

Thank you.

Share this post


Link to post
Share on other sites
On 6/25/2020 at 9:35 AM, Harzach said:

 Just sync all markers to all units, rather than just the group leader.

Soldier 1 begins at any of 5 markers at random

Soldier 2 begins at any of 5 markers at random

Or,  your method means the 8 soldiers are spread between the 5 markers.

Share this post


Link to post
Share on other sites

It is a scenario in Altis where you have to survive, there are several objectives and it is set with modules from the RAVAGE mod.

The players, leader and other components must all appear together, but each time the mission begins, at a different point on the map.

That's the idea.

Share this post


Link to post
Share on other sites

Sorry, misunderstood your intent. This is easy.

initServer.sqf:

spawnPos = ["marker1","marker2","marker3","marker4","marker5"] call BIS_fnc_selectRandom; 
publicVariable "spawnPos";

initPlayerLocal.sqf:

waitUntil {!isNull player};
player setPos getMarkerPos spawnPos;

 

Share this post


Link to post
Share on other sites
6 hours ago, Coladebote said:

Hello:
With Harzach's recommendation, each unit in the group appears at one point on the map, not all together on the same empty marker.

Can you tell me, Pierre, what code, exactly, should I insert in the trigger: 'condition' and 'when activated'?

It is that with the lines that you have indicated, it gives errors.

Excuse me, but you know that my knowledge in this matter is very poor.

Thank you.

 

These lines work. But you need to replace yourGroup by the name you gave to your group in the editor. yourMarkerArray is the array of your existing markers, for example: ["mk1","mk2","mk3"]  Each time you refer to an error, try to report it.

 

Harzach gives you a good method for spawning all the players on the same randomized (at init) marker.

 

I gave you a mean to teleport all players in a group at the same time once the group is entirely played.

Share this post


Link to post
Share on other sites

Hello Harzach, I have tried the code that you have indicated, but it does not work.

In the link you have the proof of the mission as you have indicated. All units are linked to empty markers.

The problem is that each player appears at a different point.

I may have done something wrong. Not?

Thank you.

 

TEST LINK (WITHOUT ADDONS):

https://drive.google.com/file/d/1j2WYvOC_ytCIRH48VNGmF7anDBHRKub7/view?usp=sharing

Share this post


Link to post
Share on other sites

Hello Pierre:
From your indications I interpret that the instruction must be as follows:

 

cond:
{isPlayer _x} count units yourGroup == count units yourGroup

 

on act:
leader yourGroup setPos getMarkerPos (selectRandom  ["marker1","marker2","marker3","marker4","marker5","marker6","marker7","marker8","marker9","marker10"]); {_x setpos (leader yourGroup getpos [random (15 * sqrt 1),random 360])} forEach units yourGroup;

 

It is right?

Thank you.

Share this post


Link to post
Share on other sites

lol  yourGroup is the name you wrote in editor, init field of the group icon?  It was just an example.  Your marker array seems correct if these markers exist.

Share this post


Link to post
Share on other sites

I try it right now. He informed him of the result in a few minutes.
Thanks, Pierre.

Share this post


Link to post
Share on other sites

I am doing something wrong, because it gives an error.

 

The group is called Alpha 1-1.

 

When the condition line is inserted in the trigger, it does not give any error
({isPlayer _x} count units Alpha1-1 == count units Alpha1-1;)

 

The error occurs on the line that is inserted for activation.
(leader alpha1-1 setPos getMarkerPos (selectRandom ["marker1 ","marker2","marker3","marker4","marker5","marker6","marker7","marker8","marker9","marker10"]); {_x setpos (leader yourGrou p getpos [random (15 * sqrt 1),random 360])} forEach units alpha1-1;)

 

In the link you can download an image of the screen dump where the error appears.

 

https://drive.google.com/file/d/1dyM162ormiWBvlTEzxeZbUWCve0w4555/view?usp=sharing

 

Thanks, Pierre.

Share this post


Link to post
Share on other sites

No, you need to name the group in the name field of the group icon. Alpha1-1 is a reference, not a variable name usable in scripts.
And you need to replace all yourGroup I wrote by your group name, You forgot one.

NB: and it seems to me you have an unwanted space in yourGrou p   so that throws an extra error. But you should focus on naming the group and place this name everywhere it needed in my code.

Share this post


Link to post
Share on other sites

Hi Pierre, it doesn't work.

I've called the team leader LEADER
The rest of the units are grouped to the leader
Leader and empty markers are not linked.

The lines of code used are as follows:

 

cond:
{isPlayer _x} count units yourGroup == count units LIDER;

on act:
LIDER setPos getMarkerPos (selectRandom ["marker1","marker2","marker3","marker4","marker5","marker6","marker7","marker8","marker9","marker10"]); {_x setpos (LIDER getpos [random (15 * sqrt 1),random 360])} forEach units LIDER;

 

I have used the leader role and when the mission starts you appear in the same place where the units were left from the editor, not where there is an empty marker.

 

Sometimes I wonder if for such a small achievement, it is worth so much effort.

Thank you.

Share this post


Link to post
Share on other sites

I can't do anything more for you if you don't follow the explanation. I can see remaining yourGroup... You can name the leader Lider if you want (but not leader which is a command) , because units (the command) works with a unit or a group (by chance!)

 

Furthermore, the test will fail if you test as is, because the trigger is waiting for ALL units played in the group and I guess you can't have all these players for test. If you want to test from preview, I suggest : {isPlayer _x} count units Lider == 1

Share this post


Link to post
Share on other sites

Changing the leader name to another one, such as "OFFICIAL", is not a problem. I didn't know that LIDER is a command, sorry. However, there may be a problem with what you are saying about the trigger. Seven roles depend on the team leader, in total eight players. It may happen that one day the eight players can be completed and another day there is less participation. This is a problem, right?

 

So I understand that the correct lines would be like this, right?

 

on act:
{isPlayer _x} count units OFFICIAL == count units OFFICIAL


on act:
leader OFFICIAL setPos getMarkerPos (selectRandom  ["marker1","marker2","marker3","marker4","marker5","marker6","marker7","marker8","marker9","marker10"]); {_x setpos (leader OFFICIAL getpos [random (15 * sqrt 1),random 360])} forEach units OFFICIAL;

Share this post


Link to post
Share on other sites

Lider is not a command, leader is.  Pay attention for syntax. Yes, You need to have a full played group to be teleported. If you want something else, it's up to you. I can write a condition if you have some idea of what you want exactly. I replied for:

 

On 6/24/2020 at 12:17 PM, Coladebote said:

When all roles are filled by players, the leader does appear randomly at any point, ...
but the rest of the players stay where they were placed in the editor.

 

 

 

Share this post


Link to post
Share on other sites

It is not certain that the same number of players will always participate, therefore, I understand that it would be necessary to adjust the number of roles to the participants of each mission, which is impractical. It is easier to manually change, from the editor itself, the position of the players within the map. True?

I honestly believed this was easier.
In any case, thanks for your help, Pierre.

Share this post


Link to post
Share on other sites

So, the Harzach solution is OK for starting at a randomized marker, and this marker can be the same for all players of the same group.

If players can be in different groups, you'll need some extra lines (for different marker on each group).
If you're not familiar in scripting, you shouldn't start with multiplayer scenario. Anyway, the forum can help.

 

  • Thanks 1

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

×