Jump to content
Sign in to follow this  
KingoftheSandbox

Mp Script//move playable units in parachutes

Recommended Posts

I call this script with null=execVM "parachute.sqf"; If i host a MP game all the AI´s get moved into the parachutes, also the host player, but not other players. I suck at scripting, how i can i solve this?

chute_1 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_1 setPos [getPos parapos1 select 0, getPos parapos1 select 1, 300]; 
GB1 moveinDriver chute_1;
chute_1 setDir 150;	

chute_2 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_2 setPos [getPos parapos2 select 0, getPos parapos2 select 1, 300]; 
GB2 moveinDriver chute_2;
chute_2 setDir 150;	

chute_3 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_3 setPos [getPos parapos3 select 0, getPos parapos3 select 1, 300]; 
GB3 moveinDriver chute_3;

chute_4 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_4 setPos [getPos parapos4 select 0, getPos parapos4 select 1, 300]; 
GB4 moveinDriver chute_4;
chute_4 setDir 150;	

chute_5 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_5 setPos [getPos parapos5 select 0, getPos parapos5 select 1, 300]; 
GB5 moveinDriver chute_5;
chute_5 setDir 150;	

chute_6 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_6 setPos [getPos parapos6 select 0, getPos parapos6 select 1, 300]; 
GB6 moveinDriver chute_6;
chute_6 setDir 150;	

Share this post


Link to post
Share on other sites

where do you execute this script?

Here a cleaner way of it, but makes basicly the same:

private["_chute","_paraposReal"];

_paraposReal = [getPosATL parapos select 0, getPosATL parapos select 1, 300];

{
_chute = "Steerable_Parachute_F" createVehicle [0,0,0]; 
_chute setPosATL [_paraposReal select 0 + random 3,_paraposReal select 1 + random 3,_paraposReal select 2]; //randomize spawnpos
_x moveinDriver _chute;
_chute setDir 150;
} forEach playableUnits;

Edited by Lappihuan

Share this post


Link to post
Share on other sites

Thanks again for your help Lappihuan. This is pretty complicated stuff here for me, but i want to make the coop version same as the sp.

