Oxide for Rust

repository·develop·Indexed 18 days ago

https://github.com/oxidemod/oxide.rust

A modular framework for Rust game servers that enables developers to extend game functionality via plugins. It provides a standardized API for managing players, handling chat and commands, and interacting with the game server, including methods for broadcasting chat messages and executing server console commands.

Tokens
410
Snippets
2
Records
2
Agent score
14%

What's inside oxide.rust

  1. Run server commands via Command()

    develop

    Use the Command method to execute a command directly on the server console. This executes the command with the ConsoleSystem.Option.Server permission level.

    Command(string command, params object[] args)

    • command: The string name of the command to run.
    • args: An array of objects to be passed as arguments to the command.
    // Example: Running a server command to change time
    server.Command("env.time", "12:00");
  2. Broadcast chat messages to all players

    develop

    The Server library provides two Broadcast methods to send chat messages to all connected players on the server. You can send a plain message or a message with a specific prefix (e.g., [PluginName]).

    Both methods support string formatting using Formatter.ToUnity syntax. If args are provided, they will be used to populate the format string.

    • Broadcast(string message, string prefix, ulong userId = 0, params object[] args): Broadcasts a message with a prefix. If args are provided, the message is formatted using those arguments.
    • Broadcast(string message, ulong userId = 0): Broadcasts a plain message without a prefix.
    // Broadcast a simple message to everyone
    server.Broadcast("Hello everyone!");
    
    // Broadcast a formatted message with a prefix
    server.Broadcast("Welcome to the server, {0}!", "[System]", playerId, "PlayerName");