Party Codes
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.
- Unreal Engine
- Unity
FRegistry::Lobby.SetPartyGenerateCodeResponseDelegate(
Api::Lobby::FPartyGenerateCodeResponse::CreateLambda([](FAccelByteModelsPartyGenerateCodeResponse Response)
{
// Handle result.PartyCode here
}));
FRegistry::Lobby.SendPartyGenerateCodeRequest();
AccelBytePlugin.GetLobby().GeneratePartyCode(result =>
{
if (result.IsError)
{
Debug.Log("GeneratePartyCode error");
}
else
{
Debug.Log("GeneratePartyCode success. PartyCode: " + result.Value.partyCode);
}
});
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.
- Unreal Engine
- Unity
FRegistry::Lobby.SetPartyGetCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyGetCodeResponse ::CreateLambda([](FAccelByteModelsPartyGetCodeResponse Response)
{
// Handle result.PartyCode here
}));
FRegistry::Lobby.SendPartyGetCodeRequest();
AccelBytePlugin.GetLobby().GetPartyCode(result =>
{
if (result.IsError)
{
Debug.Log("GetPartyCode error");
}
else
{
Debug.Log("GetPartyCode success. PartyCode: " + result.Value.partyCode);
}
});
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.
- Unreal Engine
- Unity
FRegistry::Lobby.SetPartyDeleteCodeResponseDelegate(
Api::Lobby::FAccelByteModelsPartyDeleteCodeResponse ::CreateLambda([](FAccelByteModelsPartyDeleteCodeResponse Response)
{
// Handle result here
}));
FRegistry::Lobby.SendPartyDeleteCodeRequest();
AccelBytePlugin.GetLobby().DeletePartyCode(result =>
{
if (result.IsError)
{
Debug.Log("DeletePartyCode error");
}
else
{
Debug.Log("DeletePartyCode success");
}
});
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.
- Unreal Engine
- Unity
FRegistry::Lobby.SetPartyJoinViaCodeResponseDelegate(
Api::Lobby::FPartyJoinViaCodeResponse ::CreateLambda([](FPartyJoinViaCodeResponse Response)
{
// Handle result here
}));
FRegistry::Lobby. SendPartyJoinViaCodeRequest(partyCode);
AccelBytePlugin.GetLobby().JoinPartyViaCode(result =>
{
if (result.IsError)
{
Debug.Log("JoinPartyViaCode error");
}
else
{
Debug.Log("JoinPartyViaCode success");
PartyInfo partyInfo = result.Value;
}
});