Jump to content
Sign in to follow this  
sputnik monroe

Question about multiplayer missions

Recommended Posts

I'm creating a FDF WW2 co op mission on Suursaari island. This is the first multiplayer mission I have ever created. I do have a few questions though.

 I've added two airstrikes that you order with 0-0-1 and 0-0-2. Now in single player the player of course can only have access to the radio if he is a squad leader or alone. However my multiplayer mission has 4 seperate human controled squads. Who has access to the 0-0-1 and 0-0-2 radio commands? I mean there are four different squad leaders.

 Is there anything else that I should know about multiplayer missions that needs to be done differently from a single player mission?

*Edit*

 I exported my mission to multiplayer and tested it out as the squad leader of each of the four teams. All four had access to the radio 0-0-1 and 0-0-2. I guess this isn't that much of a problem as long as the each command can still only be used once. I'm wondering, if say the player in squad one call's for 0-0-1 then the other three can't right? Or is it duplicated for all four squads? If that's the case my mission will be screwed up as 2 airstrikes per squad would unbalance the mission big time (that would be eight airstrikes).

 Still I am wondering, how could I set it for example so that only one of the four squads can call for the two airstrikes?

 A second idea I am toying with is giving one airstrike to team one and the other to team two, but no airstrikes for team 3 and 4 (they don't have radios)

I hope I'm making sense.

Share this post


Link to post
Share on other sites
Quote[/b] ] Is there anything else that I should know about multiplayer missions that needs to be done differently from a single player mission?

yeah... just about everything! (I jest)

Seriously though... radio triggers execute on all clients... meaning if you have 8 players and a dedicated server (regardless of how many are leaders) and one person triggers the radio, it will run a script 9 times... once on each client/server.

What you CAN do is use the trusty ol "?(!local server):exit" command to limit the script running once (on the server).

[EDIT] To elaborate, the good news is that even though there are four leaders, the activation of one will remove it on all machines if the trigger is set to run only once. Radio triggers are no different than normal triggers... they just have different activation techniques.

To give it to one leader only requires that you set the radio text (setRadioMsg) to null for all other players (i.e via init line or int.sqs). See comref.

Share this post


Link to post
Share on other sites

Thanks for resonding CrashDome. A few more questions though...

Quote[/b] ]Seriously though... radio triggers execute on all clients... meaning if you have 8 players and a dedicated server (regardless of how many are leaders) and one person triggers the radio, it will run a script 9 times... once on each client/server.

 Does this mean that if some one in my mission calls for air support that one plane will camcreate for every person playing plus the server? If so the way the airstrike script works in my mission there will be a massive explosion as 3 to 15 planes all spawn simultaneously in the same spot. If they don’t crash into each other then there will be a massive carpet bombing which will in effect kill any semblance of balance in my mission.

Quote[/b] ]What you CAN do is use the trusty ol "?(!local server):exit" command to limit the script running once (on the server).

 So do I just place that line at the beginning of the airstrike.sqs script I'm using?

Quote[/b] ]To give it to one leader only requires that you set the radio text (setRadioMsg) to null for all other players (i.e via init line or int.sqs). See comref.

 Could you elaborate on this one a little?

 Once again thanks for helping me. If you haven't noticed I'm a complete newbie when it comes to scripting and such (I didn't write the airstrike script I'm using, I simply modified it from an existing one I downloaded of OFPEC back in the day).

Share this post


Link to post
Share on other sites

Without knowing the way the script works I am assuming that once the trigger gets activated it WILL run once on each machine thus causing havoc.

Yes, put that line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(!local server):exit in the beginning of the script AND place a game logic named "server" on the map.

This will cause all clients to stop executing their scripts and only the server's will continue thus spawning only one aircraft.

Regarding the setRadioMsg... see the comref for instructions, but I am pretty sure it is <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">1 setRadioMsg "null" and <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">2 setRadioMsg "null"

What I would personally do is add a trigger and in the condition line replace it with :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player != dude where "dude" is the name of the guy who gets the radio commands

and put this in the activation line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">1 setRadioMsg "null";2 setRadioMsg "null";

Share this post


Link to post
Share on other sites

I added the ?(!local server):exit to the begining of each of my two airstrike scripts and also added a gamelogic named server on the map.

1 setradiomsg "null" hides that radio message from every one though. As a matter of fact I have that in my mission already as both radio messages are "null" until all the Anti aircraft sites on the island are destroyed then they are set from "null" to "Airstrike 1" and "Airstrike 2" respectfully.

