diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ff8a99de0..885ad9509 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,7 +1,7 @@ -* @fabianterhorst +* @fabianterhorst @doxoh /docs/ @lhoerion !/docs/*.md @lhoerion !/docs/*.yml @lhoerion /docs/filterConfig.yml @lhoerion -/api/AltV.Net.Async.CodeGen/ @zziger -/api/AltV.Net.Client/ @zziger @juztim +/api/AltV.Net.Async.CodeGen/ @zziger @doxoh +/api/AltV.Net.Client/ @zziger @juztim @doxoh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7ca8d6dc..b25684ac3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -264,7 +264,7 @@ jobs: echo "branch=${build_info%%/*}" >> $GITHUB_OUTPUT echo "version=${build_info##*/}" >> $GITHUB_OUTPUT echo "sdk_commit=$(cat ./modules/sdk_version.txt)" >> $GITHUB_OUTPUT - - run: npm i @altmp/upload-tool@latest + - run: npm i @altmp/upload-tool@latest fast-xml-parser@4.3.6 - run: npx alt-upload linux coreclr-module/$BRANCH/x64_linux $VERSION $SDK_VERSION working-directory: ./modules env: diff --git a/api/AltV.Net.Async.CodeGen/AltV.Net.Async.CodeGen.csproj b/api/AltV.Net.Async.CodeGen/AltV.Net.Async.CodeGen.csproj index b46b90929..60cb6bb05 100644 --- a/api/AltV.Net.Async.CodeGen/AltV.Net.Async.CodeGen.csproj +++ b/api/AltV.Net.Async.CodeGen/AltV.Net.Async.CodeGen.csproj @@ -7,8 +7,8 @@ AltMp AltV .NET Core Async CodeGen AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge 1.0.0 diff --git a/api/AltV.Net.Async/AltAsync.RegisterEvents.cs b/api/AltV.Net.Async/AltAsync.RegisterEvents.cs index 6dabcf8ce..2161f1cf2 100644 --- a/api/AltV.Net.Async/AltAsync.RegisterEvents.cs +++ b/api/AltV.Net.Async/AltAsync.RegisterEvents.cs @@ -25,6 +25,32 @@ public static void RegisterEvents(object target) ScriptFunction scriptFunction; switch (scriptEventType) { + case ScriptEventType.BaseObjectCreate: + { + scriptFunction = ScriptFunction.Create(eventMethodDelegate, + new[] { typeof(IBaseObject) }, isAsync: true); + if (scriptFunction == null) return; + OnBaseObjectCreate += (baseObject) => + { + var currScriptFunction = scriptFunction.Clone(); + currScriptFunction.Set(baseObject); + return currScriptFunction.CallAsync(); + }; + break; + } + case ScriptEventType.BaseObjectRemove: + { + scriptFunction = ScriptFunction.Create(eventMethodDelegate, + new[] { typeof(IBaseObject) }, isAsync: true); + if (scriptFunction == null) return; + OnBaseObjectRemove += (baseObject) => + { + var currScriptFunction = scriptFunction.Clone(); + currScriptFunction.Set(baseObject); + return currScriptFunction.CallAsync(); + }; + break; + } case ScriptEventType.Checkpoint: { scriptFunction = ScriptFunction.Create(eventMethodDelegate, diff --git a/api/AltV.Net.Async/AltAsync.cs b/api/AltV.Net.Async/AltAsync.cs index 751e45134..0307aa584 100644 --- a/api/AltV.Net.Async/AltAsync.cs +++ b/api/AltV.Net.Async/AltAsync.cs @@ -23,6 +23,18 @@ public static event CheckpointAsyncDelegate OnCheckpoint remove => Core.CheckpointAsyncEventHandler.Remove(value); } + public static event BaseObjectCreateAsyncDelegate OnBaseObjectCreate + { + add => Core.BaseObjectCreateAsyncEventHandler.Add(value); + remove => Core.BaseObjectCreateAsyncEventHandler.Remove(value); + } + + public static event BaseObjectRemoveAsyncDelegate OnBaseObjectRemove + { + add => Core.BaseObjectRemoveAsyncEventHandler.Add(value); + remove => Core.BaseObjectRemoveAsyncEventHandler.Remove(value); + } + public static event PlayerConnectAsyncDelegate OnPlayerConnect { add => Core.PlayerConnectAsyncEventHandler.Add(value); diff --git a/api/AltV.Net.Async/AltV.Net.Async.csproj b/api/AltV.Net.Async/AltV.Net.Async.csproj index 6c8ea6c3d..fab578d0f 100644 --- a/api/AltV.Net.Async/AltV.Net.Async.csproj +++ b/api/AltV.Net.Async/AltV.Net.Async.csproj @@ -8,8 +8,8 @@ AltMp AltV .NET Core Async Server Api AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge 1.0.0 diff --git a/api/AltV.Net.Async/AsyncCore.cs b/api/AltV.Net.Async/AsyncCore.cs index 84305b97c..2dbacf858 100644 --- a/api/AltV.Net.Async/AsyncCore.cs +++ b/api/AltV.Net.Async/AsyncCore.cs @@ -81,6 +81,12 @@ internal readonly AsyncEventHandler internal readonly AsyncEventHandler PlayerDisconnectAsyncEventHandler = new(EventType.PLAYER_DISCONNECT); + internal readonly AsyncEventHandler BaseObjectCreateAsyncEventHandler = + new(); + + internal readonly AsyncEventHandler BaseObjectRemoveAsyncEventHandler = + new(); + internal readonly AsyncEventHandler PlayerRemoveAsyncEventHandler = new(); @@ -357,6 +363,27 @@ await PlayerDisconnectAsyncEventHandler.CallAsync(@delegate => ); } + public override void OnCreateBaseObjectEvent(IBaseObject baseObject) + { + base.OnCreateBaseObjectEvent(baseObject); + if (!BaseObjectCreateAsyncEventHandler.HasEvents()) return; + Task.Run(async () => + { + await BaseObjectCreateAsyncEventHandler.CallAsync(@delegate => + @delegate(baseObject)); + }); + } + public override void OnRemoveBaseObjectEvent(IBaseObject baseObject) + { + base.OnRemoveBaseObjectEvent(baseObject); + if (!BaseObjectRemoveAsyncEventHandler.HasEvents()) return; + Task.Run(async () => + { + await BaseObjectRemoveAsyncEventHandler.CallAsync(@delegate => + @delegate(baseObject)); + }); + } + public override void OnPlayerRemoveEvent(IPlayer player) { base.OnPlayerRemoveEvent(player); @@ -968,13 +995,13 @@ public override void OnPlayerStopTalkingEvent(IPlayer player) }); } - public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async) + public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, object[] objects, ushort answerId, bool async) { if (!UnansweredServerRpcRequest.Contains(answerId)) { UnansweredServerRpcRequest.Add(answerId); } - base.OnScriptRPCEvent(eventpointer, target, name, args, answerId, true); + base.OnScriptRPCEvent(eventpointer, target, name, objects, answerId, true); if (UnansweredServerRpcRequest.Contains(answerId)) { @@ -985,13 +1012,15 @@ public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, strin } if (!ScriptRpcAsyncEventHandler.HasEvents()) return; - Task.Run(async () => + + var task = Task.Run(async () => { - var mValues = MValueConst.CreateFrom(this, args); var clientScriptRPCEvent = new AsyncScriptRpcEvent(target, answerId); - await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, mValues.Select(x => x.ToObject()).ToArray(), answerId)); + await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, objects, answerId)); }); + Task.WaitAll(task); + if (UnansweredServerRpcRequest.Contains(answerId)) { target.EmitRPCAnswer(answerId, null, "Answer not handled"); diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs b/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs index ee7f35725..2e7d20925 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; diff --git a/api/AltV.Net.Async/Events/Events.cs b/api/AltV.Net.Async/Events/Events.cs index 6314681ac..6aa2a772d 100644 --- a/api/AltV.Net.Async/Events/Events.cs +++ b/api/AltV.Net.Async/Events/Events.cs @@ -28,6 +28,8 @@ public delegate Task PlayerHealAsyncDelegate(IPlayer target, ushort oldHealth, u public delegate Task PlayerDisconnectAsyncDelegate(IPlayer player, string reason); + public delegate Task BaseObjectCreateAsyncDelegate(IBaseObject baseObject); + public delegate Task BaseObjectRemoveAsyncDelegate(IBaseObject baseObject); public delegate Task PlayerRemoveAsyncDelegate(IPlayer player); public delegate Task VehicleRemoveAsyncDelegate(IVehicle vehicle); diff --git a/api/AltV.Net.CApi.Generator/TypeRegistry.cs b/api/AltV.Net.CApi.Generator/TypeRegistry.cs index e4f1778f1..97570fdd1 100644 --- a/api/AltV.Net.CApi.Generator/TypeRegistry.cs +++ b/api/AltV.Net.CApi.Generator/TypeRegistry.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace AltV.Net.CApi.Generator; diff --git a/api/AltV.Net.CApi/AltV.Net.CApi.csproj b/api/AltV.Net.CApi/AltV.Net.CApi.csproj index 095f88359..b59a47e5c 100644 --- a/api/AltV.Net.CApi/AltV.Net.CApi.csproj +++ b/api/AltV.Net.CApi/AltV.Net.CApi.csproj @@ -1,11 +1,11 @@ - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET CApi - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav colshape 1.0.0 diff --git a/api/AltV.Net.CApi/Data/Position.cs b/api/AltV.Net.CApi/Data/Position.cs index afc7e0bca..13f9ce3d4 100644 --- a/api/AltV.Net.CApi/Data/Position.cs +++ b/api/AltV.Net.CApi/Data/Position.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.Numerics; using System.Runtime.InteropServices; using System.Runtime.Serialization; @@ -105,6 +106,11 @@ public float Distance(Position b) return MathF.Sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ); } + public Position ToRadians() + { + return new Position((X * MathF.PI) / 180, (Y * MathF.PI) / 180, (Z * MathF.PI) / 180); + } + public static Position operator +(Position a, Position b) => new Position(a.X + b.X, a.Y + b.Y, a.Z + b.Z); public static Position operator -(Position a, Position b) => new Position(a.X - b.X, a.Y - b.Y, a.Z - b.Z); diff --git a/api/AltV.Net.CApi/Data/Rotation.cs b/api/AltV.Net.CApi/Data/Rotation.cs index e8218d1d9..2a26fea9e 100644 --- a/api/AltV.Net.CApi/Data/Rotation.cs +++ b/api/AltV.Net.CApi/Data/Rotation.cs @@ -72,6 +72,11 @@ public bool Equals(Rotation other) return Roll.Equals(other.Roll) && Pitch.Equals(other.Pitch) && Yaw.Equals(other.Yaw); } + public Rotation ToRadians() + { + return new Rotation((Roll * MathF.PI) / 180, (Pitch * MathF.PI) / 180, (Yaw * MathF.PI) / 180); + } + public override int GetHashCode() => HashCode.Combine(Roll.GetHashCode(), Pitch.GetHashCode(), Yaw.GetHashCode()); } } \ No newline at end of file diff --git a/api/AltV.Net.CApi/Events/ClientEvents.cs b/api/AltV.Net.CApi/Events/ClientEvents.cs index 8d634d5df..e4c8822aa 100644 --- a/api/AltV.Net.CApi/Events/ClientEvents.cs +++ b/api/AltV.Net.CApi/Events/ClientEvents.cs @@ -17,16 +17,16 @@ namespace AltV.Net.CApi.ClientEvents public delegate void PlayerSpawnModuleDelegate(); public delegate void PlayerDisconnectModuleDelegate(); - public delegate void PlayerEnterVehicleModuleDelegate(IntPtr pointer, byte seat); - public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr pointer, byte seat); - public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, byte oldSeat, byte newSeat); - public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, uint oldDict, uint newDict, uint oldName, uint newName); - public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, uint oldIntLoc, uint newIntLoc); + public delegate void PlayerEnterVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat); + public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat); + public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat, byte newSeat); + public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName); + public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc, uint newIntLoc); public delegate void PlayerWeaponShootModuleDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip); public delegate void PlayerWeaponChangeModuleDelegate(uint oldWeapon, uint newWeapon); - public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, byte type); - public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, byte type); + public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, BaseObjectType type); + public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, BaseObjectType type); public delegate void AnyResourceErrorModuleDelegate(string name); public delegate void AnyResourceStartModuleDelegate(string name); @@ -78,8 +78,8 @@ public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr tar public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, IntPtr damagerPointer, BaseObjectType damagerType, uint weaponHash); - public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, IntPtr player, byte seat); - public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, IntPtr player, byte seat); + public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat); + public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat); public delegate void PlayerBulletHitModuleDelegate(uint weapon, IntPtr victimPointer, BaseObjectType victimType, Position pos); diff --git a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs index 87282b950..9a00ddeda 100644 --- a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs @@ -902,7 +902,7 @@ public unsafe interface IClientLibrary public unsafe class ClientLibrary : IClientLibrary { - public readonly uint Methods = 1770; + public readonly uint Methods = 1773; public delegate* unmanaged[Cdecl] Audio_AddOutput { get; } public delegate* unmanaged[Cdecl] Audio_GetBaseObject { get; } public delegate* unmanaged[Cdecl] Audio_GetCurrentTime { get; } @@ -3573,7 +3573,7 @@ private IntPtr GetUnmanagedPtr(IDictionary funcTable, ulong ha public ClientLibrary(Dictionary funcTable) { if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true; - else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 78812385462098472UL) Outdated = true; Audio_AddOutput = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9914412815391408844UL, Audio_AddOutputFallback); Audio_GetBaseObject = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback); Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback); diff --git a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs index 40111dcaa..80b124f92 100644 --- a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs @@ -143,10 +143,13 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] Entity_SetStreamSyncedMetaData { get; } public delegate* unmanaged[Cdecl] Entity_SetVisible { get; } public delegate* unmanaged[Cdecl] Event_WeaponDamageEvent_SetDamageValue { get; } + public delegate* unmanaged[Cdecl] Metric_Add { get; } public delegate* unmanaged[Cdecl] Metric_Begin { get; } public delegate* unmanaged[Cdecl] Metric_End { get; } + public delegate* unmanaged[Cdecl] Metric_End2 { get; } public delegate* unmanaged[Cdecl] Metric_GetName { get; } public delegate* unmanaged[Cdecl] Metric_GetValue { get; } + public delegate* unmanaged[Cdecl] Metric_Inc { get; } public delegate* unmanaged[Cdecl] Metric_SetValue { get; } public delegate* unmanaged[Cdecl] Object_ActivatePhysics { get; } public delegate* unmanaged[Cdecl] Object_PlaceOnGroundProperly { get; } @@ -485,7 +488,7 @@ public unsafe interface IServerLibrary public unsafe class ServerLibrary : IServerLibrary { - public readonly uint Methods = 1770; + public readonly uint Methods = 1773; public delegate* unmanaged[Cdecl] BaseObject_DeleteSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetMultipleSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetSyncedMetaData { get; } @@ -618,10 +621,13 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] Entity_SetStreamSyncedMetaData { get; } public delegate* unmanaged[Cdecl] Entity_SetVisible { get; } public delegate* unmanaged[Cdecl] Event_WeaponDamageEvent_SetDamageValue { get; } + public delegate* unmanaged[Cdecl] Metric_Add { get; } public delegate* unmanaged[Cdecl] Metric_Begin { get; } public delegate* unmanaged[Cdecl] Metric_End { get; } + public delegate* unmanaged[Cdecl] Metric_End2 { get; } public delegate* unmanaged[Cdecl] Metric_GetName { get; } public delegate* unmanaged[Cdecl] Metric_GetValue { get; } + public delegate* unmanaged[Cdecl] Metric_Inc { get; } public delegate* unmanaged[Cdecl] Metric_SetValue { get; } public delegate* unmanaged[Cdecl] Object_ActivatePhysics { get; } public delegate* unmanaged[Cdecl] Object_PlaceOnGroundProperly { get; } @@ -1220,14 +1226,20 @@ public unsafe class ServerLibrary : IServerLibrary private static void Entity_SetVisibleFallback(nint _entity, byte _state) => throw new Exceptions.OutdatedSdkException("Entity_SetVisible", "Entity_SetVisible SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_WeaponDamageEvent_SetDamageValueDelegate(nint _event, uint _damageValue); private static void Event_WeaponDamageEvent_SetDamageValueFallback(nint _event, uint _damageValue) => throw new Exceptions.OutdatedSdkException("Event_WeaponDamageEvent_SetDamageValue", "Event_WeaponDamageEvent_SetDamageValue SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_AddDelegate(nint _metric, ulong _value); + private static void Metric_AddFallback(nint _metric, ulong _value) => throw new Exceptions.OutdatedSdkException("Metric_Add", "Metric_Add SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_BeginDelegate(nint _metric); private static void Metric_BeginFallback(nint _metric) => throw new Exceptions.OutdatedSdkException("Metric_Begin", "Metric_Begin SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_EndDelegate(nint _metric); private static void Metric_EndFallback(nint _metric) => throw new Exceptions.OutdatedSdkException("Metric_End", "Metric_End SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_End2Delegate(nint _metric); + private static void Metric_End2Fallback(nint _metric) => throw new Exceptions.OutdatedSdkException("Metric_End2", "Metric_End2 SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Metric_GetNameDelegate(nint _metric, int* _size); private static nint Metric_GetNameFallback(nint _metric, int* _size) => throw new Exceptions.OutdatedSdkException("Metric_GetName", "Metric_GetName SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Metric_GetValueDelegate(nint _metric); private static ulong Metric_GetValueFallback(nint _metric) => throw new Exceptions.OutdatedSdkException("Metric_GetValue", "Metric_GetValue SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_IncDelegate(nint _metric); + private static void Metric_IncFallback(nint _metric) => throw new Exceptions.OutdatedSdkException("Metric_Inc", "Metric_Inc SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Metric_SetValueDelegate(nint _metric, ulong _value); private static void Metric_SetValueFallback(nint _metric, ulong _value) => throw new Exceptions.OutdatedSdkException("Metric_SetValue", "Metric_SetValue SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Object_ActivatePhysicsDelegate(nint _object); @@ -1905,7 +1917,7 @@ private IntPtr GetUnmanagedPtr(IDictionary funcTable, ulong ha public ServerLibrary(Dictionary funcTable) { if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true; - else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 78812385462098472UL) Outdated = true; BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback); BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback); BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback); @@ -2038,10 +2050,13 @@ public ServerLibrary(Dictionary funcTable) Entity_SetStreamSyncedMetaData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12798418058428333585UL, Entity_SetStreamSyncedMetaDataFallback); Entity_SetVisible = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8026011842118229214UL, Entity_SetVisibleFallback); Event_WeaponDamageEvent_SetDamageValue = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18440396865533386791UL, Event_WeaponDamageEvent_SetDamageValueFallback); + Metric_Add = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16053290375636538610UL, Metric_AddFallback); Metric_Begin = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2348810001298180138UL, Metric_BeginFallback); Metric_End = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13016512038826983106UL, Metric_EndFallback); + Metric_End2 = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18410039824979474410UL, Metric_End2Fallback); Metric_GetName = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8652629169459184520UL, Metric_GetNameFallback); Metric_GetValue = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16033500183040421617UL, Metric_GetValueFallback); + Metric_Inc = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9564264321313118159UL, Metric_IncFallback); Metric_SetValue = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13198892627580896636UL, Metric_SetValueFallback); Object_ActivatePhysics = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17585830173881425980UL, Object_ActivatePhysicsFallback); Object_PlaceOnGroundProperly = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16593704804065749058UL, Object_PlaceOnGroundProperlyFallback); diff --git a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs index 8e8745ae9..549d703b2 100644 --- a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs @@ -426,7 +426,7 @@ public unsafe interface ISharedLibrary public unsafe class SharedLibrary : ISharedLibrary { - public readonly uint Methods = 1770; + public readonly uint Methods = 1773; public delegate* unmanaged[Cdecl] Audio_GetID { get; } public delegate* unmanaged[Cdecl] AudioAttachedOutput_GetID { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetID { get; } @@ -1669,7 +1669,7 @@ private IntPtr GetUnmanagedPtr(IDictionary funcTable, ulong ha public SharedLibrary(Dictionary funcTable) { if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true; - else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 78812385462098472UL) Outdated = true; Audio_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4464042055475980737UL, Audio_GetIDFallback); AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback); AudioFilter_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback); diff --git a/api/AltV.Net.Client.Async/AltV.Net.Client.Async.csproj b/api/AltV.Net.Client.Async/AltV.Net.Client.Async.csproj index 532d28d7d..6d846bec5 100644 --- a/api/AltV.Net.Client.Async/AltV.Net.Client.Async.csproj +++ b/api/AltV.Net.Client.Async/AltV.Net.Client.Async.csproj @@ -1,11 +1,11 @@ - FabianTerhorst,zziger,JuzTim + FabianTerhorst,Doxoh,zziger,JuzTim AltV .NET Client Async API - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.0 @@ -22,7 +22,7 @@ true AltV.Net.Client.Async - + true diff --git a/api/AltV.Net.Client/Alt.Events.cs b/api/AltV.Net.Client/Alt.Events.cs index 9ae23f44e..d0f4417b9 100644 --- a/api/AltV.Net.Client/Alt.Events.cs +++ b/api/AltV.Net.Client/Alt.Events.cs @@ -170,6 +170,18 @@ public static event NetOwnerChangeDelegate OnNetOwnerChange remove => CoreImpl.NetOwnerChangeEventHandler.Remove(value); } + public static event PlayerChangeAnimationDelegate OnPLayerChangeAnimation + { + add => CoreImpl.PlayerChangeAnimationEventHandler.Add(value); + remove => CoreImpl.PlayerChangeAnimationEventHandler.Remove(value); + } + + public static event PlayerChangeInteriorDelegate OnPlayerChangeInterior + { + add => CoreImpl.PlayerChangeInteriorEventHandler.Add(value); + remove => CoreImpl.PlayerChangeInteriorEventHandler.Remove(value); + } + public static event WeaponDamageDelegate OnWeaponDamage { add => CoreImpl.WeaponDamageEventHandler.Add(value); @@ -258,217 +270,224 @@ public static event ScriptRPCDelegate OnScriptRPC remove => CoreImpl.ScriptRPCHandler.Remove(value); } - public static void OnServer(string eventName, Function function) => CoreImpl.AddServerEventListener(eventName, function); - - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Function function) => CoreImpl.AddClientEventListener(eventName, function); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); - public static void OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Function function) => CoreImpl.AddServerEventListener(eventName, function); + + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Action function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static Function OnServer(string eventName, Func function) => CoreImpl.AddServerEventListener(eventName, Function.Create(Core, function)); + public static bool OffServer(string eventName, Function function) => CoreImpl.RemoveServerEventListener(eventName, function); + + public static Function OnClient(string eventName, Function function) => CoreImpl.AddClientEventListener(eventName, function); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Action function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static Function OnClient(string eventName, Func function) => CoreImpl.AddClientEventListener(eventName, Function.Create(Core, function)); + public static bool OffClient(string eventName, Function function) => CoreImpl.RemoveClientEventListener(eventName, function); #region WebView - public static void On(this IWebView webView, string eventName, Function function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, function); - public static void On(this IWebView webView, string eventName, Action function) => + public static Function On(this IWebView webView, string eventName, Function function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, function); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Action function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebView webView, string eventName, Func function) => CoreImpl.AddWebViewEventListener(webView.WebViewNativePointer, eventName, Function.Create(Core, function)); + public static bool Off(this IWebView webView, string eventName, Function function) => CoreImpl.RemoveWebViewEventListener(webView.WebViewNativePointer, eventName, function); #endregion #region RmlElement - public static void OnRmlEvent(this IRmlElement rmlElement, string eventName, Action> function) => CoreImpl.AddRmlElementEventListener(rmlElement.RmlElementNativePointer, eventName, Function.Create(Core, function)); + public static Function OnRmlEvent(this IRmlElement rmlElement, string eventName, Action> function) => CoreImpl.AddRmlElementEventListener(rmlElement.RmlElementNativePointer, eventName, Function.Create(Core, function)); + public static bool OffRmlEvent(this IRmlElement rmlElement, string eventName, Function function) => CoreImpl.RemoveRmlElementEventListener(rmlElement.RmlElementNativePointer, eventName, function); #endregion #region Websocket - public static void On(this IWebSocketClient webSocketClient, string eventName, Function function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, function); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Function function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, function); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Action function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IWebSocketClient webSocketClient, string eventName, Func function) => CoreImpl.AddWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, Function.Create(Core, function)); + public static bool Off(this IWebSocketClient webSocketClient, string eventName, Function function) => CoreImpl.RemoveWebSocketEventListener(webSocketClient.WebSocketClientNativePointer, eventName, function); #endregion #region Audio - public static void On(this IAudio audio, string eventName, Function function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, function); - public static void On(this IAudio audio, string eventName, Action function) => + public static Function On(this IAudio audio, string eventName, Function function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, function); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Action function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); - public static void On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static Function On(this IAudio audio, string eventName, Func function) => CoreImpl.AddAudioEventListener(audio.AudioNativePointer, eventName, Function.Create(Core, function)); + public static bool Off(this IAudio audio, string eventName, Function function) => CoreImpl.RemoveAudioEventListener(audio.AudioNativePointer, eventName, function); #endregion } diff --git a/api/AltV.Net.Client/Alt.GlobalMeta.cs b/api/AltV.Net.Client/Alt.GlobalMeta.cs index cdf0e40c3..3f943eb88 100644 --- a/api/AltV.Net.Client/Alt.GlobalMeta.cs +++ b/api/AltV.Net.Client/Alt.GlobalMeta.cs @@ -1,4 +1,5 @@ using AltV.Net.Elements.Args; +using AltV.Net.Shared.Utils; namespace AltV.Net.Client { @@ -71,7 +72,7 @@ public static bool GetMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch @@ -90,7 +91,7 @@ public static bool GetSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch @@ -109,7 +110,7 @@ public static bool GetLocalMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net.Client/Alt.cs b/api/AltV.Net.Client/Alt.cs index f7ccf7248..51d9f1535 100644 --- a/api/AltV.Net.Client/Alt.cs +++ b/api/AltV.Net.Client/Alt.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Numerics; using System.Runtime.CompilerServices; using AltV.Net.Client.Elements; diff --git a/api/AltV.Net.Client/AltV.Net.Client.csproj b/api/AltV.Net.Client/AltV.Net.Client.csproj index 1d94ef861..950d1c4cf 100644 --- a/api/AltV.Net.Client/AltV.Net.Client.csproj +++ b/api/AltV.Net.Client/AltV.Net.Client.csproj @@ -2,11 +2,11 @@ true - FabianTerhorst,zziger,JuzTim + FabianTerhorst,Doxoh,zziger,JuzTim AltV .NET Client - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.0 diff --git a/api/AltV.Net.Client/Core.Events.cs b/api/AltV.Net.Client/Core.Events.cs index 10583a98f..7be66dd7e 100644 --- a/api/AltV.Net.Client/Core.Events.cs +++ b/api/AltV.Net.Client/Core.Events.cs @@ -249,9 +249,9 @@ public void OnPlayerDisconnect() DisconnectEventHandler.GetEvents().ForEachCatching(fn => fn(), $"event {nameof(OnPlayerDisconnect)}"); } - public void OnPlayerEnterVehicle(IntPtr pointer, byte seat) + public void OnPlayerEnterVehicle(IntPtr pointer, BaseObjectType type, byte seat) { - var vehicle = PoolManager.Vehicle.Get(pointer); + var vehicle = (IVehicle)PoolManager.Get(pointer, type); if (vehicle is null) { Console.WriteLine("Invalid vehicle: " + pointer); @@ -261,9 +261,9 @@ public void OnPlayerEnterVehicle(IntPtr pointer, byte seat) EnterVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, seat), $"event {nameof(OnPlayerEnterVehicle)}"); } - public void OnGameEntityCreate(IntPtr pointer, byte type) + public void OnGameEntityCreate(IntPtr pointer, BaseObjectType type) { - var baseObject = PoolManager.Get(pointer, (BaseObjectType) type); + var baseObject = PoolManager.Get(pointer, type); if (baseObject is not IEntity entity) { Console.WriteLine("Invalid entity: " + pointer + " " + (baseObject == null)); @@ -273,9 +273,9 @@ public void OnGameEntityCreate(IntPtr pointer, byte type) GameEntityCreateEventHandler.GetEvents().ForEachCatching(fn => fn(entity), $"event {nameof(OnGameEntityCreate)}"); } - public void OnGameEntityDestroy(IntPtr pointer, byte type) + public void OnGameEntityDestroy(IntPtr pointer, BaseObjectType type) { - var baseObject = PoolManager.Get(pointer, (BaseObjectType) type); + var baseObject = PoolManager.Get(pointer, type); if (baseObject is not IEntity entity) { Console.WriteLine("Invalid entity: " + pointer); @@ -339,14 +339,14 @@ public void OnGlobalSyncedMetaChange(string key, IntPtr valuePtr, IntPtr oldValu GlobalSyncedMetaChangeEventHandler.GetEvents().ForEachCatching(fn => fn(key, value.ToObject(), oldValue.ToObject()), $"event {nameof(OnGlobalSyncedMetaChange)}"); } - public void OnPlayerChangeVehicleSeat(IntPtr vehiclePtr, byte oldSeat, byte newSeat) + public void OnPlayerChangeVehicleSeat(IntPtr vehiclePtr, BaseObjectType type, byte oldSeat, byte newSeat) { - var vehicle = PoolManager.Vehicle.Get(vehiclePtr); + var vehicle = (IVehicle)PoolManager.Get(vehiclePtr, type); PlayerChangeVehicleSeatEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, oldSeat, newSeat), $"event {nameof(OnPlayerChangeVehicleSeat)}"); } - public void OnPlayerChangeAnimation(IntPtr playerPtr, uint oldDict, uint newDict, uint oldName, uint newName) + public void OnPlayerChangeAnimation(IntPtr playerPtr, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName) { - var player = PoolManager.Player.Get(playerPtr); + var player = (IPlayer)PoolManager.Get(playerPtr, type); if (player == null) { Alt.LogWarning("OnPlayerChangeAnimation: Invalid player " + playerPtr); @@ -356,9 +356,9 @@ public void OnPlayerChangeAnimation(IntPtr playerPtr, uint oldDict, uint newDict PlayerChangeAnimationEventHandler.GetEvents().ForEachCatching(fn => fn(player, oldDict, newDict, oldName, newName), $"event {nameof(OnPlayerChangeAnimation)}"); } - public void OnPlayerChangeInterior(IntPtr playerPtr, uint oldIntLoc, uint newIntLoc) + public void OnPlayerChangeInterior(IntPtr playerPtr, BaseObjectType type, uint oldIntLoc, uint newIntLoc) { - var player = PoolManager.Player.Get(playerPtr); + var player = (IPlayer)PoolManager.Get(playerPtr, type); if (player == null) { Alt.LogWarning("OnPlayerChangeInterior: Invalid player " + playerPtr); @@ -475,9 +475,15 @@ public void OnRemoveEntity(IntPtr targetPtr, BaseObjectType type) RemoveEntityEventHandler.GetEvents().ForEachCatching(fn => fn(target), $"event {nameof(OnRemoveEntity)}"); } - public void OnPlayerLeaveVehicle(IntPtr vehiclePtr, byte seat) + public void OnPlayerLeaveVehicle(IntPtr vehiclePtr, BaseObjectType type, byte seat) { - var vehicle = PoolManager.Vehicle.Get(vehiclePtr); + var vehicle = (IVehicle)PoolManager.Get(vehiclePtr, type); + if (vehicle is null) + { + Console.WriteLine("Invalid vehicle: " + vehiclePtr); + return; + } + PlayerLeaveVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, seat), $"event {nameof(OnPlayerLeaveVehicle)}"); } @@ -648,18 +654,18 @@ public void OnMetaChange(IntPtr targetPtr, BaseObjectType type, string key, IntP MetaChangeEventHandler.GetEvents().ForEachCatching(fn => fn(target, key, value.ToObject(), oldValue.ToObject()), $"event {nameof(OnMetaChange)}"); } - public void OnPlayerStartEnterVehicle(IntPtr targetpointer, IntPtr playerPointer, byte seat) + public void OnPlayerStartEnterVehicle(IntPtr targetpointer, BaseObjectType type, IntPtr playerPointer, BaseObjectType playerType, byte seat) { - var vehicle = PoolManager.Vehicle.Get(targetpointer); - var player = PoolManager.Player.Get(playerPointer); + var vehicle = (IVehicle)PoolManager.Get(targetpointer, type); + var player = (IPlayer)PoolManager.Get(playerPointer, playerType); PlayerStartEnterVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, player, seat), $"event {nameof(OnPlayerStartEnterVehicle)}"); } - public void OnPlayerStartLeaveVehicle(IntPtr targetpointer, IntPtr playerPointer, byte seat) + public void OnPlayerStartLeaveVehicle(IntPtr targetpointer, BaseObjectType type, IntPtr playerPointer, BaseObjectType playerType, byte seat) { - var vehicle = PoolManager.Vehicle.Get(targetpointer); - var player = PoolManager.Player.Get(playerPointer); + var vehicle = (IVehicle)PoolManager.Get(targetpointer, type); + var player = (IPlayer)PoolManager.Get(playerPointer, playerType); PlayerStartLeaveVehicleEventHandler.GetEvents().ForEachCatching(fn => fn(vehicle, player, seat), $"event {nameof(OnPlayerStartLeaveVehicle)}"); } @@ -719,5 +725,69 @@ public void OnScriptRPC(IntPtr eventpointer, string name, IntPtr[] args, ushort UnansweredClientRpcRequest.Remove(answerid); } } + + public bool RemoveServerEventListener(string name, Function function) + { + if (function is null + || !ServerEventBus.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } + + public bool RemoveClientEventListener(string name, Function function) + { + if (function is null + || !ClientEventBus.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } + + public bool RemoveWebViewEventListener(IntPtr webViewPtr, string name, Function function) + { + if (function is null + || !WebViewEventBus.TryGetValue(webViewPtr, out var eventHandlerDictionary) + || !eventHandlerDictionary.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } + + public bool RemoveAudioEventListener(IntPtr audioPtr, string name, Function function) + { + if (function is null + || !AudioEventBus.TryGetValue(audioPtr, out var eventHandlerDictionary) + || !eventHandlerDictionary.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } + + public bool RemoveRmlElementEventListener(IntPtr rmlElementPtr, string name, Function function) + { + if (function is null + || !RmlElementEventBus.TryGetValue(rmlElementPtr, out var eventHandlerDictionary) + || !eventHandlerDictionary.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } + + public bool RemoveWebSocketEventListener(IntPtr webSocketPtr, string name, Function function) + { + if (function is null + || !WebSocketEventBus.TryGetValue(webSocketPtr, out var eventHandlerDictionary) + || !eventHandlerDictionary.TryGetValue(name, out var eventHandlers)) + { + return false; + } + return eventHandlers.Remove(function); + } } } \ No newline at end of file diff --git a/api/AltV.Net.Client/Core.cs b/api/AltV.Net.Client/Core.cs index 7e25e6737..8977c24cb 100644 --- a/api/AltV.Net.Client/Core.cs +++ b/api/AltV.Net.Client/Core.cs @@ -232,7 +232,7 @@ public IReadOnlyCollection GetAllTextLabels() { CheckIfCallIsValid(); ulong size = 0; - var ptr = Library.Shared.Core_GetMarkers(NativePointer, &size); + var ptr = Library.Shared.Core_GetTextLabels(NativePointer, &size); var data = new IntPtr[size]; Marshal.Copy(ptr, data, 0, (int)size); var arr = data.Select(e => PoolManager.TextLabel.GetOrCreate(this, e)).ToArray(); diff --git a/api/AltV.Net.Client/Elements/Data/LocalStorage.cs b/api/AltV.Net.Client/Elements/Data/LocalStorage.cs index cc3a0bbf7..73bf5a4c9 100644 --- a/api/AltV.Net.Client/Elements/Data/LocalStorage.cs +++ b/api/AltV.Net.Client/Elements/Data/LocalStorage.cs @@ -165,7 +165,7 @@ public bool Get(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net.Client/Elements/Entities/Entity.cs b/api/AltV.Net.Client/Elements/Entities/Entity.cs index 1914158d7..5c741f012 100644 --- a/api/AltV.Net.Client/Elements/Entities/Entity.cs +++ b/api/AltV.Net.Client/Elements/Entities/Entity.cs @@ -172,7 +172,7 @@ public bool GetStreamSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net.Client/Elements/Entities/LocalPed.cs b/api/AltV.Net.Client/Elements/Entities/LocalPed.cs index 656551c2f..96f4dd892 100644 --- a/api/AltV.Net.Client/Elements/Entities/LocalPed.cs +++ b/api/AltV.Net.Client/Elements/Entities/LocalPed.cs @@ -17,7 +17,7 @@ private static IntPtr GetPedPointer(ICore core, IntPtr nativePointer) } } - public LocalPed(ICore core, IntPtr nativePointer, uint id) : base(core, GetPedPointer(core, nativePointer), BaseObjectType.LocalVehicle, id) + public LocalPed(ICore core, IntPtr nativePointer, uint id) : base(core, GetPedPointer(core, nativePointer), BaseObjectType.LocalPed, id) { LocalPedNativePointer = nativePointer; } diff --git a/api/AltV.Net.Client/Elements/Entities/RmlElement.cs b/api/AltV.Net.Client/Elements/Entities/RmlElement.cs index c7dde5eea..416b97881 100644 --- a/api/AltV.Net.Client/Elements/Entities/RmlElement.cs +++ b/api/AltV.Net.Client/Elements/Entities/RmlElement.cs @@ -19,7 +19,7 @@ private static IntPtr GetBaseObjectPointer(ICore core, IntPtr rmlElementPointer) public IntPtr RmlElementNativePointer { get; } public override IntPtr NativePointer => RmlElementNativePointer; - public RmlElement(ICore core, IntPtr rmlElementPointer, uint id) : base(core, GetBaseObjectPointer(core, rmlElementPointer), BaseObjectType.RmlDocument, id) + public RmlElement(ICore core, IntPtr rmlElementPointer, uint id) : base(core, GetBaseObjectPointer(core, rmlElementPointer), BaseObjectType.RmlElement, id) { RmlElementNativePointer = rmlElementPointer; } diff --git a/api/AltV.Net.Client/Elements/Entities/Vehicle.cs b/api/AltV.Net.Client/Elements/Entities/Vehicle.cs index 63a664d84..e1221cae9 100644 --- a/api/AltV.Net.Client/Elements/Entities/Vehicle.cs +++ b/api/AltV.Net.Client/Elements/Entities/Vehicle.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using AltV.Net.Client.Elements.Data; using AltV.Net.Client.Elements.Interfaces; using AltV.Net.Elements.Entities; diff --git a/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs b/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs index ecc28df66..5f83aa217 100644 --- a/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs +++ b/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs @@ -73,7 +73,7 @@ public bool GetStreamSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net.Client/Elements/Interfaces/IBaseObject.cs b/api/AltV.Net.Client/Elements/Interfaces/IBaseObject.cs index eda0d7432..96c715f0f 100644 --- a/api/AltV.Net.Client/Elements/Interfaces/IBaseObject.cs +++ b/api/AltV.Net.Client/Elements/Interfaces/IBaseObject.cs @@ -1,4 +1,4 @@ -using AltV.Net.Shared.Elements.Entities; +using AltV.Net.Shared.Elements.Entities; namespace AltV.Net.Client.Elements.Interfaces { diff --git a/api/AltV.Net.Client/Elements/Interfaces/IVehicle.cs b/api/AltV.Net.Client/Elements/Interfaces/IVehicle.cs index 6e6010f7f..79212c461 100644 --- a/api/AltV.Net.Client/Elements/Interfaces/IVehicle.cs +++ b/api/AltV.Net.Client/Elements/Interfaces/IVehicle.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using AltV.Net.Client.Elements.Data; using AltV.Net.Shared.Elements.Entities; diff --git a/api/AltV.Net.Client/Elements/Pools/PoolManager.cs b/api/AltV.Net.Client/Elements/Pools/PoolManager.cs index def6a2eb3..d1d2550c2 100644 --- a/api/AltV.Net.Client/Elements/Pools/PoolManager.cs +++ b/api/AltV.Net.Client/Elements/Pools/PoolManager.cs @@ -69,44 +69,44 @@ public PoolManager( IBaseObjectPool rmlDocumentPool, IEntityPool localObjectPool, IEntityPool objectPool, - IBaseObjectPool virtualEntitiyPool, - IBaseObjectPool virtualEntitiyGroupPool, + IBaseObjectPool virtualEntityPool, + IBaseObjectPool virtualEntityGroupPool, IBaseObjectPool textLabelPool, IBaseObjectPool colShapePool, IBaseObjectPool localVehiclePool, IBaseObjectPool localPedPool, IBaseObjectPool audioFilterPool, IBaseObjectPool audioOutputPool, - IBaseObjectPool AudioOutputFrontendPool, - IBaseObjectPool AudioOutputAttachedPool, - IBaseObjectPool AudioOutputWorldPool, + IBaseObjectPool audioOutputFrontendPool, + IBaseObjectPool audioOutputAttachedPool, + IBaseObjectPool audioOutputWorldPool, IBaseObjectPool fontPool, IBaseObjectPool markerPool) { - this.Player = playerPool; - this.Vehicle = vehiclePool; - this.Ped = pedPool; - this.Blip = blipPool; - this.Checkpoint = checkpointPool; - this.Audio = audioPool; - this.HttpClient = httpClientPool; - this.WebSocketClient = webSocketClientPool; - this.WebView = webViewPool; - this.RmlElement = rmlElementPool; - this.RmlDocument = rmlDocumentPool; - this.LocalObject = localObjectPool; - this.Object = objectPool; - this.VirtualEntity = virtualEntitiyPool; - this.VirtualEntityGroup = virtualEntitiyGroupPool; + Player = playerPool; + Vehicle = vehiclePool; + Ped = pedPool; + Blip = blipPool; + Checkpoint = checkpointPool; + Audio = audioPool; + HttpClient = httpClientPool; + WebSocketClient = webSocketClientPool; + WebView = webViewPool; + RmlElement = rmlElementPool; + RmlDocument = rmlDocumentPool; + LocalObject = localObjectPool; + Object = objectPool; + VirtualEntity = virtualEntityPool; + VirtualEntityGroup = virtualEntityGroupPool; TextLabel = textLabelPool; ColShape = colShapePool; LocalVehicle = localVehiclePool; LocalPed = localPedPool; AudioFilter = audioFilterPool; AudioOutput = audioOutputPool; - AudioOutputFrontend = AudioOutputFrontendPool; - AudioOutputAttached = AudioOutputAttachedPool; - AudioOutputWorld = AudioOutputWorldPool; + AudioOutputFrontend = audioOutputFrontendPool; + AudioOutputAttached = audioOutputAttachedPool; + AudioOutputWorld = audioOutputWorldPool; Font = fontPool; Marker = markerPool; } diff --git a/api/AltV.Net.Client/ModuleWrapper.cs b/api/AltV.Net.Client/ModuleWrapper.cs index f23ba6794..edaeccd75 100644 --- a/api/AltV.Net.Client/ModuleWrapper.cs +++ b/api/AltV.Net.Client/ModuleWrapper.cs @@ -209,17 +209,17 @@ public static void OnPlayerDisconnect() _core.OnPlayerDisconnect(); } - public static void OnPlayerEnterVehicle(IntPtr pointer, byte seat) + public static void OnPlayerEnterVehicle(IntPtr pointer, BaseObjectType type, byte seat) { - _core.OnPlayerEnterVehicle(pointer, seat); + _core.OnPlayerEnterVehicle(pointer, type, seat); } - public static void OnGameEntityCreate(IntPtr pointer, byte type) + public static void OnGameEntityCreate(IntPtr pointer, BaseObjectType type) { _core.OnGameEntityCreate(pointer, type); } - public static void OnGameEntityDestroy(IntPtr pointer, byte type) + public static void OnGameEntityDestroy(IntPtr pointer, BaseObjectType type) { _core.OnGameEntityDestroy(pointer, type); } @@ -323,19 +323,19 @@ public static void OnConnectionComplete() _core.OnConnectionComplete(); } - public static void OnPlayerChangeVehicleSeat(IntPtr vehicle, byte oldSeat, byte newSeat) + public static void OnPlayerChangeVehicleSeat(IntPtr vehicle, BaseObjectType type, byte oldSeat, byte newSeat) { - _core.OnPlayerChangeVehicleSeat(vehicle, oldSeat, newSeat); + _core.OnPlayerChangeVehicleSeat(vehicle, type, oldSeat, newSeat); } - public static void OnPlayerChangeAnimation(IntPtr player, uint oldDict, uint newDict, uint oldName, uint newName) + public static void OnPlayerChangeAnimation(IntPtr player, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName) { - _core.OnPlayerChangeAnimation(player, oldDict, newDict, oldName, newName); + _core.OnPlayerChangeAnimation(player, type, oldDict, newDict, oldName, newName); } - public static void OnPlayerChangeInterior(IntPtr player, uint oldIntLoc, uint newIntLoc) + public static void OnPlayerChangeInterior(IntPtr player, BaseObjectType type, uint oldIntLoc, uint newIntLoc) { - _core.OnPlayerChangeInterior(player, oldIntLoc, newIntLoc); + _core.OnPlayerChangeInterior(player, type, oldIntLoc, newIntLoc); } public static void OnPlayerWeaponShoot(uint weapon, ushort totalAmmo, ushort ammoInClip) @@ -396,9 +396,9 @@ public static void OnWorldObjectPositionChange(IntPtr target, BaseObjectType typ _core.OnWorldObjectPositionChange(target, type, position); } - public static void OnPlayerLeaveVehicle(IntPtr vehicle, byte seat) + public static void OnPlayerLeaveVehicle(IntPtr vehicle, BaseObjectType type, byte seat) { - _core.OnPlayerLeaveVehicle(vehicle, seat); + _core.OnPlayerLeaveVehicle(vehicle, type, seat); } public static void OnWorldObjectStreamIn(IntPtr target, BaseObjectType type) @@ -426,14 +426,14 @@ public static void OnMetaChange(IntPtr target, BaseObjectType type, string key, _core.OnMetaChange(target, type, key, value, oldvalue); } - public static void OnPlayerStartEnterVehicle(IntPtr targetpointer, IntPtr player, byte seat) + public static void OnPlayerStartEnterVehicle(IntPtr targetpointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat) { - _core.OnPlayerStartEnterVehicle(targetpointer, player, seat); + _core.OnPlayerStartEnterVehicle(targetpointer, type, player, playerType, seat); } - public static void OnPlayerStartLeaveVehicle(IntPtr targetpointer, IntPtr player, byte seat) + public static void OnPlayerStartLeaveVehicle(IntPtr targetpointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat) { - _core.OnPlayerStartLeaveVehicle(targetpointer, player, seat); + _core.OnPlayerStartLeaveVehicle(targetpointer, type, player, playerType, seat); } public static void OnEntityHitEntity(IntPtr targetpointer, BaseObjectType targettype, IntPtr damagerpointer, BaseObjectType damagertype, uint weaponhash) diff --git a/api/AltV.Net.ColShape/AltV.Net.ColShape.csproj b/api/AltV.Net.ColShape/AltV.Net.ColShape.csproj index 0ca873566..30d1f0071 100644 --- a/api/AltV.Net.ColShape/AltV.Net.ColShape.csproj +++ b/api/AltV.Net.ColShape/AltV.Net.ColShape.csproj @@ -1,11 +1,11 @@  - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Core ColShape Api - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav colshape 1.0.0 diff --git a/api/AltV.Net.EntitySync.ServerEvent/AltV.Net.EntitySync.ServerEvent.csproj b/api/AltV.Net.EntitySync.ServerEvent/AltV.Net.EntitySync.ServerEvent.csproj index 7c6621146..9b2fd29d8 100644 --- a/api/AltV.Net.EntitySync.ServerEvent/AltV.Net.EntitySync.ServerEvent.csproj +++ b/api/AltV.Net.EntitySync.ServerEvent/AltV.Net.EntitySync.ServerEvent.csproj @@ -1,11 +1,11 @@ - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Core Entity Sync ServerEvent network layer - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav chat 1.0.0 diff --git a/api/AltV.Net.EntitySync/AltV.Net.EntitySync.csproj b/api/AltV.Net.EntitySync/AltV.Net.EntitySync.csproj index 5b054225b..6a4d3745b 100644 --- a/api/AltV.Net.EntitySync/AltV.Net.EntitySync.csproj +++ b/api/AltV.Net.EntitySync/AltV.Net.EntitySync.csproj @@ -6,8 +6,8 @@ AltMp AltV .NET Core Entity Sync AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav license.txt diff --git a/api/AltV.Net.Interactions/AltV.Net.Interactions.csproj b/api/AltV.Net.Interactions/AltV.Net.Interactions.csproj index fa777a2a9..2bea9b4a7 100644 --- a/api/AltV.Net.Interactions/AltV.Net.Interactions.csproj +++ b/api/AltV.Net.Interactions/AltV.Net.Interactions.csproj @@ -2,11 +2,11 @@ true - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Core Interactions - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.0 diff --git a/api/AltV.Net.Mock/AltV.Net.Mock.csproj b/api/AltV.Net.Mock/AltV.Net.Mock.csproj index d2999bef7..71db69d7e 100644 --- a/api/AltV.Net.Mock/AltV.Net.Mock.csproj +++ b/api/AltV.Net.Mock/AltV.Net.Mock.csproj @@ -7,8 +7,8 @@ AltMp AltV .NET Core Server Mock Api AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge mock 1.17.2-alpha diff --git a/api/AltV.Net.ResourceGenerator/AltV.Net.ResourceGenerator.csproj b/api/AltV.Net.ResourceGenerator/AltV.Net.ResourceGenerator.csproj index ed22c6154..04538a48d 100644 --- a/api/AltV.Net.ResourceGenerator/AltV.Net.ResourceGenerator.csproj +++ b/api/AltV.Net.ResourceGenerator/AltV.Net.ResourceGenerator.csproj @@ -2,11 +2,11 @@ true - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Core Resource Generator - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.1 diff --git a/api/AltV.Net.Resources.Chat.Api/AltV.Net.Resources.Chat.Api.csproj b/api/AltV.Net.Resources.Chat.Api/AltV.Net.Resources.Chat.Api.csproj index cfeef3b31..2635ff43f 100644 --- a/api/AltV.Net.Resources.Chat.Api/AltV.Net.Resources.Chat.Api.csproj +++ b/api/AltV.Net.Resources.Chat.Api/AltV.Net.Resources.Chat.Api.csproj @@ -1,11 +1,11 @@ - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Core Chat API - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav chat 1.0.0 diff --git a/api/AltV.Net.Sdk.Client/AltV.Net.Sdk.Client.csproj b/api/AltV.Net.Sdk.Client/AltV.Net.Sdk.Client.csproj index 10ae89626..d84c88e1b 100644 --- a/api/AltV.Net.Sdk.Client/AltV.Net.Sdk.Client.csproj +++ b/api/AltV.Net.Sdk.Client/AltV.Net.Sdk.Client.csproj @@ -4,8 +4,8 @@ AltMp alt:V .NET client SDK AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav altvsdk 1.0.0 diff --git a/api/AltV.Net.Sdk.Server/AltV.Net.Sdk.Server.csproj b/api/AltV.Net.Sdk.Server/AltV.Net.Sdk.Server.csproj index 14de90e94..ae24fff44 100644 --- a/api/AltV.Net.Sdk.Server/AltV.Net.Sdk.Server.csproj +++ b/api/AltV.Net.Sdk.Server/AltV.Net.Sdk.Server.csproj @@ -4,8 +4,8 @@ AltMp alt:V .NET server SDK AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav altvsdk 1.0.0 diff --git a/api/AltV.Net.Sdk.Shared/AltV.Net.Sdk.Shared.csproj b/api/AltV.Net.Sdk.Shared/AltV.Net.Sdk.Shared.csproj index 67fe48ff6..f07784652 100644 --- a/api/AltV.Net.Sdk.Shared/AltV.Net.Sdk.Shared.csproj +++ b/api/AltV.Net.Sdk.Shared/AltV.Net.Sdk.Shared.csproj @@ -4,8 +4,8 @@ AltMp alt:V .NET shared SDK AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav altvsdk 1.0.0 diff --git a/api/AltV.Net.Shared/AltV.Net.Shared.csproj b/api/AltV.Net.Shared/AltV.Net.Shared.csproj index e371e13d4..6c440b41a 100644 --- a/api/AltV.Net.Shared/AltV.Net.Shared.csproj +++ b/api/AltV.Net.Shared/AltV.Net.Shared.csproj @@ -1,11 +1,11 @@ - FabianTerhorst + FabianTerhorst,Doxoh AltV .NET Shared API - FabianTerhorst - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + FabianTerhorst,Doxoh + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.0 diff --git a/api/AltV.Net.Shared/Elements/Args/MValueConst.cs b/api/AltV.Net.Shared/Elements/Args/MValueConst.cs index 8720c8867..68c590479 100644 --- a/api/AltV.Net.Shared/Elements/Args/MValueConst.cs +++ b/api/AltV.Net.Shared/Elements/Args/MValueConst.cs @@ -188,7 +188,7 @@ public void CallFunction(MValueConst[] args, out MValueConst result) argsPointers[i] = args[i].nativePointer; } - result = new MValueConst(core, + result = new MValueConst(core, core.Library.Shared.MValueConst_CallFunction(core.NativePointer, nativePointer, argsPointers, length)); } @@ -316,7 +316,7 @@ public object ToObject() if (entityPointer == IntPtr.Zero) return null; // TODO get or create return core.PoolManager.Get(entityPointer, entityType); - + case Type.Function: return null; case Type.Vector3: diff --git a/api/AltV.Net.Shared/Elements/Entities/CheckpointType.cs b/api/AltV.Net.Shared/Elements/Entities/CheckpointType.cs index 9e06b9ac1..ce8b6570a 100644 --- a/api/AltV.Net.Shared/Elements/Entities/CheckpointType.cs +++ b/api/AltV.Net.Shared/Elements/Entities/CheckpointType.cs @@ -7,11 +7,13 @@ public enum CheckpointType : byte CylinderTripleArrow, CylinderCycleArrow, CylinderCheckerboard, + CylinderWrench, CylinderSingleArrow2, CylinderDoubleArrow2, CylinderTripleArrow2, CylinderCycleArrow2, CylinderCheckerboard2, + CylinderWrench2, RingSingleArrow, RingDoubleArrow, RingTripleArrow, @@ -44,12 +46,28 @@ public enum CheckpointType : byte Empty, Ring, Empty2, - - //CylinderCustomShape, - //CylinderCustomShape2, - //CylinderCustomShape3, - Cylinder = 45, + Cylinder, + Cylinder1, Cylinder2, - Cylinder3 + Cylinder3, + Cylinder4, + Cylinder5, + Empty3, + Empty4, + Empty5, + Empty6, + RingDollar, + RingWolf, + RingQuestionMark, + RingPlane, + RingChopper, + RingBoat, + RingCar, + RingBike, + RingBicycle, + RingTruck, + RingParachute, + RingJetpack, + RingWhirl } } \ No newline at end of file diff --git a/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs b/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs index d9b7ad971..e9036f662 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs @@ -1,4 +1,4 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using AltV.Net.Elements.Args; using AltV.Net.Elements.Entities; using AltV.Net.Types; diff --git a/api/AltV.Net.Shared/Elements/Entities/ISharedBlip.cs b/api/AltV.Net.Shared/Elements/Entities/ISharedBlip.cs index b54f77822..01e057796 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ISharedBlip.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ISharedBlip.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using AltV.Net.Data; namespace AltV.Net.Shared.Elements.Entities diff --git a/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs b/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs index 17e305321..917e0f1d3 100644 --- a/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs +++ b/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs @@ -223,7 +223,7 @@ public bool GetMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.Utils.GetCastedMValue(mValue); return true; } catch @@ -302,7 +302,7 @@ public bool GetSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net.Shared/Events/HashSetEventHandler.cs b/api/AltV.Net.Shared/Events/HashSetEventHandler.cs index 27f7701eb..a2254fada 100644 --- a/api/AltV.Net.Shared/Events/HashSetEventHandler.cs +++ b/api/AltV.Net.Shared/Events/HashSetEventHandler.cs @@ -18,15 +18,19 @@ public HashSetEventHandler() public void Add(TEvent value) { if (value == null) return; - if (type != null) core.EventStateManager.AddHandler(type.Value); - events.Add(value); + if (events.Add(value)) + { + if (type != null) core.EventStateManager.AddHandler(type.Value); + } } public void Remove(TEvent value) { if (value == null) return; - if (type != null) core.EventStateManager.RemoveHandler(type.Value); - events.Remove(value); + if (events.Remove(value)) + { + if (type != null) core.EventStateManager.RemoveHandler(type.Value); + } } public HashSet GetEvents() => events; diff --git a/api/AltV.Net.Shared/Utils/Utils.cs b/api/AltV.Net.Shared/Utils/Utils.cs index 5e0d3e3c7..246a70966 100644 --- a/api/AltV.Net.Shared/Utils/Utils.cs +++ b/api/AltV.Net.Shared/Utils/Utils.cs @@ -1,4 +1,5 @@ using System.Text; +using AltV.Net.Elements.Args; namespace AltV.Net.Shared.Utils { @@ -25,5 +26,122 @@ public static uint Hash(string stringToHash) return hash; } + + public static T GetCastedMValue(MValueConst mValue) + { + object @object; + + if (mValue.type == MValueConst.Type.List) + { + if (mValue.ToObject() is IEnumerable sourceEnumerable) + { + + if (typeof(T).IsArray) + { + var resultList = new List(); + var elementType = typeof(T).IsArray ? typeof(T).GetElementType() : typeof(T).GetGenericArguments()[0]; + + foreach (var item in sourceEnumerable) + { + if (item == null) + { + resultList.Add(null); + } + else + { + resultList.Add(Convert.ChangeType(item, elementType)); + } + } + + var resultArray = Array.CreateInstance(elementType, resultList.Count); + for (int i = 0; i < resultList.Count; i++) + { + resultArray.SetValue(resultList[i], i); + } + return (T)(object)resultArray; + } + else + { + T resultList = default(T)!; + if (typeof(T).IsGenericType && (typeof(T).GetGenericTypeDefinition() == typeof(List<>))) + { + resultList = Activator.CreateInstance(); + + var type = typeof(T).GetGenericArguments()[0]; + foreach (var item in (object[])mValue.ToObject()) + { + if (item == null) + { + resultList.GetType().GetMethod("Add").Invoke(resultList, [null]); + } + else + { + resultList.GetType().GetMethod("Add").Invoke(resultList, [Convert.ChangeType(item, type)]); + } + } + } + return resultList; + } + } + else + { + throw new ArgumentException("Quellobjekt muss eine IEnumerable sein."); + } + + /* + T resultList = default(T)!; + if (typeof(T).IsGenericType && (typeof(T).GetGenericTypeDefinition() == typeof(List<>))) + { + resultList = Activator.CreateInstance(); + + var type = typeof(T).GetGenericArguments()[0]; + foreach (var item in (object[])mValue.ToObject()) + { + if (item == null) + { + resultList.GetType().GetMethod("Add").Invoke(resultList, [null]); + } + else + { + resultList.GetType().GetMethod("Add").Invoke(resultList, [Convert.ChangeType(item, type)]); + } + } + } + + return resultList;*/ + } + + if (mValue.type == MValueConst.Type.Dict) + { + T resultDictionary = default(T); + if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Dictionary<,>)) + { + var dictionaryType = typeof(T); + var valueType = dictionaryType.GetGenericArguments()[1]; + + if (mValue.ToObject() is Dictionary sourceDictionary) + { + resultDictionary = Activator.CreateInstance(); + + foreach (var kvp in sourceDictionary) + { + object value = Convert.ChangeType(kvp.Value, valueType); + resultDictionary.GetType().GetMethod("Add").Invoke(resultDictionary, new object[] { kvp.Key, value }); + } + + return resultDictionary; + } + else + { + throw new ArgumentException("Quellobjekt muss ein Dictionary sein."); + } + } + return resultDictionary; + } + + @object = mValue.ToObject(); + + return (T)Convert.ChangeType(@object, typeof(T)); + } } } \ No newline at end of file diff --git a/api/AltV.Net.VehicleData/AltV.Net.VehicleData.csproj b/api/AltV.Net.VehicleData/AltV.Net.VehicleData.csproj index 8c9e1c0f0..06ec05470 100644 --- a/api/AltV.Net.VehicleData/AltV.Net.VehicleData.csproj +++ b/api/AltV.Net.VehicleData/AltV.Net.VehicleData.csproj @@ -7,8 +7,8 @@ AltMp AltV .NET VehicleData Api AltMp - https://github.com/fabianterhorst/coreclr-module - https://github.com/fabianterhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git 1.0.0-dev-preview license.txt diff --git a/api/AltV.Net.sln b/api/AltV.Net.sln index f02bfbd62..ec39ffdd8 100644 --- a/api/AltV.Net.sln +++ b/api/AltV.Net.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AltV.Net", "AltV.Net\AltV.Net.csproj", "{B41318D4-99B3-4B17-88C1-2B7CCF60541F}" EndProject diff --git a/api/AltV.Net/Alt.Events.cs b/api/AltV.Net/Alt.Events.cs index cf5538cd3..50cd05aa8 100644 --- a/api/AltV.Net/Alt.Events.cs +++ b/api/AltV.Net/Alt.Events.cs @@ -26,6 +26,18 @@ public static event PlayerConnectDelegate OnPlayerConnect remove => CoreImpl.PlayerConnectEventHandler.Remove(value); } + public static event BaseObjectCreateDelegate OnBaseObjectCreate + { + add => CoreImpl.BaseObjectCreateEventHandler.Add(value); + remove => CoreImpl.BaseObjectCreateEventHandler.Remove(value); + } + + public static event BaseObjectRemoveDelegate OnBaseObjectRemove + { + add => CoreImpl.BaseObjectRemoveEventHandler.Add(value); + remove => CoreImpl.BaseObjectRemoveEventHandler.Remove(value); + } + public static event PlayerConnectDeniedDelegate OnPlayerConnectDenied { add => CoreImpl.PlayerConnectDeniedEventHandler.Add(value); diff --git a/api/AltV.Net/Alt.GlobalMeta.cs b/api/AltV.Net/Alt.GlobalMeta.cs index b485b6a70..de87c4325 100644 --- a/api/AltV.Net/Alt.GlobalMeta.cs +++ b/api/AltV.Net/Alt.GlobalMeta.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using AltV.Net.Elements.Args; +using AltV.Net.Shared.Utils; namespace AltV.Net { @@ -14,12 +16,12 @@ public static partial class Alt public static bool GetMetaData(string key, out T result) { Core.GetMetaData(key, out var mValue); + using (mValue) { - try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch @@ -44,7 +46,7 @@ public static bool GetSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net/Alt.Import.cs b/api/AltV.Net/Alt.Import.cs index ed1495870..4428ddf98 100644 --- a/api/AltV.Net/Alt.Import.cs +++ b/api/AltV.Net/Alt.Import.cs @@ -1,6 +1,7 @@ using System; using AltV.Net.Elements.Args; using AltV.Net.Native; +using AltV.Net.Shared.Utils; namespace AltV.Net { @@ -141,7 +142,7 @@ public static bool Import(string resourceName, string key, out object value) value = mValue.ToObject(); return true; } - + public static bool Import(string resourceName, string key, out string value) { if (HostImport(resourceName, key, out value)) @@ -168,7 +169,7 @@ public static bool Import(string resourceName, string key, out MValueConst mValu throw new InvalidImportException( $"Resource: '{resourceName}' not found."); } - + if (!resource.GetExport(key, out mValue)) { throw new InvalidImportException( @@ -198,14 +199,14 @@ public static bool Import(string resourceName, string key, MValueConst.Type type Alt.Core.CreateMValue(out var mValueElement, args[i]); mValueArgs[i] = mValueElement.nativePointer; } - + result = new MValueConst(Alt.Core.Library.MValue_CallFunction(mValue.nativePointer, mValueArgs, length)); for (ulong i = 0;i < length;i++) { Alt.Core.Library.MValueConst_Delete(mValueArgs[i]); } }*/ - + private static object ImportCall(in MValueConst mValue, object[] args) { unsafe @@ -230,6 +231,30 @@ private static object ImportCall(in MValueConst mValue, object[] args) } } + private static object ImportCall(in MValueConst mValue, object[] args) + { + unsafe + { + var length = (ulong) args.Length; + var mValueArgs = new IntPtr[length]; + for (uint i = 0; i < length; i++) + { + Alt.Core.CreateMValue(out var mValueElement, args[i]); + mValueArgs[i] = mValueElement.nativePointer; + } + + var result = new MValueConst(Alt.Core, Alt.Core.Library.Shared.MValueConst_CallFunction(Alt.Core.NativePointer, mValue.nativePointer, mValueArgs, length)); + var resultObj = Utils.GetCastedMValue(result); + result.Dispose(); + for (ulong i = 0;i < length;i++) + { + Alt.Core.Library.Shared.MValueConst_Delete(mValueArgs[i]); + } + + return resultObj; + } + } + public static bool Import(string resourceName, string key, out Action value) { if (HostImport(resourceName, key, out value)) @@ -578,7 +603,7 @@ public static bool Import(string resourceName, string key, out Func { - if (ImportCall(mValue, new object[] { }) is TResult result) + if (ImportCall(mValue, new object[] { }) is TResult result) { return result; } @@ -603,7 +628,7 @@ public static bool Import(string resourceName, string key, out Func value = (p1) => { - if (ImportCall(mValue, new object[] {p1}) is TResult result) + if (ImportCall(mValue, new object[] {p1}) is TResult result) { return result; } @@ -628,7 +653,7 @@ public static bool Import(string resourceName, string key, out value = (p1, p2) => { - if (ImportCall(mValue, new object[] {p1, p2}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2}) is TResult result) { return result; } @@ -654,7 +679,7 @@ public static bool Import(string resourceName, string key, value = (p1, p2, p3) => { - if (ImportCall(mValue, new object[] {p1, p2, p3}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3}) is TResult result) { return result; } @@ -680,7 +705,7 @@ public static bool Import(string resourceName, string k value = (p1, p2, p3, p4) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4}) is TResult result) { return result; } @@ -706,7 +731,7 @@ public static bool Import(string resourceName, stri value = (p1, p2, p3, p4, p5) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5}) is TResult result) { return result; } @@ -732,7 +757,7 @@ public static bool Import(string resourceName, value = (p1, p2, p3, p4, p5, p6) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6}) is TResult result) { return result; } @@ -758,7 +783,7 @@ public static bool Import(string resourceNa value = (p1, p2, p3, p4, p5, p6, p7) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7}) is TResult result) { return result; } @@ -784,7 +809,7 @@ public static bool Import(string resour value = (p1, p2, p3, p4, p5, p6, p7, p8) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8}) is TResult result) { return result; } @@ -810,7 +835,7 @@ public static bool Import(string re value = (p1, p2, p3, p4, p5, p6, p7, p8, p9) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9}) is TResult result) { return result; } @@ -836,7 +861,7 @@ public static bool Import(stri value = (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10}) is TResult result) { return result; } @@ -863,7 +888,7 @@ public static bool Import value = (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) => { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11}) is TResult result) + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11}) is TResult result) { return result; } @@ -890,7 +915,7 @@ public static bool Import { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12}) is TResult + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12}) is TResult result) { return result; @@ -918,7 +943,7 @@ public static bool Import { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13}) is TResult + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13}) is TResult result) { return result; @@ -946,7 +971,7 @@ public static bool Import { - if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14}) is + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14}) is TResult result) { return result; @@ -974,7 +999,7 @@ public static bool Import { - if (ImportCall(mValue, + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15}) is TResult result) { return result; @@ -1002,7 +1027,7 @@ public static bool Import { - if (ImportCall(mValue, + if (ImportCall(mValue, new object[] {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16}) is TResult result) { diff --git a/api/AltV.Net/Alt.RegisterEvents.cs b/api/AltV.Net/Alt.RegisterEvents.cs index e38127c8e..09bf3b047 100644 --- a/api/AltV.Net/Alt.RegisterEvents.cs +++ b/api/AltV.Net/Alt.RegisterEvents.cs @@ -22,6 +22,30 @@ public static void RegisterEvents(object target) ScriptFunction scriptFunction; switch (scriptEventType) { + case ScriptEventType.BaseObjectCreate: + { + scriptFunction = ScriptFunction.Create(eventMethodDelegate, + new[] { typeof(IBaseObject) }); + if (scriptFunction == null) return; + OnBaseObjectCreate += (baseObject) => + { + scriptFunction.Set(baseObject); + scriptFunction.Call(); + }; + break; + } + case ScriptEventType.BaseObjectRemove: + { + scriptFunction = ScriptFunction.Create(eventMethodDelegate, + new[] { typeof(IBaseObject) }); + if (scriptFunction == null) return; + OnBaseObjectRemove += (baseObject) => + { + scriptFunction.Set(baseObject); + scriptFunction.Call(); + }; + break; + } case ScriptEventType.Checkpoint: { scriptFunction = ScriptFunction.Create(eventMethodDelegate, diff --git a/api/AltV.Net/AltV.Net.csproj b/api/AltV.Net/AltV.Net.csproj index abb55e620..7894f91a5 100644 --- a/api/AltV.Net/AltV.Net.csproj +++ b/api/AltV.Net/AltV.Net.csproj @@ -10,8 +10,8 @@ AltMp AltV .NET Core Server Api AltMp - https://github.com/FabianTerhorst/coreclr-module - https://github.com/FabianTerhorst/coreclr-module + https://github.com/altmp/coreclr-module + https://github.com/altmp/coreclr-module git altv gta bridge gta5 gtav 1.0.0 diff --git a/api/AltV.Net/Core.Events.cs b/api/AltV.Net/Core.Events.cs index b55ce03b6..922669889 100644 --- a/api/AltV.Net/Core.Events.cs +++ b/api/AltV.Net/Core.Events.cs @@ -63,6 +63,12 @@ public partial class Core internal readonly IEventHandler PlayerDisconnectEventHandler = new HashSetEventHandler(EventType.PLAYER_DISCONNECT); + internal readonly IEventHandler BaseObjectCreateEventHandler = + new HashSetEventHandler(); + + internal readonly IEventHandler BaseObjectRemoveEventHandler = + new HashSetEventHandler(); + internal readonly IEventHandler PlayerRemoveEventHandler = new HashSetEventHandler(); @@ -2057,14 +2063,55 @@ public virtual void OnModuleLoaded(IModule module) { } - public void OnCreateBaseObject(IntPtr baseObject, BaseObjectType type, uint id) + public void OnCreateBaseObject(IntPtr baseObjectPtr, BaseObjectType type, uint id) { - PoolManager.GetOrCreate(this, baseObject, type, id); + var baseObject = PoolManager.GetOrCreate(this, baseObjectPtr, type, id); + OnCreateBaseObjectEvent(baseObject); } - public void OnRemoveBaseObject(IntPtr baseObject, BaseObjectType type) + public virtual void OnCreateBaseObjectEvent(IBaseObject baseObject) { - PoolManager.Remove(baseObject, type); + foreach (var @delegate in BaseObjectCreateEventHandler.GetEvents()) + { + try + { + @delegate(baseObject); + } + catch (TargetInvocationException exception) + { + Alt.Log("exception at event:" + "OnCreateBaseObjectEvent" + ":" + exception.InnerException); + } + catch (Exception exception) + { + Alt.Log("exception at event:" + "OnCreateBaseObjectEvent" + ":" + exception); + } + } + } + + public void OnRemoveBaseObject(IntPtr baseObjectPtr, BaseObjectType type) + { + var baseObject = PoolManager.Get(baseObjectPtr, type); + OnRemoveBaseObjectEvent(baseObject); + PoolManager.Remove(baseObjectPtr, type); + } + + public virtual void OnRemoveBaseObjectEvent(IBaseObject baseObject) + { + foreach (var @delegate in BaseObjectRemoveEventHandler.GetEvents()) + { + try + { + @delegate(baseObject); + } + catch (TargetInvocationException exception) + { + Alt.Log("exception at event:" + "OnRemoveBaseObjectEvent" + ":" + exception.InnerException); + } + catch (Exception exception) + { + Alt.Log("exception at event:" + "OnRemoveBaseObjectEvent" + ":" + exception); + } + } } public void OnPlayerRemove(IntPtr playerPointer) @@ -2633,7 +2680,7 @@ public virtual void OnPlayerStopTalkingEvent(IPlayer player) } } - public void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, IntPtr pointer, ulong size, ushort answerId) + public void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, IntPtr[] args, ushort answerId) { var target = PoolManager.Player.Get(targetpointer); if (target == null) @@ -2642,28 +2689,38 @@ public void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, return; } - var args = new IntPtr[size]; - if (pointer != IntPtr.Zero) + var length = args.Length; + var mValues = new MValueConst[length]; + for (var i = 0; i < length; i++) + { + mValues[i] = new MValueConst(this, args[i]); + } + + var objects = new object[length]; + for (var i = 0; i < length; i++) { - Marshal.Copy(pointer, args, 0, (int) size); + objects[i] = mValues[i].ToObject(); } - OnScriptRPCEvent(eventpointer, target, name, args, answerId, false); + OnScriptRPCEvent(eventpointer, target, name, objects, answerId, false); } - public virtual void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async) + public virtual void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, object[] objects, ushort answerId, bool async) { if (!UnansweredServerRpcRequest.Contains(answerId)) { UnansweredServerRpcRequest.Add(answerId); } - var mValues = MValueConst.CreateFrom(this, args); + + if (!ScriptRpcHandler.HasEvents()) return; + var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer, answerId, false); + foreach (var @delegate in ScriptRpcHandler.GetEvents()) { try { - @delegate(clientScriptRPCEvent, target, name, mValues.Select(x => x.ToObject()).ToArray(), answerId); + @delegate(clientScriptRPCEvent, target, name, objects, answerId); } catch (TargetInvocationException exception) { diff --git a/api/AltV.Net/Data/Metric.cs b/api/AltV.Net/Data/Metric.cs index cf312a55e..517f2e200 100644 --- a/api/AltV.Net/Data/Metric.cs +++ b/api/AltV.Net/Data/Metric.cs @@ -53,6 +53,7 @@ public void Begin() } } + [Obsolete("Deprecated old behavior, remove in future. Use End2")] public void End() { unsafe @@ -60,4 +61,28 @@ public void End() Core.Library.Server.Metric_End(MetricNativePointer); } } + + public void Add(ulong value) + { + unsafe + { + Core.Library.Server.Metric_Add(MetricNativePointer, value); + } + } + + public void Inc() + { + unsafe + { + Core.Library.Server.Metric_Inc(MetricNativePointer); + } + } + + public void End2() + { + unsafe + { + Core.Library.Server.Metric_End2(MetricNativePointer); + } + } } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/Checkpoint.cs b/api/AltV.Net/Elements/Entities/Checkpoint.cs index 72462469e..6a3eb4faa 100644 --- a/api/AltV.Net/Elements/Entities/Checkpoint.cs +++ b/api/AltV.Net/Elements/Entities/Checkpoint.cs @@ -251,7 +251,7 @@ public bool GetStreamSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net/Elements/Entities/Entity.cs b/api/AltV.Net/Elements/Entities/Entity.cs index db06c7f0f..50e911794 100644 --- a/api/AltV.Net/Elements/Entities/Entity.cs +++ b/api/AltV.Net/Elements/Entities/Entity.cs @@ -206,7 +206,7 @@ public bool GetStreamSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net/Elements/Entities/IMetric.cs b/api/AltV.Net/Elements/Entities/IMetric.cs index c71c27d99..39eeea0cc 100644 --- a/api/AltV.Net/Elements/Entities/IMetric.cs +++ b/api/AltV.Net/Elements/Entities/IMetric.cs @@ -9,5 +9,9 @@ public interface IMetric string Name { get; } ulong Value { get; set; } void Begin(); + [Obsolete("Deprecated old behavior, remove in future. Use End2")] void End(); + void Add(ulong value); + void Inc(); + void End2(); } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/Player.cs b/api/AltV.Net/Elements/Entities/Player.cs index dee69418d..14b6549b2 100644 --- a/api/AltV.Net/Elements/Entities/Player.cs +++ b/api/AltV.Net/Elements/Entities/Player.cs @@ -85,7 +85,7 @@ public bool GetLocalMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net/Elements/Entities/VirtualEntity.cs b/api/AltV.Net/Elements/Entities/VirtualEntity.cs index 816f2c6c3..5756f71ff 100644 --- a/api/AltV.Net/Elements/Entities/VirtualEntity.cs +++ b/api/AltV.Net/Elements/Entities/VirtualEntity.cs @@ -71,7 +71,7 @@ public bool GetStreamSyncedMetaData(string key, out T result) try { - result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + result = Utils.GetCastedMValue(mValue); return true; } catch diff --git a/api/AltV.Net/Elements/Pools/BaseObjectPool.cs b/api/AltV.Net/Elements/Pools/BaseObjectPool.cs index 90b86cfe5..787488c69 100644 --- a/api/AltV.Net/Elements/Pools/BaseObjectPool.cs +++ b/api/AltV.Net/Elements/Pools/BaseObjectPool.cs @@ -12,7 +12,10 @@ public static void SetEntityNoLongerExists(TBaseObject entity) { if (entity is not IInternalBaseObject internalEntity) return; internalEntity.Exists = false; - internalEntity.ClearData(); + if (!entity.Cached) + { + internalEntity.ClearData(); + } } private readonly Dictionary entities = new (); diff --git a/api/AltV.Net/Events/Events.cs b/api/AltV.Net/Events/Events.cs index 85e0245ce..cd9f358ea 100644 --- a/api/AltV.Net/Events/Events.cs +++ b/api/AltV.Net/Events/Events.cs @@ -27,6 +27,9 @@ public delegate void PlayerHealDelegate(IPlayer target, ushort oldHealth, ushort public delegate void PlayerDisconnectDelegate(IPlayer player, string reason); + public delegate void BaseObjectCreateDelegate(IBaseObject baseObject); + public delegate void BaseObjectRemoveDelegate(IBaseObject baseObject); + public delegate void PlayerRemoveDelegate(IPlayer player); public delegate void VehicleRemoveDelegate(IVehicle vehicle); diff --git a/api/AltV.Net/ModuleWrapper.cs b/api/AltV.Net/ModuleWrapper.cs index 0b57cbb32..e3599c85a 100644 --- a/api/AltV.Net/ModuleWrapper.cs +++ b/api/AltV.Net/ModuleWrapper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; @@ -517,9 +518,14 @@ public static void OnPlayerStopTalking(IntPtr playerpointer) _core.OnPlayerStopTalking(playerpointer); } - public static void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, IntPtr args, ulong size, ushort answerId) + public static void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, IntPtr pointer, ulong size, ushort answerId) { - _core.OnScriptRPC(eventpointer, targetpointer, name, args, size, answerId); + var args = new IntPtr[size]; + if (pointer != IntPtr.Zero) + { + Marshal.Copy(pointer, args, 0, (int) size); + } + _core.OnScriptRPC(eventpointer, targetpointer, name, args, answerId); } public static void OnScriptRPCAnswer(IntPtr targetpointer, ushort answerid, IntPtr answer, string answererror) diff --git a/api/AltV.Net/ScriptEventType.cs b/api/AltV.Net/ScriptEventType.cs index db64a4a52..2053cf95a 100644 --- a/api/AltV.Net/ScriptEventType.cs +++ b/api/AltV.Net/ScriptEventType.cs @@ -45,6 +45,8 @@ public enum ScriptEventType VehicleHorn, VehicleSiren, PlayerSpawn, - RequestSyncedScene + RequestSyncedScene, + BaseObjectCreate, + BaseObjectRemove, } } \ No newline at end of file diff --git a/runtime b/runtime index 9379dbeb3..f4327f258 160000 --- a/runtime +++ b/runtime @@ -1 +1 @@ -Subproject commit 9379dbeb3ed08b3181378fe0cf01521f8a29c2e5 +Subproject commit f4327f258168bbae9a99ec7502a61435918dfe85