MrBlue
Friends system and API managing friend lists

Supported Games
GameServerKingsGameServerKings

Friends doesn't really do anything itself besides managing a friends list. It offers functions to use by other plugins to do things based on players friends. Other plugins can utilize this plugin to prevent friendly fire, allow access to things for friends, etc.

Commands

This plugin offers both chat and console commands. When using a command chat, prefix with a forward slash: /.

  • friend <add/remove> <player name or id> -- Add or remove a player as a friend
  • friend list -- List all of your current friends

Configuration

{
  "Maximum number of friends per player (0 to disable)": 30,
  "Friend list cache time (0 to disable)": 0
}

Localization

Developer API

To call the functions from this API you'll first need to get the plugin reference:

[PluginReference]
private Plugin Friends;

After you have the plugin reference, just simply call the desired API method:

Friends.Call<bool>("HasFriend", playerId, targetId)

The above example uses the "HasFriend" API method; for others, see below.

API Methods

bool AddFriend(string playerId, string friendId)
bool AddFriend(ulong playerId, ulong friendId)

bool RemoveFriend(string playerId, string friendId)
bool RemoveFriend(ulong playerId, ulong friendId)

bool HasFriend(string playerId, string friendId)
bool HasFriend(ulong playerId, ulong friendId)

bool AreFriends(string playerId, string friendId)
bool AreFriends(ulong playerId, ulong friendId)

bool IsFriend(string playerId, string friendId)
bool IsFriend(ulong playerId, ulong friendId)

string[] GetFriendList(string playerId)
ulong[] GetFriendList(ulong playerId)

string[] IsFriendOf(string playerId)
ulong[] IsFriendOf(ulong playerId)

bool HadFriend(string playerId, string friendId)
bool HadFriend(ulong playerId, ulong friendId)

bool WereFriends(string playerId, string friendId)
bool WereFriends(ulong playerId, ulong friendId)

bool WasFriend(string playerId, string friendId)
bool WasFriend(ulong playerId, ulong friendId)

string[] GetFriends(string playerId)
ulong[] GetFriends(ulong playerId)

int GetMaxFriends()

Hooks

To listen for when a friend is added or removed, use the following hook(s):

private void OnFriendAdded(string playerId, string friendId)
private void OnFriendRemoved(string playerId, string friendId)

Credits

  • Nogrod, for the original version of the Friends API plugin for Rust

MIT License, with distribution exclusivity for uMod.org


Copyright (c) 2020 Wulf


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:


The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.