Use Friend In-Game

In this How-to, we will implement a mutual Friends system in-game using LootLocker. You will learn how to send friend requests, accept or decline them, list your friends and pending requests, and handle blocking relationships. This creates opt-in, two-way connections between players.

Prerequisites

Friends vs Followers

Friends are a two-way relationship requiring mutual consent. Player A sends a friend request to Player B, and they only become friends once B accepts. This powers you to build:

  • Private messaging systems

  • Co-op gameplay invitations

  • Trusted player groups for guilds or parties

  • Mutual achievement sharing and challenges

If you need one-way relationships that don't require approval, use Followers instead (see: Use Followers in Game).

Core Concepts

  • Friends list: Players who have mutually accepted each other's friend requests.

  • Incoming requests: Friend requests sent to the current player by others.

  • Outgoing requests: Friend requests the current player has sent but not yet accepted/declined.

  • Blocked players: Players who cannot send friend requests or interact with the current player.

  • Offset pagination: Lists use page numbers and per-page counts to paginate the data.

Typical UX Flow

  1. Open Social UI → fetch friend counts for header

  2. Browse friends list, incoming requests, or outgoing requests in tabs

  3. Send friend request from player profile → appears in target's incoming list

  4. Accept/decline incoming requests → moves to friends list or disappears

  5. Cancel outgoing requests if changed mind

  6. Block/unblock players to manage harassment

List Friends and Requests

The foundation of any friends system is showing existing relationships and pending requests.

Offset Pagination Strategy

  • Use page numbers (0-indexed) and PerPage count to paginate the data

  • Track current page for each list type separately

  • Consider a page "complete" if returned items equal the requested PerPage

  • Reset to page 0 when refreshing lists

Unlike cursor-based pagination, offset pagination lets you jump to specific pages without knowing the content on them

Send and Cancel Friend Requests

Allow players to initiate and manage outgoing friend requests.

Accept and Decline Friend Requests

Handle incoming friend requests to build your friends network.

Block and Unblock Players

Manage your blocked players list to prevent unwanted interactions.

Check Friendship Status

Determine the current relationship between players for UI state management.

Displaying Counts and Status

Show meaningful counts and relationship indicators in your UI.

Performance Tips

  • Batch relationship checks: When showing many players (leaderboards for example), only fetch data for visible items

  • Cache friend IDs locally: Maintain a set of friend ULIDs for instant button state rendering

  • Moderate page sizes: 20-50 items per page balances responsiveness with network efficiency

  • Debounce rapid requests: Prevent spam-clicking send/cancel buttons

  • Lazy load secondary lists: Load friends first, then incoming/outgoing requests when tabs are opened

Example Feature Ideas

  • Mutual Friends: "You have 3 mutual friends with this player"

  • Friend Recommendations: Suggest friends-of-friends or players with similar interests

  • Private Groups: Create invite-only spaces using your friends list

  • Co-op Quick Join: Join friends' game sessions directly from the friends list

Conclusion

In this How-to we implemented friend requests, list management, acceptance/declining workflows, blocking functionality, and relationship status checking. The friends system provides the foundation for deeper social features like messaging, co-op play, and community building.

Key differences from followers include the mutual consent model, request management workflow, and offset-based pagination. Next, consider adding Followers for asymmetric relationships or explore Web Console management for administrative oversight.

Last updated