Skip to main content

Party Codes

Last updated on

Party leaders can send party codes to players so that those players can join their party. Only party leaders can use party codes. They can also refresh or revoke a party code.

Create Party and Party Code

When players create a party, partyCode is returned as a response (either as FAccelByteModelsCreatePartyResponse in Unreal Engine, or PartyCreateResponse in Unity.

Generate or Refresh a Party Code

Use the following function to generate or refresh a party code.

FRegistry::Lobby.SetPartyGenerateCodeResponseDelegate(
Api::Lobby::FPartyGenerateCodeResponse::CreateLambda([](FAccelByteModelsPartyGenerateCodeResponse Response)
{
// Handle result.PartyCode here
}));

FRegistry::Lobby.SendPartyGenerateCodeRequest();

Get a Party Code

Once a code is generated, party leaders can get the code and share it from other players. This function allows party leaders to get the party code.

FRegistry::Lobby.SetPartyGetCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyGetCodeResponse ::CreateLambda([](FAccelByteModelsPartyGetCodeResponse Response)
{
// Handle result.PartyCode here
}));
FRegistry::Lobby.SendPartyGetCodeRequest();
tip

TIP If the success response returns an empty party code, you need to call the GeneratePartyCode function to generate a new party code.

Revoke a Party Code

Party leaders can revoke a party code. If a party code is revoked, players will no longer be able to use it to join the party. This function allows party leaders to revoke the party code.

FRegistry::Lobby.SetPartyDeleteCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyDeleteCodeResponse ::CreateLambda([](FAccelByteModelsPartyDeleteCodeResponse Response)
{
// Handle result here
}));
FRegistry::Lobby.SendPartyDeleteCodeRequest();

Join a Party with a Party Code

Players that have been sent a party code can use it to join a party. This function allows players to join a party using a party code.

FRegistry::Lobby.SetPartyJoinViaCodeResponseDelegate(
Api::Lobby::FPartyJoinViaCodeResponse ::CreateLambda([](FPartyJoinViaCodeResponse Response)
{
// Handle result here
}));
FRegistry::Lobby. SendPartyJoinViaCodeRequest(partyCode);