I'm thinking it's probably alright to just let the four squad leaders share the two airstrikes. They'll just have to bicker amongst them selves if of them uses one with out the other groups permission. I still am on the fence though, I still also think it would be nice to just let squad one have access to airstrike 1 and squad two have acces to airstike 2.

Share this post


Link to post
Share on other sites

Did you try hiding them like ?NOT(player==alpha01):1 setradiomsg "NULL"; in init.sqs or what? It works at least in single player, but it might be a global command though. Someone should make an updated command reference with all the locality info and such, that'd be a lot of work though.

If it is indeed a global command then I'd use actions instead, addaction command is local, use it like ?player==alpha01:alpha01 addaction ["Airstrike 1","arty1.sqs"];

Share this post


Link to post
Share on other sites
Quote[/b] ]Did you try hiding them like ?NOT(player==alpha01):1 setradiomsg "NULL"; in init.sqs or what?

 I just tried that but I have a trigger set up that has 1 setradiomsg "Airstrike 1";2 setradiomsg "Airstrike 2"; which is activated when all the antiaircraft guns are destroyed, prior to that both messages are "null"; Well when the airstrikes are set back from "null" to "Airstrike 1" and "Airstrike 2" every squad leader has access to them again.

Quote[/b] ]If it is indeed a global command then I'd use actions instead, addaction command is local, use it like ?player==alpha01:alpha01 addaction ["Airstrike 1","arty1.sqs"];

 I actually have contemplated that. I had trouble getting the script to activate that way though and it had unlimited use (the action remained in the action menu for reuse). However I could just add  player==alpha01:alpha01 removeaction ["Airstrike 1","arty1.sqs"]; at the end of the airstrike scripts to make it a one time use correct?

 Here is the problem I have with adding the script as an action. The command to use the script is onMapSingleClick {[_pos] exec "airstrike.sqs"}; in the activation field of a trigger. I've tried Eastman addaction ["Airstrike","onMapSingleClick {[_pos] exec "airstrike.sqs"};"]; But I get an error when the script is used that way.

Share this post


Link to post
Share on other sites
Quote[/b] ]Well when the airstrikes are set back from "null" to "Airstrike 1" and "Airstrike 2" every squad leader has access to them again.

Add condition aagunsdead AND player==alpha01 to that trigger, and if there's a text message or something that should effect all, make a duplicate trigger for that without the player condition.

Quote[/b] ] However I could just add player==alpha01:alpha01 removeaction ["Airstrike 1","arty1.sqs"]; at the end of the airstrike scripts to make it a one time use correct?

Nope, but in init.sqs: ?player==alpha01:artyaction1=alpha01 addaction ["Airstrike 1","arty1.sqs"];

And in the _beginning_ of arty1.sqs: player removeaction artyaction1;

... so you can't tap it like crazy while the script is still running, plus you could add a variable to be on the safe side, like in the beginning of arty1.sqs:

?arty1activated:exit;

arty1activated=true;

player removeaction artyaction1;

...

and declare arty1activated=false in the init.sqs.

Quote[/b] ]

Here is the problem I have with adding the script as an action. The command to use the script is onMapSingleClick {[_pos] exec "airstrike.sqs"}; in the activation field of a trigger. I've tried Eastman addaction ["Airstrike","onMapSingleClick {[_pos] exec "airstrike.sqs"};"]; But I get an error when the script is used that way.

You can't pass parameters to scripts with the addaction command. However, you can pass the coordinates to the script with a variable or a marker for example. Like onMapSingleClick {"artymarker" setmarkerpos _pos;true}; and have a marker named artymarker, then with the action exec "arty1dummy.sqs" which in turn calls the real arty script with the markerpos as coordinates, like:

_coords=getmarkerpos "artymarker";

[_coords] exec "airstrike.sqs";

Share this post


Link to post
Share on other sites

Thanks again Metal Heart for your help. I actually got it working from the action menu now for both squad leaders so they each have one airstrike each. I had to create my first first two actual scripts, titled action1.sqs and action2.sqs.

  Basically I have a trigger that is condition: all aa are dead and activation hint "Both AA sites are neutralized. Air support is now available.";eastman addaction ["Airstrike","action1.sqs"];westman addaction ["Airstrike","action2.sqs"];

action1.sqs looks like this...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

onMapSingleClick {[_pos] exec "airstrike.sqs"};

strikePilot sideChat "What do you need bombed?";

hint "On the map left click to select strike location";

exit

Action2.sqs is the same but it's for the other squad leader.

 In the airstrike script I've been modifying and using I added in at the start of the script squudleadername removeaction 0 so now each squad leader can only call their airstrike once.

