In this example, we will implement the following features:
-
Add and delete a friend by username from a player’s friends list. The friend does not need to acknowledge that he is being added.
-
Player will be notified when his friends log on and off.
-
Player can see a list of his friends and their current status (i.e., online or offline).
-
Send a message to an online friend regardless of where he is in the game world.
-
Request an online friend’s health and location, regardless of where he is in the game world.
For details on how to implement other variants of friends list, see Variations.
Note
We are placing a fixed limit on the number of friends a player can have, which influences the design.
The limit is defined by the constant MAX_FRIENDS in the base part of Avatar.