Git Product home page Git Product logo

friends's Introduction

Friends License

Universal friends plugin for the Oxide modding framework.

Features

  • Written in C# with efficiency in mind
  • Configurable to your needs
  • Works for every game Oxide supports with Covalence
  • Can be extended with game-specific logic
  • Exposes an easy to use API to other plugins
  • Aims to be API-compatible with Friends API for Rust
  • Compatible with BattleLink / Rust:IO 3.X
  • Includes configurable friendly fire
  • Includes configurable door and turret sharing for Rust
  • Includes configurable friends broadcast and private chat

Usage

As a player, this is how you use the plugin:

Command Alias Description
/friends Displays your friends list and essential usage instructions
/addfriend name... Adds a player to your friends
/removefriend name... Removes a player from your friends
/fm message... /f Broadcasts a message to all of your friends
/pm "name..." message... /m Sends a private message to the specified player
/rm message... /r Replies to the last message received

You can also use the respective unique player id (i.e. Steam ID) instead of a player's name in case that there are multiple players using the same name.

Also note that /fm and /pm may not be available if the server owner decided so, and if available, be aware that these messages can trivially be logged on the server even if there is no logging mechanism by default.

Configuration

Once installed, the configuration file becomes available at oxide/config/Friends.json. To change your settings, simply edit the file and reload the plugin once afterwards.

Option Default Description
MaxFriends 30 Limits the number of friends a single player can add
DisableFriendlyFire false If true, disables friendly fire for friends if supported by the game
EnableFriendChat false If true, enables friend chat through the /fm command.
LimitFriendChatToMutualFriends true If true, limits friend chat to mutual friends.
EnablePrivateChat false If true, enables private messages through the /pm command.
SendOnlineNotification true If true, sends a chat notification to each friend when a player connects
SendOfflineNotification true If true, sends a chat notification to each friend when a player disconnects
SendAddedNotification true If true, sends a chat notification to the newly added friend
SendRemovedNotification false If true, sends a chat notification to the removed friend

There are additional configuration options for specific games:

Rust

Option Default Description
ShareCodeLocks false If true, allows a player's friends to use their doors
ShareAutoTurrets false If true, prevents auto turrets from targeting a player's friends

API

The API is pretty much straight forward:

Method Description
GetMaxFriends():int Gets the maximum number of friends allowed per player.
GetPlayerName(playerId:object):string Gets player's current or remembered name, by id.
HasFriend(playerId:object, friendId:object):bool Tests if player added friend to their friends list, by id.
AreFriends(playerId:object, friendId:object):bool Tests if player and friend are mutual friends, by id.
AddFriend(playerId:object, friendId:object):bool Adds friend to player's friends list, by id.
RemoveFriend(playerId:object, friendId:object):bool Removes friend from player's friends list, by id.
GetFriends(playerId:object):object Gets a typed array of player's friends, by id.
GetFriendsReverse(playerId:object):object Gets a typed array of players who have added player to their friends list, by id.

Note that all methods take arbitrary player id types (i.e. string, ulong or int), which makes them independent of what the game being modded uses to represent player ids.

GetFriends and GetFriendsReverse in particular return an array of the specified parameter's type (i.e. ulong[] if the parameter was ulong).

Other methods declared within the source file exist for compatibility purposes only and should not be used in new projects.

Additionally, the plugin emits its own hooks:

Hook Description
OnFriendAdded(playerId:string, friendId:string) Called when player adds friend to their friends list, by id.
OnFriendRemoved(playerId:string, friendId:string) Called when player removes friend from their friends list, by id.

Example

[PluginReference]
Plugin Friends;

...
{
    var hasFriend = Friends?.Call<bool>("HasFriend", playerId, friendId) ?? false;
    ...
}

OnFriendAdded(string playerId, string friendId)
{
    ...
}

Contributing

We'll be happy to review your pull request or issue...

  • if you'd like to add support for your native language.
  • if you'd like to contribute game-specific logic for your favorite game.
  • if you have found a bug or require a specific feature.

friends's People

Contributors

danrigby avatar dcodeio avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

chriss-0x01

friends's Issues

/pm and /fm do not work

I've uninstalled the plugin (previously all deleted) re-uploaded. Since then comes this message when someone wants to write / pm NAME TEXT or /fm TEXT

(20:32:23) | [RCON][156.67.136.185:43249] oxide.reload Friends

(20:32:23) | Unloaded plugin Friends v2.5.3 by dcode

(20:32:23) | Loaded plugin Friends v2.5.3 by dcode

(20:32:31) | Failed to call hook 'IOnServerCommand' on plugin 'RustCore v2.0.3528' (FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.)

(20:32:31) | at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in :0

at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in :0

at System.String.Format (System.String format, System.Object[] args) [0x00000] in :0

at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Message (System.String message, System.Object[] args) [0x00000] in :0

at Oxide.Plugins.Friends.cmdPrivateChat (IPlayer player, System.String command, System.String[] args) [0x00000] in :0

at Oxide.Plugins.Friends+c__AnonStorey0.<>m__0 (IPlayer caller, System.String cmd_, System.String[] args) [0x00000] in :0

at Oxide.Game.Rust.Libraries.Covalence.RustCommandSystem.CommandCallback (IPlayer caller, System.String cmd, System.String[] args) [0x00000] in :0

at Oxide.Core.Libraries.Covalence.CommandHandler.HandleCommand (IPlayer player, System.String command, System.String[] args) [0x00000] in :0

at Oxide.Core.Libraries.Covalence.CommandHandler.HandleChatMessage (IPlayer player, System.String message) [0x00000] in :0

at Oxide.Game.Rust.Libraries.Covalence.RustCommandSystem.HandleChatMessage (IPlayer player, System.String message) [0x00000] in :0

at Oxide.Game.Rust.RustCore.IOnServerCommand (.Arg arg) [0x00000] in :0

at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)

at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0

No longer working

now get this error since Rust updated game.
Friends - Failed to compile: Friends.cs(465,72): error CS1503: Argument #2' cannot convert int' expression to type `string'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.