I only have two questions left.

1. Is there a way to set the range of an action so that only the squad leader can use it? I notice if your another player and your close enough to the squad leader the airstrike option will apear in your action bar also.

2. What would be the most efficient way to remove the action from the squad leader if he is killed and then add it to the replacement squad leader? I got to thinking if the leader dies before he calls the airstrike then the rest of the squad is simply out of luck.

Share this post


Link to post
Share on other sites

1. No but you can use the addaction locally on him.

2. Maybe in the leader's init field do groupx=group this; and have a looping script like this executed from init.sqs for each group:

#loop

_ldr=leader groupx;

?player==_ldr:player addaction ["arty","arty.sqs"];

@not(alive _ldr)

goto "loop";

You might also need a variable that prevents this happening once the arty has been used.

Share this post


Link to post
Share on other sites
Quote[/b] ]No but you can use the addaction locally on him.

Sorry to ask another stupid question, but how exactly do I do that?

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(local ldr): <addaction to leader unit code>

The problem is that you add the action via the init.sqs so every client machine adds the action to the unit thus allowing other players to activate it. By making it conditional to being a local only unit, you covertly add the action on only the specific players machine and the other machines don't know that the action exists.... (have I confused you yet?)

Share this post


Link to post
Share on other sites
Quote[/b] ]Sorry to ask another stupid question, but how exactly do I do that?

That example (with the group leader thingy) already does it locally on the player who is the leader. It has one limitation though... if AI becomes group leader, you gotta shoot it in order to get the arty action.

And forget what Crashdome said, you can add actions locally on clients form init.sqs, like this for example:

?player==alpha01: player addaction ["action","act.sqs"];

And only player who controls unit alpha01 will see the action, since it's the only client that the addaction command was executed on.

Share this post


Link to post
Share on other sites
And forget what Crashdome said, you can add actions locally on clients form init.sqs, like this for example:

?player==alpha01: player addaction ["action","act.sqs"];

And only player who controls unit alpha01 will see the action, since it's the only client that the addaction command was executed on.

That is exactly what I said. The only difference is the condition in which you determine the local unit.

icon_rolleyes.gif

Share this post


Link to post
Share on other sites

In my mission I've actually added the action via trigger later in the mission and not bt init as I don't want them to have it at the start. It has in condition not alive aa1 and not alive aa2 and not alive aa3 and not alive aa4 and not alive aa5 and not alive aa6 and then in activation hint "Both AA sites are neutralized. Air support is now available.";eastman addaction ["Airstrike","action1.sqs"];westman addaction ["Airstrike","action2.sqs"];

 I get an error when I try to use player==westman as a condition in a trigger. I tried

condition field not alive aa1 and not alive aa2 and not alive aa3 and not alive aa4 and not alive aa5 and not alive aa6;player==eastman On activation field eastman addaction ["Airstrike","action1.sqs"]; but then when I click Ok to leave the trigger I get the error "Type bool, expected nothing"

 This truly is the last hurdle for my mission. It's ready to release except for the airstrike action showing up for every one within 10 meters of the squad leader.

Share this post


Link to post
Share on other sites

Oh, I didn't quite understand what you were saying exactly with...

Quote[/b] ]"The problem is that you add the action via the init.sqs so every client machine adds the action to the unit thus allowing other players to activate it.

...which is simply not true when you use conditions like every example has used on this thread I think.

Likewise, I didn't understand where'd you come up with...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(local ldr): <addaction to leader unit code>

Share this post


Link to post
Share on other sites

I took the "ldr" from your code as an example... but I should have mentioned it was a representation of the name given to the leader.

I should have probably been alot more thorough in my explanations:

Example:

Place a group and name the leader "Lead1"

In trigger which is meant to add actions place this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(local Lead1):Lead1 addaction ["Airstrike 1","arty1.sqs"]

In your arty1.sqs put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick {[_pos] exec "airstrike.sqs"};

strikePilot sideChat "What do you need bombed?";

hint "On the map left click to select strike location";

_this select 0 removeaction _this select 2

exit

No Loops... no init.sqs needed ... no worries thumbs-up.gif

@Metal

by this:

Quote[/b] ]The problem is that you add the action via the init.sqs so every client machine adds the action to the unit thus allowing other players to activate it.
I was referring to Sputniks post and use of the addaction which I just realized was in the init line of a trigger and not init.sqs... whistle.gif but again is still run "on every client"

Share this post


Link to post
Share on other sites
Quote[/b] ]No Loops... no init.sqs needed ... no worries

