Class API
Provides vital functionality to interact with RAGECOOP
Inherited Members
Namespace: RageCoop.Client.Scripting
Assembly: RageCoop.Client.dll
Syntax
public class API
Properties
CurrentVersion
Get the version of RAGECOOP
Declaration
public static Version CurrentVersion { get; }
Property Value
Type | Description |
---|---|
Version |
IsChatFocused
Check if the RAGECOOP chat is visible
Declaration
public static bool IsChatFocused { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsMenuVisible
Check if a RAGECOOP menu is visible
Declaration
public static bool IsMenuVisible { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsOnServer
Check if player is connected to a server
Declaration
public static bool IsOnServer { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsPlayerListVisible
Check if the RAGECOOP list of players is visible
Declaration
public static bool IsPlayerListVisible { get; }
Property Value
Type | Description |
---|---|
Boolean |
LocalPlayerID
Get the local player's ID
Declaration
public static int LocalPlayerID { get; }
Property Value
Type | Description |
---|---|
Int32 | PlayerID |
Logger
Get a Logger that RAGECOOP is currently using.
Declaration
public static Logger Logger { get; }
Property Value
Type | Description |
---|---|
Logger |
ServerEndPoint
Get an IPEndPoint that the player is currently connected to, or null if not connected to the server
Declaration
public static IPEndPoint ServerEndPoint { get; }
Property Value
Type | Description |
---|---|
IPEndPoint |
Methods
Connect(String)
Connect to a server
Declaration
public static void Connect(string address)
Parameters
Type | Name | Description |
---|---|---|
String | address | Address of the server, e.g. 127.0.0.1:4499 |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | When a connection is active or being established |
Disconnect()
Disconnect from current server or cancel the connection attempt.
Declaration
public static void Disconnect()
LocalChatMessage(String, String)
Send a local chat message to this player
Declaration
public static void LocalChatMessage(string from, string message)
Parameters
Type | Name | Description |
---|---|---|
String | from | Name of the sender |
String | message | The player's message |
QueueAction(Action)
Queue an action to be executed on next tick.
Declaration
public static void QueueAction(Action a)
Parameters
Type | Name | Description |
---|---|---|
Action | a |
QueueAction(Func<Boolean>)
Queue an action to be executed on next tick, allowing you to call scripting API from another thread.
Declaration
public static void QueueAction(Func<bool> a)
Parameters
Type | Name | Description |
---|---|---|
Func<Boolean> | a | An Func<T,TResult> to be executed with a return value indicating whether it can be removed after execution. |
RegisterCustomEventHandler(Int32, Action<CustomEventReceivedArgs>)
Register an handler to the specifed event hash, one event can have multiple handlers. This will be invoked from backgound thread, use QueueAction(Action) in the handler to dispatch code to script thread.
Declaration
public static 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. |
RequestSharedFile(String, Action<String>)
Declaration
public static void RequestSharedFile(string name, Action<string> callback)
Parameters
Type | Name | Description |
---|---|---|
String | name | |
Action<String> | callback |
SendCustomEvent(Int32, Object[])
Send an event and data to the server.
Declaration
public static void SendCustomEvent(int eventHash, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Int32 | eventHash | An unique identifier of the event |
Object[] | args | The objects conataing your data, see CustomEventReceivedArgs for a list of supported types |