Jump to content
Sign in to follow this  
PhelanKA7

AddAction problem in MP

Recommended Posts

I'm having a problem getting an AddAction script to work correctly in multiplayer. The Action is set on an object which moves the player into cargo of a vehicle. There are three different scripts for three different barrels depending on the player's squad.

In Single Player (ie - testing the mission from the editor) the correct AddAction appears depending on what squad the player is in, and all is well.

In Multiplayer however, the AddAction only shows up for the squad leaders of each team, and once one of the actions pops up for any of them, all other players can only see that action for that barrel.

I'm almost positive that the problem arises from saying "if (player == a1) then { AddAction ["Board Alpha boat", "alphaboard.sqf"]"

On each barrel I have the following script initialized as

nul = [this, alphaboat] execVM "alphabarrel.sqf"

Script:

_barrel = _this select 0;
_boat = _this select 1;

sleep 2;

if (player == a1) then 
{
_barrel AddAction ["Board Alpha boat", "boardalpha.sqf"];
sleep 2;


}

else { 	

if (player == a2) then {

_barrel AddAction ["Board Alpha boat", "boardalpha.sqf"];
sleep 2;

}

else {

if (player == alphademo) then {

_barrel AddAction ["Board Alpha boat", "boardalpha.sqf"];
sleep 2;

}

else {

if (player == a4) then {

_barrel AddAction ["Board Alpha boat", "boardalpha.sqf"];
sleep 2;
}
else {

if (player == a5) then {

_barrel AddAction ["Board Alpha boat", "boardalpha.sqf"];
sleep 2;	

}
else {

_barrel AddAction ["Wrong barrel!", "wrongbarrel.sqf"];
sleep 2;
}
}
}
}
}
};

Do I need to pass the unit's variable somehow instead of relying on "player == blah"?

How do I do that?

Thanks for any help!

Share this post


Link to post
Share on other sites

Try this:

if (player in (units a1)) then

and so on.

Share this post


Link to post
Share on other sites

Thanks for the quick reply, but no dice. I tried that and it didn't work.

One other thing I forgot to mention is that the script works if AI Units are enabled. As soon as you start the mission with AI units disabled, the script doesn't work.

Share this post


Link to post
Share on other sites

Create/name the groups by putting this into the members init field:

grpAlpha = group this

Put that into each member to make sure it's always created, because if theres no AI or human in the unit, it wont be created, thus the init field is not executed, which means no squad naming.

To alpha boat's init field:

this addAction ["Board boat","board.sqf",[],5,false,true,"","group player == grpAlpha"]

You can use the same thing for other groups, just change "grpAlpha" to whatever you want.

board.sqf

(_this select 1) moveincargo (_this select 0);
(_this select 0) removeAction (_this select 2);

Share this post


Link to post
Share on other sites
Create/name the groups by putting this into the members init field:

grpAlpha = group this

Put that into each member to make sure it's always created, because if theres no AI or human in the unit, it wont be created, thus the init field is not executed, which means no squad naming.

To alpha boat's init field:

this addAction ["Board boat","board.sqf",[],5,false,true,"","group player == grpAlpha"]

You can use the same thing for other groups, just change "grpAlpha" to whatever you want.

board.sqf

(_this select 1) moveincargo (_this select 0);
(_this select 0) removeAction (_this select 2);

Worked like a charm! Thanks!

I'd always kind of wondered how the arrays for AddAction worked.

Share this post


Link to post
Share on other sites

You can pass AddAction an array of variables inside the [] there. It'll be _this select 3 within the script.

_this select 0 = the object the action is on

_this select 1 = the object that's calling the action

_this select 2 = the ID number of the addAction

_this select 3 = the array after the script name.

So if your addAction was: this addAction["Make Sweet Love","businesstime.sqf",[2,nancy,"I am so sorry, that never happens"]];

(_this select 3) select 0 = 2

(_this select 3) select 1 = nancy

(_this select 3) select 2 = "I am so sorry, that never happens"

Share this post


Link to post
Share on other sites

Sorry to 'borrow your thread Phelan...

Kylania, are those same that would be in a radio trigger?

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  

×