Except the possibility of not having access to arty if the leader dies.

Share this post


Link to post
Share on other sites

ok .... then change (local Lead1) to (local leader Lead1) to make sure that whomever is the leader at time trigger is activated gets the action.

If the leader ends up dying, well what happens after that is up to what the mission designer decides, right? Is this a respawning mission? is it one death only? does he even want it to transfer?

oh and regarding your request for scripting reference showing global/local commands:

http://ofp.gamepark.cz/_hosted/hardrock/en/

I haven't heard anything about it for awhile, but I;ve seen it and it is very well done so far and is sorely needed.

Share this post


Link to post
Share on other sites

I shall try this out. so basically I just modify my current trigger by adding...

condition field not alive aa1 and not alive aa2 and not alive aa3 and not alive aa4 and not alive aa5 and not alive aa6;local westman;local eastman;

On activation hint "Both AA sites are neutralized. Air support is now available.";eastman addaction ["Airstrike","action1.sqs"];westman addaction ["Airstrike","action2.sqs"];

and then modify the action1.sqs and action2.sqs by adding in the line _this select 0 removeaction _this select 2 at the end of each script just before exit?

Share this post


Link to post
Share on other sites

thumbs-up.gif

edit: wait a moment... there is one thing wrong

condition field should probably be

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({alive _x} count [aa1,aa2,aa3,aa4,aa5,aa6]==0)

Same as what you had for aa1 through aa6 but shortened - double check that my syntax is right.. it's been awhile since I wrote a line like that. OR you can use what you originally had

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">not alive aa1 and not alive aa2 and not alive aa3 and not alive aa4 and not alive aa5 and not alive aa6

Then in ACTIVATION Field put:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint "Both AA sites are neutralized. Air support is now available.";if (local westman) then westman addaction ["Airstrike 1","arty1.sqs"];if (local eastman) then eastman addaction ["Airstrike 1","arty1.sqs"]

Reason: your first example would have given both of them the actions to both of the units... the alternative is either create two triggers (one for each unit - west or east) OR do the above

Share this post


Link to post
Share on other sites
Quote[/b] ]hint "Both AA sites are neutralized. Air support is now available.";if (local westman) then westman addaction ["Airstrike 1","arty1.sqs"];if (local eastman) then eastman addaction ["Airstrike 1","arty1.sqs"]

  I just tried that out but I receive an error message.

Here's how I put it in the trigger...

Condition not alive aa1 and not alive aa2 and not alive aa3 and not alive aa4 and not alive aa5 and not alive aa6;

On Activation hint "Both AA sites are neutralized. Air support is now available.";if (local westman) then westman addaction ["Airstrike","action1.sqs"];if (local eastman) then eastman addaction ["Airstrike","action2.sqs"];

Share this post


Link to post
Share on other sites

What was the error message?

[edit]...doh

try adding {} around the then statements - i.e. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (local eastman) then {eastman addaction ["Airstrike","action2.sqs"]};

You can totally tell I am just returning to OFP scripting after a loooong hiatus.

Share this post


Link to post
Share on other sites
Quote[/b] ]What was the error message?

[edit]...doh

try adding {} around the then statements - i.e. Code Sample  

if (local eastman) then {eastman addaction ["Airstrike","action2.sqs"]};  

You can totally tell I am just returning to OFP scripting after a loooong hiatus.

 I tried it out that way. Now there are no error messages but when I preview the mission as a different unit and approach westman and eastman (the two squad leaders)I still have the airstrike option pop up.

 Also with it done this way the airstrike stays in the action menu after use and can be used again unlimited times. For some reason the "eastman removeaction 0" line in the airstrike script is no longer working.

Share this post


Link to post
Share on other sites

In preview mode those units are AI and in-fact local to your machine.

In MP, if a player took over one of those units it would work just fine. There IS a benefit to this. Perhaps you want to run single player or just want an AI to control one of the commanders. The host of the game can run up to the leader and trigger the action if needed. This only applies if it is an AI unit. As I said, if it is a player unit, then only that player will see the action.

Quote[/b] ]For some reason the "eastman removeaction 0" line in the airstrike script is no longer working.

putting this code <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_this select 0 removeaction _this select 2 in the arty1.sqs and arty2.sqs as I suggested is sufficient enough to remove the actions

When you use addaction command, you'll notice you cannot send any parameters to script like when using a <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[param1,param2] exec "script.sqs". That is because the action command already declares three of em:

_this select 0 = the object the action was added to

_this select 2 = the actionID of the current action

and in case you are wondering

_this select 1 = the unit that activates the action

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  

×