Jump to content
NyteMyre

I just can't get moveInCargo work for all players on a dedicated server

Recommended Posts

 

Hey everyone,

 

I've been pulling my hairs out with this issue of (in my eyes) simply teleporting a group of players into a plane. The main problem is: It just randomly works for some players. But never for everyone.

I asked around on the Discord, on ArmaDev subreddit and some other scriptmakers, and i received multiple methods that should work, but so far none actually teleported all players. I haven't tried the BI forums yet though.

 

My setup

  •  4x player squads (alpha / bravo / charlie / delta)
  • 2x CJ130, (plane1 & plane2)
  • Both planes start in objectHidden true
  • Trigger 1: unhide planes, send hint to players that mission starts in 10 seconds
  • Trigger 2: 10 seconds delay:  Black out screen, show mission title screen
  • Trigger 3: 5 second delay: Run script that does the following:
    • skipTime to 23:00
    • (re)set overcast to 0 (clear skies)
    • Load squad alphabravo in plane1
    • Load squad charlie & delta in plane2
    • sleep 2
    • Ungroup all players 

 

The script (currently) looks as follows:

 

On Activation

ret = execVM "missionscripts\loadup.sqf";

loadup.sqf

if (isServer) then {
	1 setOvercast 0;
    skipTime ((23 - daytime) % 24);
    1 setOvercast 0;


    private _plane1Cargo = units alpha + units bravo;
    private _plane2Cargo = units charlie + units delta;

    {
        [_x, [plane1, _forEachIndex]] remoteExec ["moveInCargo",_x];
    } forEach _plane1Cargo;

    {
        [_x, [plane2, _forEachIndex]] remoteExec ["moveInCargo",_x];
    } forEach _plane2Cargo;

    /*Short delay*/
    sleep 2;

    /* remove from groups */
    {[_x] joinSilent grpNull;} forEach (playableUnits + switchableUnits);
};

 

IMGUR album:

https://imgur.com/a/c1Lwq

Share this post


Link to post
Share on other sites

Why do you teleport the playableUnits at server start, when they could be already inside the vehicle via 3den?

Same for their group??

Share this post


Link to post
Share on other sites
58 minutes ago, pierremgi said:

Why do you teleport the playableUnits at server start, when they could be already inside the vehicle via 3den?

Same for their group??

 

They don't start in the planes

Share this post


Link to post
Share on other sites

Perhaps you should give some more info. If your players don't start in a plane, that means they are local to their PCs and no more in server when you teleport them.

So, it's weird to make a code if (isServer) then ... teleport all playable units.

You should try a code in initPlayerLocal.sqf which runs when player is ready to game (JIP compatible)

and wait for something. I don't know what... then teleport inside the plane.

 

in initPlayerLocal:

 

