Search Results for

    Show / Hide Table of Contents

    Class API

    An class that can be used to interact with RageCoop server.

    Inheritance
    Object
    API
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: RageCoop.Server.Scripting
    Assembly: RageCoop.Server.dll
    Syntax
    public class API

    Fields

    Events

    Server side events

    Declaration
    public readonly APIEvents Events
    Field Value
    Type Description
    APIEvents

    Properties

    Logger

    Get a Logger that the server is currently using, you should use Logger to display resource-specific information.

    Declaration
    public Logger Logger { get; }
    Property Value
    Type Description
    Logger

    Methods

    GetAllClients()

    Get a list of all Clients

    Declaration
    public Dictionary<long, Client> GetAllClients()
    Returns
    Type Description
    Dictionary<Int64, Client>

    All clients as a dictionary indexed by NetID

    GetClientByUsername(String)

    Get the client by its username

    Declaration
    public Client GetClientByUsername(string username)
    Parameters
    Type Name Description
    String username

    The username to search for (non case-sensitive)

    Returns
    Type Description
    Client

    The Client from this user or null

    RegisterCommand(String, Action<CommandContext>)

    Register a new command chat command (Example: "/test")

    Declaration
    public void RegisterCommand(string name, Action<CommandContext> callback)
    Parameters
    Type Name Description
    String name

    The name of the command (Example: "test" for "/test")

    Action<CommandContext> callback

    Create a new function!

    RegisterCommand(String, String, Int16, Action<CommandContext>)

    Send CleanUpWorld to all players to delete all objects created by the server

    Declaration
    public void RegisterCommand(string name, string usage, short argsLength, Action<CommandContext> callback)
    Parameters
    Type Name Description
    String name

    The name of the command (Example: "test" for "/test")

    String usage

    How to use this message (argsLength required!)

    Int16 argsLength

    The length of args (Example: "/message USERNAME MESSAGE" = 2) (usage required!)

    Action<CommandContext> callback

    Create a new function!

    RegisterCommands(Object)

    Register all commands inside an class instance

    Declaration
    public void RegisterCommands(object obj)
    Parameters
    Type Name Description
    Object obj

    The instance of type containing the commands

    RegisterCommands<T>()

    Register all commands in a static class

    Declaration
    public void RegisterCommands<T>()
    Type Parameters
    Name Description
    T

    Your static class with commands

    RegisterCustomEventHandler(Int32, Action<CustomEventReceivedArgs>)

    Register an handler to the specifed event hash, one event can have multiple handlers.

    Declaration
    public void RegisterCustomEventHandler(int hash, Action<CustomEventReceivedArgs> handler)
    Parameters
    Type Name Description
    Int32 hash

    An unique identifier of the event, you can hash your event name with Hash(String)

    Action<CustomEventReceivedArgs> handler

    An handler to be invoked when the event is received from the server. This will be invoked from main thread.

    RegisterCustomEventHandler(String, Action<CustomEventReceivedArgs>)

    Register an event handler for specified event name.

    Declaration
    public void RegisterCustomEventHandler(string name, Action<CustomEventReceivedArgs> handler)
    Parameters
    Type Name Description
    String name

    This value will be hashed to an int to reduce overhead

    Action<CustomEventReceivedArgs> handler

    The handler to be invoked when the event is received

    SendChatMessage(String, List<Client>, String)

    Send a chat message to all players, use SendChatMessage(String, String) to send to an individual client.

    Declaration
    public void SendChatMessage(string message, List<Client> targets = null, string username = "Server")
    Parameters
    Type Name Description
    String message

    The chat message

    List<Client> targets

    The clients to send message, leave it null to send to all clients

    String username

    The username which send this message (default = "Server")

    SendCustomEvent(Int32, List<Object>, List<Client>)

    Send an event and data to the specified clients. Use SendCustomEvent(Int32, List<Object>) if you want to send event to individual client.

    Declaration
    public void SendCustomEvent(int eventHash, List<object> args = null, List<Client> targets = null)
    Parameters
    Type Name Description
    Int32 eventHash

    An unique identifier of the event, you can use Hash(String) to get it from a string

    List<Object> args

    The objects conataing your data, supported types: byte, short, ushort, int, uint, long, ulong, float, bool, string.

    List<Client> targets

    The target clients to send. Leave it null to send to all clients

    SendCustomEvent(String, List<Object>, List<Client>)

    Send an event and data to the specified clients. Use SendCustomEvent(Int32, List<Object>) if you want to send event to individual client.

    Declaration
    public void SendCustomEvent(string name, List<object> args = null, List<Client> targets = null)
    Parameters
    Type Name Description
    String name

    The name of the event, will be hashed to an int. For optimal performence, you should hash it in a static contructor inside the shared library, then call SendCustomEvent(Int32, List<Object>, List<Client>).

    List<Object> args

    The objects conataing your data, supported types: byte, short, ushort, int, uint, long, ulong, float, bool, string.

    List<Client> targets

    The target clients to send. Leave it null to send to all clients

    In This Article
    Back to top Generated by DocFX