You can subscribe to the MultiplayerAPI event "OnPlayerDisconnectedFromMatch" like so:
void Start()
{
UFE.MultiplayerAPI.OnPlayerDisconnectedFromMatch += this.OnPlayerDisconnectedFromMatch;
}
Then create a function that calls a set of functions to emulate the end of a match:
void OnPlayerDisconnectedFromMatch()
{
// Declare Local Player as Winner
ControlsScript winner = UFE.GetControlsScript(UFE.GetLocalPlayer());
// Fire Game Ends Event
UFE.FireGameEnds(winner);
// Play Game Won Outro Animation
UFE.GetControlsScript(UFE.GetLocalPlayer()).SetMoveToOutro(2);
// Call for End Game and open menu a few seconds later
UFE.DelaySynchronizedAction(UFE.MatchManager.EndMatch, UFE.config.roundOptions._endGameDelay);
}
On a side note:
You might need to override how UFE handles disconnections. Under file ConnectionHandler.cs, comment line 19 like so:
//UFE.MultiplayerAPI.OnPlayerDisconnectedFromMatch += this.OnPlayerDisconnectedFromMatch;
This will prevent UFE from also disconnecting the local player from the room.
Like UFE? Please rate and review us on the
Asset Store!
Questions about the Forum? Check out our
Karma FAQ.
Don't forget to check our
discord channel.