First of all im gettin an missing [ error on your script, but if my noobish script should work at all and this does the same, il get you some more details.

The overall problem in my coop missions is the following. I want the mission to be playable in all options. Means with 6 players or less players with AI, or for example with 2 players.

The problem starts allready with LEA, the loadout script. If i give GB1, GB2, GB3 and so on loadout and not all players or AI´s are there at all, script fails because it cant find GB6 if not slotted by AI or player.

What i need now would be an method which checks, if the slot is a player or ai=is it there at all. as you said allready i could use playableUnits for that.

Looks like with LEA there is no way to have one slot which is defined with a variable not connected. So i think i have to play allways with all slots, AI or players.

Now i think the problem connected to my script is that i use the Strategic Map Module, which is not yet designed for MP. The module calls a script and it looks like it does that only local for the host.

How would i make sure a script would be executed for all clients, if only the host executes the inital script local? Thanks in advance...

Share this post


Link to post
Share on other sites

Had a copy&paste error in it ^^ i updatet my post above...

I think you just should never use static names in this case.

Allways use playableUnits.

Share this post


Link to post
Share on other sites

Not working, does nothing for some reason. But il see, MP scripting is way to advanced without having some good basic scripting knowledge;-(

Share this post


Link to post
Share on other sites

If you use playableUnits, you will need to test in a MP environment or it will return [];

try using:

{
   // parachute stuff here
} forEach (switchableUnits + playableUnits);

then you can test it in the SP editor.

Share this post


Link to post
Share on other sites

note that i changed parapos1 - 6 (game logic or what ever you have in the editor) to just parapos and added a radomizer for the x,y koordinates.

Share this post


Link to post
Share on other sites

Thanks, DasAttorney for the hint!

@Lappihuan Yea, i created parapos and now i use this code

private["_chute","_paraposReal"];

_paraposReal = [getPosATL parapos select 0, getPosATL parapos select 1, 300];

{
_chute = "Steerable_Parachute_F" createVehicle [0,0,0]; 
_chute setPosATL [_paraposReal select 0 + random 3,_paraposReal select 1 + random 
3,_paraposReal select 2]; //randomize spawnpos
_x moveinDriver _chute;
_chute setDir 150;
}  forEach (switchableUnits + playableUnits);  

drops an error on line 7 now. Typ "Every" expecting number

Share this post


Link to post
Share on other sites

I'm at work so I can't check but it might be this line:

_chute setPosATL [_paraposReal select 0 + random 3,_paraposReal select 1 + random  3,_paraposReal select 2];

Try some brackets (Arma gets confused with formatting sometimes)

_chute setPosATL [(_paraposReal select 0) + random 3,(_paraposReal select 1) + random  3,_paraposReal select 2];

Everything else looks gravy to me :)

Share this post


Link to post
Share on other sites

private["_chute","_paraposReal"];

_paraposReal = [getPosATL parapos select 0, getPosATL parapos select 1, 300];

{
_chute = "Steerable_Parachute_F" createVehicle [0,0,0]; 
_chute setPosATL [(_paraposReal select 0) + random 3,(_paraposReal select 1) + random  3,_paraposReal select 2]; //randomize spawnpos
_x moveinDriver _chute;
_chute setDir 150;
}  forEach (switchableUnits + playableUnits);  

This works, but for some reason there are about 10 extra empty parachutes created. Adjusting the radius shouldnt be a problem for me (all are bunched up on one place dying a glory airborne dead, lol.)

i call this script from the init with "null=execVM "script.sqf";

In Editor this works nice, tested with 2 players in multiplayer.

Edited by KingoftheSandbox

Share this post


Link to post
Share on other sites

I think the extra parachutes get spawned because every client and the server execute this code.

You need to make sure this is only executet on the server like this:

if (isServer) then {
private["_chute","_paraposReal"];

_paraposReal = [getPosATL parapos select 0, getPosATL parapos select 1, 300];

{
_chute = "Steerable_Parachute_F" createVehicle [0,0,0]; 
_chute setPosATL [(_paraposReal select 0) + random 30,(_paraposReal select 1) + random  30,_paraposReal select 2]; //randomize spawnpos
_x moveinDriver _chute;
_chute setDir 150;
}  forEach (switchableUnits + playableUnits);  
};

parachutes should now spawn in a radius of 30m instead of 3m.

also not tested btw.

Share this post


Link to post
Share on other sites

hey, had no time till yet to work on that script, now, what i tried is this the code below.

It works, but there are still some extra parachutes created!?

if (isServer) then {
null=execVM "scripts\parachute_insertion.sqf";
};

if (isServer) then {

if (!isNil "GB1") then {

chute_1 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_1 setPos [getPos parapos1 select 0, getPos parapos1 select 1, 300]; 
GB1 moveinDriver chute_1;
chute_1 setDir 150;	

};

if (!isNil "GB2") then {


chute_2 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_2 setPos [getPos parapos2 select 0, getPos parapos2 select 1, 300]; 
GB2 moveinDriver chute_2;
chute_2 setDir 150;	

};


if (!isNil "GB3") then {


chute_3 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_3 setPos [getPos parapos4 select 0, getPos parapos3 select 1, 300]; 
GB3 moveinDriver chute_3;
chute_3 setDir 150;	

};


if (!isNil "GB4") then {


chute_4 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_4 setPos [getPos parapos4 select 0, getPos parapos4 select 1, 300]; 
GB4 moveinDriver chute_4;
chute_4 setDir 150;	

};


if (!isNil "GB5") then {


chute_5 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_5 setPos [getPos parapos5 select 0, getPos parapos5 select 1, 300]; 
GB5 moveinDriver chute_5;
chute_5 setDir 150;	

};


if (!isNil "GB6") then {


chute_6 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_6 setPos [getPos parapos6 select 0, getPos parapos6 select 1, 300]; 
GB6 moveinDriver chute_6;
chute_6 setDir 150;	

};

};

Share this post


Link to post
Share on other sites

I think it's a genuine Arma bug rather than an issue with your script.

I've got a similar script for para deployment and on a dedi it always produces an extra empty parachute per unit (not sure if extra players would generate more empty parachutes).

I've made sure it's only run on the dedi with:

if (isDedicated) then
{
   // para stuff
};

But still it's spawning the empties.

If you check your .rpt, it might say something about

Cannot create object "parachute_class_name" with scope = private

Not sure what the deal is there but it's been going on for some time.

Share this post


Link to post
Share on other sites

I have just recently gone through similar issues myself. You need to switch back and forth between the server and the owner of the AI a few times.

You can use the local command to see if you are in charge of them. If you are, you need to set their position to where ever they are falling from.

When you are ready to open a parachute, you need to have the server create the parachute.

Then, the person that owns the AI needs to tell AI to move in as driver.

This will only create one parachute.

These commands will be helpful.

https://community.bistudio.com/wiki/local

https://community.bistudio.com/wiki/BIS_fnc_MP

If this doesn't make sense, I can post something later

Edited by brians200

Share this post


Link to post
Share on other sites

Back on the problem: I solved the duplicating of parachutes by assigning publicVariables for the chutes. Now the problem remains: Only the host is moved into the parachute & AI, not players. Parachutes are created for the players, but they are not moved into.

if (isServer) then {


if (!isNil "GB1" AND local GB1) then {

chute_1 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_1 setPos [getPos parapos1 select 0, getPos parapos1 select 1, 300]; 
publicVariable "chute_1";
sleep 0.5;
GB1 assignAsDriver chute_1;
GB1 action ["GetInDriver", chute_1]; 
chute_1 setDir 150;

};

if (!isNil "GB2" AND local GB2) then {


chute_2 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_2 setPos [getPos parapos2 select 0, getPos parapos2 select 1, 300]; 
publicVariable "chute_2";
sleep 0.5;
GB2 assignAsDriver chute_2;
GB2 action ["GetInDriver", chute_2]; 
chute_2 setDir 150;

};


if (!isNil "GB3" AND local GB3) then {


chute_3 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_3 setPos [getPos parapos4 select 0, getPos parapos3 select 1, 300]; 
publicVariable "chute_3";
sleep 0.5;
GB3 assignAsDriver chute_3;
GB3 action ["GetInDriver", chute_3]; 
chute_3 setDir 150;

};


if (!isNil "GB4" AND local GB4) then {


chute_4 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_4 setPos [getPos parapos4 select 0, getPos parapos4 select 1, 300]; 
publicVariable "chute_4";
sleep 0.5;
GB4 assignAsDriver chute_4;
GB4 action ["GetInDriver", chute_4]; 
chute_4 setDir 150;

};


if (!isNil "GB5" AND local GB5) then {


chute_5 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_5 setPos [getPos parapos5 select 0, getPos parapos5 select 1, 300]; 
publicVariable "chute_5";
sleep 0.5;
GB5 assignAsDriver chute_5;
GB5 action ["GetInDriver", chute_5]; 
chute_5 setDir 150;

};


if (!isNil "GB6" AND local GB6) then {


chute_6 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_6 setPos [getPos parapos6 select 0, getPos parapos6 select 1, 300]; 
publicVariable "chute_6";
sleep 0.5;
GB6 assignAsDriver chute_6;
GB6 action ["GetInDriver", chute_6]; 
chute_6 setDir 150;

};

if (!isNil "GB7" AND local GB7) then {

chute_7 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_7 setPos [getPos parapos7 select 0, getPos parapos7 select 1, 300]; 
publicVariable "chute_7";
sleep 0.5;
GB7 assignAsDriver chute_7;
GB7 action ["GetInDriver", chute_7]; 
chute_7 setDir 150;
};

if (!isNil "GB8" AND local GB8) then {


chute_8 = "Steerable_Parachute_F" createVehicle [0,0,0]; 
chute_8 setPos [getPos parapos8 select 0, getPos parapos8 select 1, 300]; 
publicVariable "chute_8";
sleep 0.5;
GB8 assignAsDriver chute_8;
GB8 action ["GetInDriver", chute_8]; 
chute_8 setDir 150;
};
};

I found this on the BIS biki, no way to make it work then with the movein command?

Notes from before the conversion: MP Note Functions MoveInDriver can only be called for local soldiers. They will be ignored for remote soldiers. (see Locality in Multiplayer)

Share this post


Link to post
Share on other sites

I found out where my duplicates were coming from. I was scripting it in the onAct box for waypoints and I forgot the code runs globally, so I put some checks in for locality and now it's fine.

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  

×