Unblock a Player
Last updated on
Use the following function to unblock a player
- Unreal Engine
- Unity
FString UserId = FString("SomeUserId");
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetUnblockPlayerResponseDelegate(AccelByte::Api::Lobby::FUnblockPlayerResponse::CreateLambda([](const FAccelByteModelsUnblockPlayerResponse& Result)
{
if (Result.Code == "0")
{
// Do something if UnblockPlayerResponseDelegate has been successful
}
else
{
// Do something if UnblockPlayerResponseDelegate has an error
}
}));
FRegistry::Lobby.UnblockPlayer(UserId);
string userId = "SomeUserId";
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().UnblockPlayer(userid, result =>
{
if (result.IsError)
{
// Do something if UnblockPlayer has an error
Debug.Log($"Error UnblockPlayer, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UnblockPlayer has been successful
}
});
Listen to Player Unblocked Events
Just like the Player Blocked Event, this event will be raised on the unblock player's side and will pass data that contains both the unblocking player and unblocked player's User IDs.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetUnblockPlayerNotifDelegate(AccelByte::Api::Lobby::FUnblockPlayerNotif::CreateLambda([](const FAccelByteModelsUnblockPlayerNotif& Result)
{
// Do something if UnblockPlayerNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().PlayerUnblockedNotif += result =>
{
if (result.IsError)
{
// Do something if PlayerUnblockedNotif has an error
Debug.Log($"Error PlayerUnblockedNotif, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if PlayerUnblockedNotif has been successful
}
};