> For the complete documentation index, see [llms.txt](/llms.txt)


# Connect players

Try profiles, rankings, friends, and guilds with two accounts.



Call your existing player A and create a second player, B. Display their names, compare scores, and connect them through friends and guilds.

## 1. Add profile, ranking, and guild settings


**Studio**

From **Add features**, add **Friends & Profile**, **Rankings**, and **Guilds**. Profiles and friends require no table entries.

Add a row under **Tables → Rankings → Ranking** and enter the following values.

| Field | Value |
| --- | --- |
| ID | `adventure` |
| Sort direction | `desc` (highest score first) |
| Sum scores | Off |
| Minimum score | `0` |
| Maximum score | `1000000` |
| Schedule | Leave empty |

Do not add ranking reward rows. This ranking uses each player's most recently submitted score.

Under **Tables → Guilds → GuildRole**, add the following two rows. Paste the entire linked JSON into each **Permission policy** cell.

| ID | Permission policy |
| --- | --- |
| `master` | <a href="/samples/adventure/en/extensions/guild-master-policy.json" download>Master policy</a>. Allows changing guild settings and approving requests |
| `member` | <a href="/samples/adventure/en/extensions/guild-member-policy.json" download>Member policy</a>. Does not grant guild administration permissions |

Add a row to **Guild** and enter the following values.

| Field | Value |
| --- | --- |
| ID | `adventure` |
| Initial / maximum capacity | Both `10` |
| Rejoin cooldown | `0` |
| Maximum memberships / master roles | Both `1` |
| Master role | `master` |
| Member role | `member` |
| Master inactivity period | Leave empty |

Deploy from **Publish → Calculate server differences**, then click **Update the Unity project**.


**SDK (Unity)**

Download the <a href="/samples/adventure/en/extensions/social.json" download>social features template</a>. In the management console's Tokyo region, open **Deploy → Stack list → Create stack**. Name it `adventure-social`, select the file under **Template data**, and create it.

| Feature | Service / namespace | Settings |
| --- | --- | --- |
| Profiles and friends | Friend / `adventure-friend` | Stores each player's name and friends |
| Ranking | Ranking2 / `adventure-ranking` | `adventure`; highest score first, uses the latest value without summing |
| Guilds | Guild / `adventure-guild` | Type `adventure`; 10 members, one guild per player, no rejoin cooldown |

Your existing adventure and character settings remain available after adding this stack.




### Add the social panel in Unity

Stop Play Mode and uncheck **Adventure Characters** on `Extensions`. Keep the adventure panel on the left.


**Studio**

Place <a href="/samples/adventure/en/extensions/studio/AdventureSocial.cs" download>AdventureSocial.cs</a> in `Assets/AdventureExtensions`, then add **Adventure Social** to `Extensions`. It uses the signed-in `Gs2ClientHolder` and `Gs2GameSessionHolder`.


**SDK (Unity)**

Place <a href="/samples/adventure/en/extensions/sdk/AdventureSocial.cs" download>AdventureSocial.cs</a> in `Assets/AdventureExtensions`, then add **Adventure Social** to `Extensions`. Assign the scene's `AdventureLogin` to **Login**.




Enter Play Mode to see the social panel on the right. Scroll within it to reach the lower buttons.

### Switch between A and B

Click **Copy my ID** on the right and save it in a text editor as player A's ID. Set **Display name** to `Adventurer A` and click **Save my name**.


**Studio**

Stop Play Mode. On the login object, change **PlayerPrefs Account Store → Key Prefix** from `adventure.main` to `adventure.social-b`, then enter Play Mode. The first time, account B is created.

To switch accounts, stop Play Mode, set Key Prefix to `adventure.main` for A or `adventure.social-b` for B, and restart. Logging in with the saved account restores the same player ID.


**SDK (Unity)**

Stop Play Mode, change **Account Slot** on `AdventureLogin` from `main` to `social-b`, then restart and log in. The first time, account B is created.

To switch accounts, stop Play Mode, set Account Slot to `main` for A or `social-b` for B, then restart and log in. The saved account restores the same player ID.




