Leave Parties #
This topic provides instructions on how to leave parties voluntarily or kick players from 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 the LeaveParty()
or KickPlayerFromParty()
call is made, or if a player is removed automatically, such as when a session is terminated, the Party service removes the target player from the party and invokes the Party Plugin’s onRemovePlayer()
method, which is used to perform any necessary updates to the party state.
override suspend fun onRemovePlayer(
party: Party,
removedPlayer: PartyPlayer,
removalReason: RemovalReason
) {
party.player.forEach {
it.isReady = false
}
}
The removed player will receive a OnLeftParty
notification with the RemovalReason
, which indicates why the player was removed from the party. 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 and errors #
Related events:
- OnPartyUpdated
- OnExtBroadcastPartyChanged
- OnExtPrivatePlayerChanged
- OnPartyPlayersChanged
- OnLeftParty
- OnRemovedFromParty
- OnPlayerLeftParty
Related errors:
- PartyService_NotInParty
- PartyService_PlayerNotLeader
- PartyService_CanNotKickSelf
- PartyService_PlayerNotFound