Multiplayer Ending Controller

From F2 EN
Jump to navigation Jump to search


For various reasons, it is not always easy to get a mission to end gracefully across all clients and the server - not all players see the correct debriefing (from the briefing.html file). The Multiplayer Ending Controller component allows a desired mission ending to be invoked on the server after the clients – which means all players see the appropriate debriefing.

Required files

All the code associated with this component is found in:

  • init.sqf
  • f\common\f_mpEndSetup.sqf
  • f\common\f_mpEndReceiver.sqf
  • f\server\f_mpEndBroadcast.sqf

How to use

Ending your mission

In your mission, whenever you want the mission to end (such as in a trigger or a script), use the following code (where myEnd is anything you choose, and n is the number of the scenario ending you wish to invoke; possible values are: 1,2,3,4,5,6):

myEnd = [n] execVM "f\server\f_mpEndBroadcast.sqf";

Please note that the above code can be executed on any machine, but it will only cause the component to work (and thereby invoke an ending) if it is also run on the server.

You can put the above code in the On Activation field of a normal trigger, or within a custom script (.sqf file). It is important to note that if you use triggers, you should use the type Switch, and never the type End1 / End2 etc. (because the multiplayer ending controller automatically creates and uses an End trigger).

The component will automatically ensure the desired ending occurs on the clients first, then on the server. Your mission will now end gracefully across all machines, displaying the correct debriefing for all players (make sure your briefing.html file contains text for each ending you plan to use – see the Briefing File Template for more information.

Running custom code at mission end

If you want to make further use of the component to perform clean-up tasks, such as setting objectives to pass/fail, or invoking scripted cut-scenes when the mission ends open the file f\common\f_mpEndReceiver.sqf and look for the code segment entitled:


If you read through this section, you will see spaces marked:

// Ending #1
case 1:
// Place any custom code for ending #1 after this line:

There will be a space for each of the possible endings (1 to 6). Simply insert your ending-specific code in the space provided.


  • Running custom code at mission end is a perfect place to alter the state of tasks.

How to disable

Open the file init.sqf and look for the code segment entitled:

// F2 - Multiplayer Ending Controller

Edit the lines below, adding // to the start:

f_endSelected = -1;
[] execVM "f\common\f_mpEndSetUp.sqf";


  • Headspace
  • Rom
  • Fer