Skip to main content

Block a Player

Last updated on

Blocking allows players to restrict other players from interacting with them. When one player blocks another, both players are prevented from:

  • Adding the other as a friend. If the players are already friends, they will be unfriended.
  • Sending or receiving messages to one another.
  • Seeing each other's messages in global chat rooms.
  • Inviting each other to parties.
  • Meeting each other in matches.
  • Being placed in the same party. (Unless they are both invited by a third player. When this occurs, the two blocked players will be able to interact with each other in the party chat.)
  • Inviting each other to join groups.
  • Seeing each other's player profiles in the group members lists.

Blocked players cannot see the profile of the blocking player, and blocked players receive no notification regarding the block. See the tutorials below to implement player blocking using the SDKs.

Block Player Request

Use the following function to block a player.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetBlockPlayerResponseDelegate(AccelByte::Api::Lobby::FBlockPlayerResponse::CreateLambda([](const FAccelByteModelsBlockPlayerResponse& Result)
{
if (Result.Code == "0")
{
// Do something if BlockPlayerResponseDelegate has been successful
}
else
{
// Do something if BlockPlayerResponseDelegate has an error
}
}));

FRegistry::Lobby.BlockPlayer(UserId);

Listen to Player Blocking Events

The game needs to know if a player has been blocked by another player to avoid matching blocked players together and other similar tasks. Blocking events can be tracked by subscribing to the below event. The event will be raised on the blocked player side and will pass data that contains both the blocking player and blocked player's user IDs.

FRegistry::Lobby.Connect();
FRegistry::Lobby.SetBlockPlayerNotifDelegate(AccelByte::Api::Lobby::FBlockPlayerNotif::CreateLambda([](const FAccelByteModelsBlockPlayerNotif& Result)
{
// Do something if BlockPlayerNotifDelegate has been successful
}));