Leave Parties #

This topic provides instructions on how to leave parties voluntarily or kick players from a party.

Leave a party

Leave a party voluntarily #

Voluntarily leave a party

Players can voluntarily leave a party using the Party API LeaveParty() method.

If a leader leaves a party, a random player in the party is made leader.
Player->PartyApi().LeaveParty(
  const FOnCompleteDelegate& FOnCompleteDelegate
);
player.PartyApi.LeaveParty(
  CompleteDelegate onComplete
);
{
  "requestId": 13,
  "type": "PartyRpc.LeaveV1Request",
  "payload": {
  }
}

Kick a player from a party #

Kick a player out of a party

Party leaders can remove players from a party using the Party API KickPlayerFromParty() method.

In the case of multiple leaders, one leader can kick another leader.
Player->PartyApi().KickPlayerFromParty(
  const FString& PlayerId, 
  const FOnCompleteDelegate& OnComplete
);
player.PartyApi.KickPlayerFromParty(
  PragmaId playerToKickId, 
  CompleteDelegate onComplete
  )
{
  "requestId": 14,
  "type": "PartyRpc.KickV1Request",
  "payload": {
    "playerId":"5e359a34-8112-4a84-81d5-87f11f261f77"
  }
}

Handle removed players #

Update parties when players leave

When a player leaves a party, the Party service invokes the Party Plugin’s onRemovePlayer() method, which is used to perform any necessary updates to the party state. In the following example, we set each player’s ready state to false on removal.

override suspend fun onRemovePlayer(
    party: Party,
    removedPlayer: PartyPlayer,
    removalReason: RemovalReason
) {
    party.player.forEach {
        it.isReady = false
    }
}

The removed player will receive the OnLeftParty notification. If the player left involuntarily, they will also receive the OnRemovedFromParty event with the RemovalReason (disconnected, kicked, or expired). The remaining party members receive a notification with the updated party state.

If the removed player is in a party that is in matchmaking, the party will be removed from matchmaking. See Leave matchmaking for more information.

Related events:

Related errors:

  • PartyService_NotInParty
  • PartyService_PlayerNotLeader
  • PartyService_CanNotKickSelf
  • PartyService_PlayerNotFound