Jump to content

Recommended Posts

Hello, I'm developing an airborne mission for my group, basically the guys (Two fire-team consisting of four members each, named A1, A2, A3, A4, B1, B2, B3, B4) spawn in an C-130 and parachute into the A.O. The problem is, I need them to have their backpacks when they land, so they have enough ammo and equipment to complete the mission, so I came up with this Idea, a trigger executing a script for each unit, the script will wait until they land and then add backpacks and equipment into it.
 
The C-130 will enter the trigger area with the team onboard. These are the trigger's specs:
 
ACTIVATION: BLUFOR
ACTIVATION TYPE: PRESENT
CONDITION: this && isServer
ON ACT:
 
para1 = [] execvm "scripts\backpack\A1.sqf";
para2 = [] execvm "scripts\backpack\A2.sqf";
para3 = [] execvm "scripts\backpack\A3.sqf";
para4 = [] execvm "scripts\backpack\A4.sqf";
para5 = [] execvm "scripts\backpack\B1.sqf";
para6 = [] execvm "scripts\backpack\B2.sqf";
para7 = [] execvm "scripts\backpack\B3.sqf";
para8 = [] execvm "scripts\backpack\B4.sqf";
 
Now this is the A1.sqf script:

_backpackA=0;

//defined variable to stop the loop

 

while {_backpackA < 1} do {sleep 1;

waitUntil {

(getPosATL A1 select 2) < 2 ;

//wait until the player is less the 2 meters high from the ground

};
 
_backpackA = _backpackA + 3;
sleep 3;
A1 addBackpack "rhsusf_assault_eagleaiii_ocp";
A1 addItemToBackPack "rhs_mag_an_m8hc";
A1 addItemToBackPack "rhs_mag_an_m8hc";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "rhs_mag_M441_HE";
A1 addItemToBackPack "ACE_elasticBandage";
A1 addItemToBackPack "ACE_elasticBandage";
A1 addItemToBackPack "ACE_elasticBandage";
A1 addItemToBackPack "ACE_quikclot";
A1 addItemToBackPack "ACE_quikclot";
A1 addItemToBackPack "ACE_quikclot";
A1 addItemToBackPack "ACE_epinephrine";
A1 addItemToBackPack "ACE_MapTools";
A1 addItemToBackPack "ACE_morphine";
A1 addItemToBackPack "ACE_morphine";
A1 addItemToBackPack "ACE_morphine";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_packingBandage";
A1 addItemToBackPack "ACE_tourniquet";
};

 

I tested it and it worked great, except when I tested it in a multiplayer server (I hosted it locally), I got in as unit A1. When I landed, the script worked and the parachute got replaced by the backpack and the defined contents, however it didn't work for the other player, their parachutes didn't get replaced by the intended backpacks, At first I thought I could've screwed the script for their units, so I restarted the mission and got in as another unit (A2), as some of you guys may imagine, I got my backpack just fine, but the other players didn't, not even the unit I just tested (A1). I tested all the other units and it worked great when I was playing as them, but no one else got their backpacks.

 

As you guys probably know, I think I fucked up the locality of the script execution, not sure how, could any of you guys enlighten me as how to make this thing work?

 

We usually use conventional hosting (through the game Multiplayer menu) and Dedicated hosting, so it would need to be something that works for both.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

You need to rewrite the script to use with passed trigger thislist and condition which will  check the unit variable name or type.

Share this post


Link to post
Share on other sites

So youre executing a individual script for every player? Strange.

Yes its a locality problem. If it were me, I would entirely skip the trigger and simplify the code (look into for loops so you can shorten code like this a lot):

Put this straight into your mission folder root.

initplayerlocal.sqf

waituntil {getposATL player select 2 < 2};

player addBackpack "rhsusf_assault_eagleaiii_ocp";
player addItemToBackPack "rhs_mag_an_m8hc";
player addItemToBackPack "rhs_mag_an_m8hc";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_30Rnd_556x45_M855A1_Stanag_Tracer_Orange";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "rhs_mag_M441_HE";
player addItemToBackPack "ACE_elasticBandage";
player addItemToBackPack "ACE_elasticBandage";
player addItemToBackPack "ACE_elasticBandage";
player addItemToBackPack "ACE_quikclot";
player addItemToBackPack "ACE_quikclot";
player addItemToBackPack "ACE_quikclot";
player addItemToBackPack "ACE_epinephrine";
player addItemToBackPack "ACE_MapTools";
player addItemToBackPack "ACE_morphine";
player addItemToBackPack "ACE_morphine";
player addItemToBackPack "ACE_morphine";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_packingBandage";
player addItemToBackPack "ACE_tourniquet";
};

Share this post


Link to post
Share on other sites

You need to rewrite the script to use with passed trigger thislist and condition which will  check the unit variable name or type.