waitUntil {something I don't know what};

call {

  if (player in units alfa or player in units bravo) exitWith {

   player moveInCargo plane1;

  };

  if (player in units charlie or player in units delta) exitWith {

   player moveInCargo plane2;

  };

};

 

Share this post


Link to post
Share on other sites

The planes are only there temporary for the mission start. After they paradropped the players inside (another script), the planes will get deleted.

 

8 hours ago, pierremgi said:

Perhaps you should give some more info.

 

 

I created an imgur album with my exact setup here:

https://imgur.com/a/c1Lwq

 

There's really not any more info i can give

Share this post


Link to post
Share on other sites

Houston, you have a problem. What happens when a player JIP ? Is he free to walk in the hangar? choose some loadout in crate? exit the trigger just walking? Are you waiting for each other? Do you disable AIs in lobby (severe impact on your scenario)?

 

  • Haha 1

Share this post


Link to post
Share on other sites

AIs are disabled

JIP players can move to players in the field via a framework teleport script. The trigger isn't set to repeatable so it should only fire once?

Share this post


Link to post
Share on other sites

disabled Ais are non-existent until JIP. That means playableUnits are only the array of actual players, not your 4 * 8 units.

Share this post


Link to post
Share on other sites

It could be that not all slots are filled, so that's fine.

Currently trying this:

 

switch (group player) do
{
	case alpha:
		{
			player moveincargo plane1;
		};
	case bravo:
		{
			player moveincargo plane1;
		
		};
	case charlie:
		{
			player moveincargo plane2;
		};
	case delta:
		{
			player moveincargo plane2;
		
		};
	default
		{
			player moveincargo plane2;
		};
};

 

Edit: Didn't work either :(

Share this post


Link to post
Share on other sites

moveInCargo doesn't work at 100% for some reason. I had that issue too, that it just doesn't teleport units into cargo. This is probably because of this, that moveInCargo needs some micro-delay to be done. They overlap themselves (Not sure about that). 

 

[unit1, plane1] remoteExec ["moveInCargo",0];

[unit2, plane1] remoteExec ["moveInCargo",0];

 

Probably (im not sure) unit2 can be teleported earlier to plane1 than unit1, while the teleporting of unit1 is already in progress (looks like also remoteExec works like spawn command, which adds to queue, depending how busy the engine is. But it's only my theory :D).

 

I solved it that way:

 

while {!(player in sctUral)} do
    {
        [player, sctUral] remoteExec ["moveInCargo", 0];
        sleep 0.4;
    };

 

Share this post


Link to post
Share on other sites

@jts_2009 is correct, add a small sleep between moving in each unit. Don't know why particularly, but after much testing on a dedicated with four clients as leaders of four four-man groups, some units were always left out unless you add this small sleep between each one.

 

45 minutes ago, pierremgi said:

Where did you read you have to remoteExec this command?

moveInCargo needs to be done where the unit is local (AL EG). Which will be needed for @NyteMyre if they are controlling flow from the server.

For @jts_2009 the example does not really make sense as they are using player so the unit must already be local from where the remoteExec is being called from.

 

@NyteMyre TEST MISSION Try that see if it works for your particular setup.

Share this post


Link to post
Share on other sites
53 minutes ago, Larrow said:

 

 

moveInCargo needs to be done where the unit is local (AL EG). Which will be needed for @NyteMyre if they are controlling flow from the server.

For @jts_2009 the example does not really make sense as they are using player so the unit must already be local from where the remoteExec is being called from.

 

 

 

@Larrow Sure, I don't know why Bi makes difference between "AL" and "AL with specific locality". I'm trying to explain what I guess:

 

Compare the two commands:

moveInCargo AL EG

and

allowDamage AL EG also but with a specific warning box for locality.

On my mind, the moveInCargo could be applied where the unit(s) were defined. I was wrong. :hang:

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

but with a specific warning box for locality.

The warning box is not a warning for usage locality, it is a warning that the command will need to be re-issued if the vehicle changes localitly.

Share this post


Link to post
Share on other sites

This problem is here since ofp. The easiest/safest way is to use the unit's init field.

this moveInCargo plane 1

It works every times for every players.

  • Haha 1

Share this post


Link to post
Share on other sites
10 hours ago, Larrow said:

For @jts_2009 the example does not really make sense as they are using player so the unit must already be local from where the remoteExec is being called from.

 

Thats why this is an example :D He have to adjust it. I just copied it from my coop

Share this post


Link to post
Share on other sites
2 hours ago, jts_2009 said:

I just copied it from my coop

Exactly. That is why I say your code does not make sense for your usage.

while {!(player in sctUral)} do
{
    [player, sctUral] remoteExec ["moveInCargo", 0];
    sleep 0.4;
};

You are using player, so where ever this code is running must be a client or host machine, and player refers to the the unit the client is using on this specific machine.

As the command moveInCargo must be run where the unit is local. Local must be where this code is running, due to the fact you use the command player.

So it makes no sense to remoteExec the moveInCargo command (let alone to all client machines 0) as player has to be the local unit to the machine this code is running on.

Share this post


Link to post
Share on other sites

I haven't tested it yet, but someone from my group suggested this:

 

if (isserver) then {
{
if (!isplayer _x && (side _x == WEST)) then{
switch (group _x) do
{
	case alpha:
		{
			_plane = plane1;
		};
	case bravo:
		{
			_plane = plane1;
		};
	case charlie:
		{
			_plane = plane2;
		};
	case delta:
		{
			_plane = plane2;
		
		};
	default
		{
			_plane = plane2;
		};
};
while {!(_x in _plane)} do {
_x moveincargo _plane;
};
sleep .1;
};
}foreach (playableunits);
};

 

Share this post


Link to post
Share on other sites

It could work. But the example code is only to move AI's in the planes. It does not move players. For players:

 

if (isServer) then {
	{
		if (isPlayer _x && (side _x == west)) then {
			switch (group _x) do {
				case alpha;
				case bravo: {_plane = plane1;};
				case charlie;
				case delta;
				default {_plane = plane2;};
			};
			
			while {!(_x in _plane)} do {
				_x moveInCargo _plane;
			};
			
			sleep .1;
		};
	} forEach playableUnits;
};

I still think that moving players into vehicles should be carried out on the player client and not by the server.

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

×