Updated documentation. Small changes
This commit is contained in:
@ -108,7 +108,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ?
|
/// Check if the player is already on a server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsOnServer()
|
public static bool IsOnServer()
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the local net handle from this Lidgren network client when connected to a server
|
/// Get the local net handle from this Lidgren-Network client when connected to a server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>long</returns>
|
/// <returns>long</returns>
|
||||||
public static long GetLocalNetHandle()
|
public static long GetLocalNetHandle()
|
||||||
@ -129,7 +129,6 @@ namespace CoopClient
|
|||||||
/// Key = Lidgren-Network net handle
|
/// Key = Lidgren-Network net handle
|
||||||
/// Value = Character handle or null
|
/// Value = Character handle or null
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary(long, int)</returns>
|
|
||||||
public static Dictionary<long, int?> GetAllPlayers()
|
public static Dictionary<long, int?> GetAllPlayers()
|
||||||
{
|
{
|
||||||
Dictionary<long, int?> result = new Dictionary<long, int?>();
|
Dictionary<long, int?> result = new Dictionary<long, int?>();
|
||||||
@ -147,7 +146,6 @@ namespace CoopClient
|
|||||||
/// Get a player using their Lidgren Network net handle
|
/// Get a player using their Lidgren Network net handle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="handle">Lidgren-Network net handle</param>
|
/// <param name="handle">Lidgren-Network net handle</param>
|
||||||
/// <returns>Entities.EntitiesPlayer</returns>
|
|
||||||
public static Entities.EntitiesPlayer GetPlayer(long handle)
|
public static Entities.EntitiesPlayer GetPlayer(long handle)
|
||||||
{
|
{
|
||||||
lock (Main.Players)
|
lock (Main.Players)
|
||||||
@ -157,7 +155,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ?
|
/// Check if a GTACOOP:R menu is visible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsMenuVisible()
|
public static bool IsMenuVisible()
|
||||||
{
|
{
|
||||||
@ -169,7 +167,7 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check the chat is visible
|
/// Check if the GTACOOP:R chat is visible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsChatFocused()
|
public static bool IsChatFocused()
|
||||||
{
|
{
|
||||||
@ -177,9 +175,8 @@ namespace CoopClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check the list of players is visible
|
/// Check if the GTACOOP:R list of players is visible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>bool</returns>
|
|
||||||
public static bool IsPlayerListVisible()
|
public static bool IsPlayerListVisible()
|
||||||
{
|
{
|
||||||
return Util.GetTickCount64() - PlayerList.Pressed < 5000;
|
return Util.GetTickCount64() - PlayerList.Pressed < 5000;
|
||||||
@ -188,7 +185,6 @@ namespace CoopClient
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the version of GTACOOP:R
|
/// Get the version of GTACOOP:R
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string</returns>
|
|
||||||
public static string GetCurrentVersion()
|
public static string GetCurrentVersion()
|
||||||
{
|
{
|
||||||
return Main.CurrentVersion;
|
return Main.CurrentVersion;
|
||||||
@ -231,7 +227,6 @@ namespace CoopClient
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get that player's local username
|
/// Get that player's local username
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string</returns>
|
|
||||||
public static string GetUsername()
|
public static string GetUsername()
|
||||||
{
|
{
|
||||||
return Main.MainSettings.Username;
|
return Main.MainSettings.Username;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<AssemblyVersion>1.8.0.0001</AssemblyVersion>
|
<AssemblyVersion>1.9.1.0001</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.0</FileVersion>
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
|
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -140,15 +140,45 @@ namespace CoopServer
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EVENTS
|
#region EVENTS
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the server has started
|
||||||
|
/// </summary>
|
||||||
public event EmptyEvent OnStart;
|
public event EmptyEvent OnStart;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the server has stopped
|
||||||
|
/// </summary>
|
||||||
public event EmptyEvent OnStop;
|
public event EmptyEvent OnStop;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the server receives a new chat message for players
|
||||||
|
/// </summary>
|
||||||
public event ChatEvent OnChatMessage;
|
public event ChatEvent OnChatMessage;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the server receives a new incoming connection
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerHandshake;
|
public event PlayerEvent OnPlayerHandshake;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a new player has successfully connected
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerConnected;
|
public event PlayerEvent OnPlayerConnected;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a new player has successfully disconnected
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerDisconnected;
|
public event PlayerEvent OnPlayerDisconnected;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a new player sends data like health
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerUpdate;
|
public event PlayerEvent OnPlayerUpdate;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a player has a new health value
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerHealthUpdate;
|
public event PlayerEvent OnPlayerHealthUpdate;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a player has a new position
|
||||||
|
/// </summary>
|
||||||
public event PlayerEvent OnPlayerPositionUpdate;
|
public event PlayerEvent OnPlayerPositionUpdate;
|
||||||
|
/// <summary>
|
||||||
|
/// Called when a player sends a packet from another modification
|
||||||
|
/// </summary>
|
||||||
public event ModEvent OnModPacketReceived;
|
public event ModEvent OnModPacketReceived;
|
||||||
|
|
||||||
internal void InvokeStart()
|
internal void InvokeStart()
|
||||||
@ -207,19 +237,21 @@ namespace CoopServer
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region FUNCTIONS
|
#region FUNCTIONS
|
||||||
|
/// <summary>
|
||||||
|
/// Send a mod packet to all players
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mod">The name of the modification that will receive the data</param>
|
||||||
|
/// <param name="customID">The ID to check what this data is</param>
|
||||||
|
/// <param name="bytes">The serialized data</param>
|
||||||
|
/// <param name="netHandleList">The list of connections (players) that will receive the data</param>
|
||||||
public static void SendModPacketToAll(string mod, byte customID, byte[] bytes, List<long> netHandleList = null)
|
public static void SendModPacketToAll(string mod, byte customID, byte[] bytes, List<long> netHandleList = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<NetConnection> connections;
|
List<NetConnection> connections = netHandleList == null
|
||||||
if (netHandleList == null)
|
? Server.MainNetServer.Connections
|
||||||
{
|
: Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
||||||
connections = Server.MainNetServer.Connections;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connections = Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
|
||||||
}
|
|
||||||
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
||||||
new ModPacket()
|
new ModPacket()
|
||||||
{
|
{
|
||||||
@ -238,6 +270,11 @@ namespace CoopServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a native call (Function.Call) to all players
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hash">The hash (Example: 0x25223CA6B4D20B7F = GET_CLOCK_HOURS)</param>
|
||||||
|
/// <param name="args">The arguments (Example: "Function.Call(Hash.SET_TIME_SCALE, args);")</param>
|
||||||
public static void SendNativeCallToAll(ulong hash, params object[] args)
|
public static void SendNativeCallToAll(ulong hash, params object[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -270,6 +307,10 @@ namespace CoopServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get all connections as a list of NetHandle(long)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public static List<long> GetAllConnections()
|
public static List<long> GetAllConnections()
|
||||||
{
|
{
|
||||||
List<long> result = new();
|
List<long> result = new();
|
||||||
@ -294,6 +335,12 @@ namespace CoopServer
|
|||||||
return Server.Clients.Find(x => x.Player.Username.ToLower() == username.ToLower());
|
return Server.Clients.Find(x => x.Player.Username.ToLower() == username.ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a chat message to all players
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">The chat message</param>
|
||||||
|
/// <param name="username">The username which send this message (default = "Server")</param>
|
||||||
|
/// <param name="netHandleList">The list of connections (players) who received this chat message</param>
|
||||||
public static void SendChatMessageToAll(string message, string username = "Server", List<long> netHandleList = null)
|
public static void SendChatMessageToAll(string message, string username = "Server", List<long> netHandleList = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -303,15 +350,10 @@ namespace CoopServer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<NetConnection> connections;
|
List<NetConnection> connections = netHandleList == null
|
||||||
if (netHandleList == null)
|
? Server.MainNetServer.Connections
|
||||||
{
|
: Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
||||||
connections = Server.MainNetServer.Connections;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connections = Server.MainNetServer.Connections.FindAll(c => netHandleList.Contains(c.RemoteUniqueIdentifier));
|
|
||||||
}
|
|
||||||
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
|
||||||
new ChatMessagePacket()
|
new ChatMessagePacket()
|
||||||
{
|
{
|
||||||
@ -326,15 +368,31 @@ namespace CoopServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register a new command chat command (Example: "/test")
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the command (Example: "test" for "/test")</param>
|
||||||
|
/// <param name="usage">How to use this message (argsLength required!)</param>
|
||||||
|
/// <param name="argsLength">The length of args (Example: "/message USERNAME MESSAGE" = 2) (usage required!)</param>
|
||||||
|
/// <param name="callback">Create a new function!</param>
|
||||||
public static void RegisterCommand(string name, string usage, short argsLength, Action<CommandContext> callback)
|
public static void RegisterCommand(string name, string usage, short argsLength, Action<CommandContext> callback)
|
||||||
{
|
{
|
||||||
Server.RegisterCommand(name, usage, argsLength, callback);
|
Server.RegisterCommand(name, usage, argsLength, callback);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Register a new command chat command (Example: "/test")
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the command (Example: "test" for "/test")</param>
|
||||||
|
/// <param name="callback">Create a new function!</param>
|
||||||
public static void RegisterCommand(string name, Action<CommandContext> callback)
|
public static void RegisterCommand(string name, Action<CommandContext> callback)
|
||||||
{
|
{
|
||||||
Server.RegisterCommand(name, callback);
|
Server.RegisterCommand(name, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Register a class of commands
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The name of your class with functions</typeparam>
|
||||||
public static void RegisterCommands<T>()
|
public static void RegisterCommands<T>()
|
||||||
{
|
{
|
||||||
Server.RegisterCommands<T>();
|
Server.RegisterCommands<T>();
|
||||||
@ -350,8 +408,14 @@ namespace CoopServer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the Usage (Example: "Please use "/help"". ArgsLength required!)
|
||||||
|
/// </summary>
|
||||||
public string Usage { get; set; }
|
public string Usage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the length of arguments (Example: 2 for "/message USERNAME MESSAGE". Usage required!)
|
||||||
|
/// </summary>
|
||||||
public short ArgsLength { get; set; }
|
public short ArgsLength { get; set; }
|
||||||
|
|
||||||
public Command(string name)
|
public Command(string name)
|
||||||
@ -368,7 +432,7 @@ namespace CoopServer
|
|||||||
public Client Client { get; internal set; }
|
public Client Client { get; internal set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the chatdata associated with the command
|
/// Gets the arguments (Example: "/message USERNAME MESSAGE", Args[0] for USERNAME)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Args { get; internal set; }
|
public string[] Args { get; internal set; }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user