I'm not really sure how to do this... Actually, I'm not really sure I understood what you meant... Could you please give an example?

Share this post


Link to post
Share on other sites

That wont address the locality issues you're going to get using triggers. Have you tested this on a dedicated server? because player gear is local and triggers execute on server.

You're better of using what I posted as it will not only execute clientside, it will also work for any player that joins and any amount of players. (assuming I did it correctly, it was a quick fix)

Share this post


Link to post
Share on other sites

That wont address the locality issues you're going to get using triggers. Have you tested this on a dedicated server? because player gear is local and triggers execute on server.

You're better of using what I posted as it will not only execute clientside, it will also work for any player that joins and any amount of players. (assuming I did it correctly, it was a quick fix)

I was also going to ask you about your sugestion. The thing is, putting all the eight gear scripts in the same file, may generate some problems, like, lets say I write all of the scripts inside of this file initplayerlocal.sqf in the specific order, A1, A2, A3, A4, B1, B2, B3 and B4. So what would happen if A4 decides he won't jump? Would Bravo team still get their gear when they land? Because I imagine the script would be on hold on the "waitUntil" for unit A4, since he didn't land.

 

Second question, wouldn't this script run in the order I wrote it instead of the order units land? Lets say the entire Bravo team lands, but they won't get their gear, because of the lazy A1 who still didn't make to the ground.

 

I need the units to get their gear independently of what happens to the other units, and I need it to happen the instant they hit the ground, would your suggestion accomplish that?

 

Thanks in advance!

Share this post


Link to post
Share on other sites

the solution in post #3 will work client side. that means every connected player will execute the script as its own thread. so its not executed once only. u can modify the script with some if then constructs to give a specific unit its specific gear.

if(player==A1)then

{

//gear script for A1

};

 

 

EDIT switch do solution:

initPlayerLocal.sqf

waitUntil {sleep 1; getposATL player select 2 < 2};

switch (player) do {
    case A1: {[] execvm "scripts\backpack\A1.sqf";};
    case A2: {[] execvm "scripts\backpack\A2.sqf";};
    case A3: {[] execvm "scripts\backpack\A3.sqf";};
    case A4: {[] execvm "scripts\backpack\A4.sqf";};
    case A5: {[] execvm "scripts\backpack\A5.sqf";};
    case A6: {[] execvm "scripts\backpack\A6.sqf";};
    case A7: {[] execvm "scripts\backpack\A7.sqf";};
    case A8: {[] execvm "scripts\backpack\A8.sqf";};
};
Edited by sarogahtyp
  • Like 1

Share this post


Link to post
Share on other sites

In server locality it executes once. In client locality it will execute once on every machine, so for every connected player. So every player will get their gear at the moment they are below 2m ATL, totally independantly of everything else including other players. Sarogahtyp has a solution for unit specific gear also. It will work.

Locality can be hard to wrap your head around, check out this http://killzonekid.com/arma-scripting-tutorials-locality/

Edit: Also it is good practice to use a sleep in waituntil code like above, I just forgot to do it.

  • Like 1

Share this post


Link to post
Share on other sites

You can use waitUntil { isTouchingGround player};

  • Like 1

Share this post


Link to post
Share on other sites

In server locality it executes once. In client locality it will execute once on every machine, so for every connected player. So every player will get their gear at the moment they are below 2m ATL, totally independantly of everything else including other players. Sarogahtyp has a solution for unit specific gear also. It will work.

Locality can be hard to wrap your head around, check out this http://killzonekid.com/arma-scripting-tutorials-locality/

Edit: Also it is good practice to use a sleep in waituntil code like above, I just forgot to do it.

 

Thanks for the link. MKD3. It's very helpful and clarified a lot of things to me.

I got the script to work, not in a very elegant way I must confess...

 

I placed a trigger in the jumping zone, on act the trigger would "set damage 1" to a civilian unit named "civtrigger"

I placed another trigger with the condition "!alive civtrigger", on act it would call the scripts...

It worked, although I don't feel very good about such lousy solution...

Is there a way to for a specific unit to run a script? Something like ([A1] execvm "scripts\backpack\A1.sqf";)

 

Thanks for the help!

  • Like 1

Share this post


Link to post
Share on other sites

man, LOOK AT post #7 ! I gave u all u need... if u dont understand things just ask

  • Like 1

Share this post


Link to post
Share on other sites

Just so you guys know how I fixed the locality issue:

 

I created a unit name "AItrigger" far away

I created a trigger (BLUFOR present), ON ACT: "AItrigger setDamage 1;"

I created a trigger (!alive AItrigger), ON ACT it calls all of the scripts

 

It's not a very elegant solution, but it solved the problem in time for the mission.

 

Thank you guys, very much, I'll definitely apply your solutions in the missions to come!

 

=)

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

×