Change parameter order for consistency

This commit is contained in:
Sardelka 2022-07-04 21:35:01 +08:00
parent a53b514fec
commit 56cd17401b
3 changed files with 14 additions and 14 deletions

View File

@ -251,7 +251,7 @@ namespace RageCoop.Server.Scripting
/// <param name="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 <see cref="SendCustomEvent(int, List{object}, List{Client})"/>.</param> /// <param name="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 <see cref="SendCustomEvent(int, List{object}, List{Client})"/>.</param>
/// <param name="args">See <see cref="CustomEventReceivedArgs"/> for a list of supported types.</param> /// <param name="args">See <see cref="CustomEventReceivedArgs"/> for a list of supported types.</param>
/// <param name="targets">The target clients to send. Leave it null to send to all clients</param> /// <param name="targets">The target clients to send. Leave it null to send to all clients</param>
public void SendCustomEvent(string name, List<Client> targets = null, List<object> args = null) public void SendCustomEvent(List<Client> targets, string name, List<object> args = null)
{ {
targets ??= new(Server.Clients.Values); targets ??= new(Server.Clients.Values);
var p = new Packets.CustomEvent() var p = new Packets.CustomEvent()
@ -271,11 +271,11 @@ namespace RageCoop.Server.Scripting
/// <param name="hash"></param> /// <param name="hash"></param>
/// <param name="args"></param> /// <param name="args"></param>
/// /// <param name="clients">Clients to send, null for all clients</param> /// /// <param name="clients">Clients to send, null for all clients</param>
public void SendNativeCall(GTA.Native.Hash hash, List<Client> clients, List<object> args) public void SendNativeCall(List<Client> clients, GTA.Native.Hash hash, List<object> args)
{ {
var argsList = new List<object>(args); var argsList = new List<object>(args);
argsList.InsertRange(0, new object[] { (byte)TypeCode.Empty, (ulong)hash }); argsList.InsertRange(0, new object[] { (byte)TypeCode.Empty, (ulong)hash });
SendCustomEvent(CustomEvents.NativeCall,clients, argsList); SendCustomEvent(clients, CustomEvents.NativeCall, argsList);
} }
/// <summary> /// <summary>
@ -284,11 +284,11 @@ namespace RageCoop.Server.Scripting
/// <param name="hash"></param> /// <param name="hash"></param>
/// <param name="args"></param> /// <param name="args"></param>
/// /// <param name="clients">Clients to send, null for all clients</param> /// /// <param name="clients">Clients to send, null for all clients</param>
public void SendNativeCall(GTA.Native.Hash hash, List<Client> clients = null, params object[] args) public void SendNativeCall(List<Client> clients , GTA.Native.Hash hash, params object[] args)
{ {
var argsList = new List<object>(args); var argsList = new List<object>(args);
argsList.InsertRange(0, new object[] { (byte)TypeCode.Empty, (ulong)hash }); argsList.InsertRange(0, new object[] { (byte)TypeCode.Empty, (ulong)hash });
SendCustomEvent(CustomEvents.NativeCall, clients, argsList); SendCustomEvent(clients, CustomEvents.NativeCall, argsList);
} }
/// <summary> /// <summary>
@ -297,7 +297,7 @@ namespace RageCoop.Server.Scripting
/// <param name="eventHash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param> /// <param name="eventHash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param>
/// <param name="args">The objects conataing your data, see <see cref="Scripting.CustomEventReceivedArgs.Args"/> for supported types.</param> /// <param name="args">The objects conataing your data, see <see cref="Scripting.CustomEventReceivedArgs.Args"/> for supported types.</param>
/// <param name="targets">The target clients to send. Leave it null to send to all clients</param> /// <param name="targets">The target clients to send. Leave it null to send to all clients</param>
public void SendCustomEvent(int eventHash, List<Client> targets = null, List<object> args=null) public void SendCustomEvent(List<Client> targets , int eventHash, List<object> args=null)
{ {
targets ??= new(Server.Clients.Values); targets ??= new(Server.Clients.Values);
var p = new Packets.CustomEvent() var p = new Packets.CustomEvent()
@ -317,9 +317,9 @@ namespace RageCoop.Server.Scripting
/// <param name="eventHash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param> /// <param name="eventHash">An unique identifier of the event, you can use <see cref="CustomEvents.Hash(string)"/> to get it from a string</param>
/// <param name="args">The objects conataing your data, see <see cref="Scripting.CustomEventReceivedArgs.Args"/> for supported types.</param> /// <param name="args">The objects conataing your data, see <see cref="Scripting.CustomEventReceivedArgs.Args"/> for supported types.</param>
/// <param name="targets">The target clients to send. Leave it null to send to all clients</param> /// <param name="targets">The target clients to send. Leave it null to send to all clients</param>
public void SendCustomEvent(int eventHash, List<Client> targets, params object[] args) public void SendCustomEvent(List<Client> targets, int eventHash, params object[] args)
{ {
SendCustomEvent(eventHash,targets,new List<object>(args)); SendCustomEvent(targets, eventHash,new List<object>(args));
} }
/// <summary> /// <summary>
/// Register an handler to the specifed event hash, one event can have multiple handlers. /// Register an handler to the specifed event hash, one event can have multiple handlers.

View File

@ -41,14 +41,14 @@ namespace RageCoop.Server.Scripting
{ {
foreach(var obj in objects) foreach(var obj in objects)
{ {
API.SendCustomEvent(CustomEvents.ServerPropSync, clients,obj.ID, obj.Model ,obj.Position,obj.Rotation ); API.SendCustomEvent(clients, CustomEvents.ServerPropSync,obj.ID, obj.Model ,obj.Position,obj.Rotation );
} }
} }
public void SendServerBlipsTo(List<ServerBlip> objects, List<Client> clients = null) public void SendServerBlipsTo(List<ServerBlip> objects, List<Client> clients = null)
{ {
foreach (var obj in objects) foreach (var obj in objects)
{ {
API.SendCustomEvent(CustomEvents.ServerBlipSync, clients, obj.ID, (short)obj.Sprite, (byte)obj.Color, obj.Scale,obj.Position,obj.Rotation,obj.Name ); API.SendCustomEvent(clients, CustomEvents.ServerBlipSync, obj.ID, (short)obj.Sprite, (byte)obj.Color, obj.Scale,obj.Position,obj.Rotation,obj.Name );
} }
} }
void NativeResponse(CustomEventReceivedArgs e) void NativeResponse(CustomEventReceivedArgs e)

View File

@ -131,7 +131,7 @@ namespace RageCoop.Server
/// </summary> /// </summary>
public override void Delete() public override void Delete()
{ {
Server.API.SendCustomEvent(CustomEvents.DeleteServerProp, null,ID); Server.API.SendCustomEvent(null,CustomEvents.DeleteServerProp,ID);
Server.API.Entities.RemoveProp(ID); Server.API.Entities.RemoveProp(ID);
} }
@ -141,7 +141,7 @@ namespace RageCoop.Server
public override Vector3 Position public override Vector3 Position
{ {
get { return _pos; } get { return _pos; }
set { _pos=value; Server.API.SendNativeCall(Hash.SET_ENTITY_COORDS_NO_OFFSET, clients:null ,Handle, value.X, value.Y, value.Z, 1, 1, 1); } set { _pos=value; Server.API.SendNativeCall(null, Hash.SET_ENTITY_COORDS_NO_OFFSET, Handle, value.X, value.Y, value.Z, 1, 1, 1); }
} }
/// <summary> /// <summary>
@ -150,7 +150,7 @@ namespace RageCoop.Server
public override Vector3 Rotation public override Vector3 Rotation
{ {
get { return _rot; } get { return _rot; }
set { _rot=value; Server.API.SendNativeCall(Hash.SET_ENTITY_ROTATION,null, Handle, value.X, value.Y, value.Z, 2, 1); } set { _rot=value; Server.API.SendNativeCall(null, Hash.SET_ENTITY_ROTATION, Handle, value.X, value.Y, value.Z, 2, 1); }
} }
@ -299,7 +299,7 @@ namespace RageCoop.Server
/// </summary> /// </summary>
public void Delete() public void Delete()
{ {
Server.API.SendCustomEvent(CustomEvents.DeleteServerBlip, null,ID); Server.API.SendCustomEvent(null, CustomEvents.DeleteServerBlip,ID);
Server.Entities.RemoveServerBlip(ID); Server.Entities.RemoveServerBlip(ID);
} }