Friend Request System

Comprehensive documentation for the BlinkBox Friend Request Addon

Introduction

The BlinkBox Friend Request system extends the standard MFPS functionality by adding a robust, persistent friend request mechanism. It allows users to send, receive, accept, and decline friend requests, with built-in spam protection and database persistence.

Key Features

Setup & Installation

Prerequisite: This addon requires ULogin System Pro (ULSP) to function, as it relies on the database connection and user authentication.

1. Database Setup

  1. Upload the provided bl_FriendRequest.php file to your web server (same directory as your other MFPS PHP files).
  2. The system will automatically attempt to create the necessary tables (`bl_friend_requests`) on the first run.

2. Unity Setup

  1. Drag the FriendRequests[Panel] prefab into your Lobby scene (usually under the Canvas/UI hierarchy).
  2. Ensure the bl_FriendRequest component is present in your scene (often attached to a manager object or the UI panel itself).
  3. Assign the FriendRequestSettings asset to the bl_FriendRequest component in the Inspector.

Configuration

The system is configured via the FriendRequestSettings ScriptableObject. Create one via Create > BlinkBox > Friend Request > Settings if needed.

Cooldown Settings

Setting Description
Global Cooldown Minimum time (seconds) between sending any friend request.
Per User Cooldown Time (seconds) to wait before sending another request to the same user.
Declined Cooldown Time (seconds) to wait if a user previously declined your request.

Limits & Logs

Core Components

bl_FriendRequest.cs

The central manager (Singleton: bl_FriendRequest.instance). It handles all network logic and state management.

bl_FriendRequestUI.cs

Manages the visual interface.

bl_FriendRequestInfo.cs

Attached to individual list items. Holds data for a specific request.

Integration Note: If PLAYER_PROFILE_INSPECT is enabled, visual elements like avatars and calling cards are delegated to the bl_ProfileDataRenderer component.

UI System

The UI is template-based. You can customize the look of list items by editing the prefabs:

The main panel FriendRequests[Panel] contains the lists and navigation logic.

Integration Guide

How to use the system from your own scripts.

Sending a Request

// Send by Name
bl_FriendRequest.instance.SendFriendRequest("PlayerName123");

// Send by ID (if known)
bl_FriendRequest.instance.SendFriendRequestByID("54");

Listening to Events

You can subscribe to events to react to changes (e.g., play a sound, show a custom notification).

void OnEnable()
{
    if (bl_FriendRequest.instance != null)
    {
        bl_FriendRequest.instance.OnRequestSent += HandleRequestSent;
        bl_FriendRequest.instance.OnRequestAccepted += HandleRequestAccepted;
    }
}

void HandleRequestSent(bool success)
{
    if (success) Debug.Log("Friend request sent successfully!");
}

void HandleRequestAccepted(bool success)
{
    if (success) Debug.Log("New friend added!");
}