For B, click **Copy my ID** and save the ID. Set the display name to `Adventurer B` and save it. Enter A's ID in **Other player's ID** and click **Read their name**. `Adventurer A` appears.

Switch to A, enter B's ID, and read their name. Seeing B's name confirms that you can look up another player by ID.

Names are stored in Friend's public profile.

```csharp
await Client.Friend.Namespace(FriendNamespace).Me(Session).Profile()
    .UpdateProfileAsync(publicProfile: displayName);

await Client.Friend.Namespace(FriendNamespace).User(targetUserId)
    .PublicProfile().ModelAsync();
```

## 2. Submit scores and compare rankings

This ranking uses the **most recently submitted score**, rather than keeping each player's personal best.

The list shows rank, display name at submission, score, and player ID. Updates can take up to five minutes to appear. If your score is not visible yet, wait a little and click **Read rankings**. Check each result before moving to the next row below.

| Action | Result after reading rankings |
| --- | --- |
| As A, enter `Adventurer A` and score `100`, then click **Submit score** | A has 100 points |
| Switch to B, enter `Adventurer B` and score `200`, then submit | B has 200 points and ranks above A |
| Switch to A, enter `Adventurer A` and score `300`, then submit | A has 300 points and ranks above B |
| Submit `50` as A | A's score becomes 50 and ranks below B |

```csharp
var ranking = Client.Ranking2.Namespace(RankingNamespace)
    .GlobalRankingModel("adventure").GlobalRankingSeason(Session);
await ranking.PutGlobalRankingAsync(value, displayName);
await foreach (var item in ranking.GlobalRankingsAsync())
{
    if (item != null) message += item.Rank + ": " + item.Metadata + " / " + item.Score + "\n";
}
```

The display name is submitted with the score. Changing only the profile name does not change the ranking name. Submit another score with the new display name to update it.

## 3. Send and accept a friend request

1. As A, enter B's ID in the other player field and click **Send friend request**.
2. Click **Read friends**. B is not listed yet because the request has not been accepted.
3. Switch to B, enter A's ID, and click **Accept their request**. A appears in the friend list.
4. Switch to A and read the list. B appears.
5. As A, enter B's ID and click **Remove friend**. B disappears from A's list. Switch to B and read the list again; A has disappeared there too.

Use player IDs to specify both the request recipient and the sender whose request you want to accept.

```csharp
var me = Client.Friend.Namespace(FriendNamespace).Me(Session);
await me.SendRequestAsync(targetUserId);
await me.ReceiveFriendRequest(targetUserId).AcceptAsync();
await foreach (var item in me.FriendsAsync(withProfile: true))
{
    if (item != null) message += item.UserId + " / " + item.PublicProfile + "\n";
}
```

## 4. Join a guild

Switch to A and click **Create an adventurers' guild**. The new guild ID appears in the input field; save it. The member list shows A with the `master` role.

1. Switch to B and enter the saved ID in **Guild ID**.
2. Click **Join or apply to this guild**. Initially the guild allows anyone (`anybody`), so B joins immediately.
3. Click **Read members** to see A and B. B has the `member` role.
4. As B, click **Leave this guild**.
5. Switch to A, enter the same guild ID, and click **Master: Require approval**. The join policy becomes `approval`.
6. Switch to B and click **Join or apply to this guild** again. This time only a request is sent; B is not yet in the member list.
7. Switch to A, enter the guild ID and B's player ID, and click **Master: Approve their request**. B is added to the member list.

Creating and joining guilds uses the signed-in player's session.

```csharp
var me = Client.Guild.Namespace(GuildNamespace).Me(Session);
await me.CreateGuildAsync("adventure", "Adventurers' guild", "anybody");
await me.SendRequestAsync("adventure", guildName);
```

To approve requests or change the join policy, obtain a guild session using A's permissions first. This is implemented in `ManageGuild()` in `AdventureSocial.cs`.

Finish with A selected. In the next chapter, you will send event rewards to this player.

[Next: Run an event]()



