From 7c489c69ec95a8eff99df9ecec7f4f8e52dd0093 Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Sun, 5 Jan 2025 15:05:26 +0100 Subject: [PATCH] ALTV-626 - add PlayerDimensionChangeModuleDelegate to client --- api/AltV.Net.CApi/Events/ClientEvents.cs | 84 +++++++++++++++---- api/AltV.Net.CApi/Libraries/ClientLibrary.cs | 9 +- api/AltV.Net.CApi/Libraries/ServerLibrary.cs | 4 +- api/AltV.Net.CApi/Libraries/SharedLibrary.cs | 4 +- api/AltV.Net.Client/Alt.Events.cs | 6 ++ api/AltV.Net.Client/Core.Events.cs | 15 ++++ api/AltV.Net.Client/Events/Events.cs | 1 + api/AltV.Net.Client/ModuleWrapper.cs | 5 ++ .../Runtime/CSharpResourceImpl.cs | 5 ++ 9 files changed, 109 insertions(+), 24 deletions(-) diff --git a/api/AltV.Net.CApi/Events/ClientEvents.cs b/api/AltV.Net.CApi/Events/ClientEvents.cs index e4c8822aa..5dd416e2f 100644 --- a/api/AltV.Net.CApi/Events/ClientEvents.cs +++ b/api/AltV.Net.CApi/Events/ClientEvents.cs @@ -8,86 +8,134 @@ namespace AltV.Net.CApi.ClientEvents public delegate void TickModuleDelegate(); public delegate void ClientEventModuleDelegate(string name, IntPtr args, ulong size); + public delegate void ServerEventModuleDelegate(string name, IntPtr args, ulong size); + public delegate void WebViewEventModuleDelegate(IntPtr webView, string name, IntPtr args, ulong size); + public delegate void RmlEventModuleDelegate(IntPtr rmlElement, string name, IntPtr args); + public delegate void WebSocketEventModuleDelegate(IntPtr webSocket, string name, IntPtr args, ulong size); + public delegate void AudioEventModuleDelegate(IntPtr audio, string name, IntPtr args, ulong size); - public delegate void ConsoleCommandModuleDelegate(string name, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize); + + public delegate void ConsoleCommandModuleDelegate(string name, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize); public delegate void PlayerSpawnModuleDelegate(); + public delegate void PlayerDisconnectModuleDelegate(); + 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 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 PlayerDimensionChangeModuleDelegate(IntPtr pointer, BaseObjectType type, int oldDim, + int newDim); + public delegate void PlayerWeaponShootModuleDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip); + public delegate void PlayerWeaponChangeModuleDelegate(uint oldWeapon, uint newWeapon); 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); + public delegate void AnyResourceStopModuleDelegate(string name); public delegate void KeyDownModuleDelegate(uint key); + public delegate void KeyUpModuleDelegate(uint key); public delegate void ScreenshotResultModuleDelegate(IntPtr strPtr); - public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues, int headerSize); + + public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues, + int headerSize); public delegate void ConnectionCompleteModuleDelegate(); public delegate void GlobalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); + public delegate void GlobalSyncedMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); public delegate void LocalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); - public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); - public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); - public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); + + public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, + IntPtr value, IntPtr oldValue); + + public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, + IntPtr oldValue); + + public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, + IntPtr oldValue); public delegate void TaskChangeModuleDelegate(int oldTask, int newTask); public delegate void WindowFocusChangeModuleDelegate(byte state); + public delegate void WindowResolutionChangeModuleDelegate(Vector2 oldResolution, Vector2 newResolution); - public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type, Position oldPosition); + public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type, + Position oldPosition); + public delegate void WorldObjectStreamInModuleDelegate(IntPtr target, BaseObjectType type); + public delegate void WorldObjectStreamOutModuleDelegate(IntPtr target, BaseObjectType type); - public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner, IntPtr oldOwner); + public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner, + IntPtr oldOwner); public delegate void DiscordOAuth2TokenResultModuleDelegate(byte success, string token); public delegate void WeaponDamageModuleDelegate(IntPtr eventPointer, IntPtr entityPointer, - BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart, IntPtr sourceEntityPointer, + BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart, + IntPtr sourceEntityPointer, BaseObjectType sourceEntityType); public delegate void CreateBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type, uint id); public delegate void RemoveBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type); - public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType, + public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, + BaseObjectType entityType, byte state); - public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType, + + public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, + BaseObjectType entityType, byte state); - public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, IntPtr damagerPointer, + public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, + IntPtr damagerPointer, BaseObjectType damagerType, uint weaponHash); - 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 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); public delegate void VoiceConnectionModuleDelegate(VoiceConnectionState state); - public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size, ushort answerId); + public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size, + ushort answerId); public delegate void ScriptRPCAnswerModuleDelegate(ushort answerId, IntPtr answer, string answerError); -} \ No newline at end of file +} diff --git a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs index 643568c6c..46b6978a6 100644 --- a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs @@ -300,6 +300,7 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Event_SetPlayerChangeAnimationDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeInteriorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeVehicleSeatDelegate { get; } + public delegate* unmanaged[Cdecl] Event_SetPlayerDimensionChangeDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerDisconnectDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerEnterVehicleDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerLeaveVehicleDelegate { get; } @@ -938,7 +939,7 @@ public unsafe interface IClientLibrary public unsafe class ClientLibrary : IClientLibrary { - public readonly uint Methods = 1811; + public readonly uint Methods = 1812; public delegate* unmanaged[Cdecl] Audio_AddOutput { get; } public delegate* unmanaged[Cdecl] Audio_GetBaseObject { get; } public delegate* unmanaged[Cdecl] Audio_GetCurrentTime { get; } @@ -1228,6 +1229,7 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Event_SetPlayerChangeAnimationDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeInteriorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeVehicleSeatDelegate { get; } + public delegate* unmanaged[Cdecl] Event_SetPlayerDimensionChangeDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerDisconnectDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerEnterVehicleDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerLeaveVehicleDelegate { get; } @@ -2440,6 +2442,8 @@ public unsafe class ClientLibrary : IClientLibrary private static void Event_SetPlayerChangeInteriorDelegateFallback(nint _resource, ClientEvents.PlayerChangeInteriorModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerChangeInteriorDelegate", "Event_SetPlayerChangeInteriorDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerChangeVehicleSeatDelegateDelegate(nint _resource, ClientEvents.PlayerChangeVehicleSeatModuleDelegate _delegate); private static void Event_SetPlayerChangeVehicleSeatDelegateFallback(nint _resource, ClientEvents.PlayerChangeVehicleSeatModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerChangeVehicleSeatDelegate", "Event_SetPlayerChangeVehicleSeatDelegate SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerDimensionChangeDelegateDelegate(nint _resource, ClientEvents.PlayerDimensionChangeModuleDelegate _delegate); + private static void Event_SetPlayerDimensionChangeDelegateFallback(nint _resource, ClientEvents.PlayerDimensionChangeModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerDimensionChangeDelegate", "Event_SetPlayerDimensionChangeDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerDisconnectDelegateDelegate(nint _resource, ClientEvents.PlayerDisconnectModuleDelegate _delegate); private static void Event_SetPlayerDisconnectDelegateFallback(nint _resource, ClientEvents.PlayerDisconnectModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerDisconnectDelegate", "Event_SetPlayerDisconnectDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerEnterVehicleDelegateDelegate(nint _resource, ClientEvents.PlayerEnterVehicleModuleDelegate _delegate); @@ -3717,7 +3721,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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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); @@ -4007,6 +4011,7 @@ public ClientLibrary(Dictionary funcTable) Event_SetPlayerChangeAnimationDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1013031841840963141UL, Event_SetPlayerChangeAnimationDelegateFallback); Event_SetPlayerChangeInteriorDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10641081887455190199UL, Event_SetPlayerChangeInteriorDelegateFallback); Event_SetPlayerChangeVehicleSeatDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2849447755791784577UL, Event_SetPlayerChangeVehicleSeatDelegateFallback); + Event_SetPlayerDimensionChangeDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12559962844846581925UL, Event_SetPlayerDimensionChangeDelegateFallback); Event_SetPlayerDisconnectDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11526105887646755055UL, Event_SetPlayerDisconnectDelegateFallback); Event_SetPlayerEnterVehicleDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16259534399403863387UL, Event_SetPlayerEnterVehicleDelegateFallback); Event_SetPlayerLeaveVehicleDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10354256863799375649UL, Event_SetPlayerLeaveVehicleDelegateFallback); diff --git a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs index 40c34383f..1a55c66a3 100644 --- a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs @@ -490,7 +490,7 @@ public unsafe interface IServerLibrary public unsafe class ServerLibrary : IServerLibrary { - public readonly uint Methods = 1811; + public readonly uint Methods = 1812; public delegate* unmanaged[Cdecl] BaseObject_DeleteSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetMultipleSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetSyncedMetaData { get; } @@ -1925,7 +1925,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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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); diff --git a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs index c503b1121..31b99f135 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 = 1811; + public readonly uint Methods = 1812; 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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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/Alt.Events.cs b/api/AltV.Net.Client/Alt.Events.cs index 299425df1..24253df13 100644 --- a/api/AltV.Net.Client/Alt.Events.cs +++ b/api/AltV.Net.Client/Alt.Events.cs @@ -182,6 +182,12 @@ public static event PlayerChangeInteriorDelegate OnPlayerChangeInterior remove => ((Core)CoreImpl).PlayerChangeInteriorEventHandler.Remove(value); } + public static event PlayerDimensionChangeDelegate OnPlayerDimensionChange + { + add => ((Core)CoreImpl).PlayerDimensionChangeEventHandler.Add(value); + remove => ((Core)CoreImpl).PlayerDimensionChangeEventHandler.Remove(value); + } + public static event WeaponDamageDelegate OnWeaponDamage { add => ((Core)CoreImpl).WeaponDamageEventHandler.Add(value); diff --git a/api/AltV.Net.Client/Core.Events.cs b/api/AltV.Net.Client/Core.Events.cs index cb5c232d0..6b92f782d 100644 --- a/api/AltV.Net.Client/Core.Events.cs +++ b/api/AltV.Net.Client/Core.Events.cs @@ -114,6 +114,9 @@ public virtual IEnumerable GetRegisteredServerEvents() internal readonly IEventHandler PlayerChangeInteriorEventHandler = new HashSetEventHandler(EventType.PLAYER_CHANGE_INTERIOR_EVENT); + internal readonly IEventHandler PlayerDimensionChangeEventHandler = + new HashSetEventHandler(EventType.PLAYER_DIMENSION_CHANGE); + internal readonly IEventHandler PlayerWeaponShootEventHandler = new HashSetEventHandler(EventType.PLAYER_WEAPON_SHOOT_EVENT); @@ -368,6 +371,18 @@ public void OnPlayerChangeInterior(IntPtr playerPtr, BaseObjectType type, uint o PlayerChangeInteriorEventHandler.GetEvents().ForEachCatching(fn => fn(player, oldIntLoc, newIntLoc), $"event {nameof(OnPlayerChangeInterior)}"); } + public void OnPlayerDimensionChange(IntPtr playerPtr, BaseObjectType type, int oldDim, int newDim) + { + var player = (IPlayer)PoolManager.Get(playerPtr, type); + if (player == null) + { + Alt.LogWarning("OnPlayerDimensionChange: Invalid player " + playerPtr); + return; + } + + PlayerDimensionChangeEventHandler.GetEvents().ForEachCatching(fn => fn(player, oldDim, newDim), $"event {nameof(OnPlayerDimensionChange)}"); + } + public void OnPlayerWeaponShoot(uint weapon, ushort totalAmmo, ushort ammoInClip) { PlayerWeaponShootEventHandler.GetEvents().ForEachCatching(fn => fn(weapon, totalAmmo, ammoInClip), $"event {nameof(OnPlayerWeaponShoot)}"); diff --git a/api/AltV.Net.Client/Events/Events.cs b/api/AltV.Net.Client/Events/Events.cs index 66968dc45..23787f75a 100644 --- a/api/AltV.Net.Client/Events/Events.cs +++ b/api/AltV.Net.Client/Events/Events.cs @@ -17,6 +17,7 @@ namespace AltV.Net.Client.Events public delegate void PlayerChangeVehicleSeatDelegate(IVehicle vehicle, byte oldSeat, byte newSeat); public delegate void PlayerChangeAnimationDelegate(IPlayer player, uint oldDict, uint newDict, uint oldName, uint newName); public delegate void PlayerChangeInteriorDelegate(IPlayer player, uint oldIntLoc, uint newIntLoc); + public delegate void PlayerDimensionChangeDelegate(IPlayer player, int oldDim, int newDim); public delegate void PlayerWeaponShootDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip); public delegate void PlayerWeaponChangeDelegate(uint oldWeapon, uint newWeapon); public delegate void PlayerLeaveVehicleDelegate(IVehicle vehicle, byte seat); diff --git a/api/AltV.Net.Client/ModuleWrapper.cs b/api/AltV.Net.Client/ModuleWrapper.cs index 0279d30db..74d9d6fd1 100644 --- a/api/AltV.Net.Client/ModuleWrapper.cs +++ b/api/AltV.Net.Client/ModuleWrapper.cs @@ -338,6 +338,11 @@ public static void OnPlayerChangeInterior(IntPtr player, BaseObjectType type, ui _core.OnPlayerChangeInterior(player, type, oldIntLoc, newIntLoc); } + public static void OnPlayerDimensionChange(IntPtr player, BaseObjectType type, int oldDim, int newDim) + { + _core.OnPlayerDimensionChange(player, type, oldDim, newDim); + } + public static void OnPlayerWeaponShoot(uint weapon, ushort totalAmmo, ushort ammoInClip) { _core.OnPlayerWeaponShoot(weapon, totalAmmo, ammoInClip); diff --git a/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs b/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs index dbfbfd5e8..fd8f9dd12 100644 --- a/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs +++ b/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs @@ -1,5 +1,6 @@ using System.Runtime.InteropServices; using AltV.Net.CApi.ClientEvents; +using AltV.Net.Native; using AltV.Net.Shared; namespace AltV.Net.Client.Runtime @@ -216,6 +217,10 @@ internal void SetDelegates() ScriptRPCAnswerModuleDelegate onScriptRPCAnswer = ModuleWrapper.OnScriptRPCAnswer; handles.AddFirst(GCHandle.Alloc(onScriptRPCAnswer)); core.Library.Client.Event_SetScriptRPCAnswerDelegate(this.NativePointer, onScriptRPCAnswer); + + PlayerDimensionChangeModuleDelegate onPlayerDimensionChange = ModuleWrapper.OnPlayerDimensionChange; + handles.AddFirst(GCHandle.Alloc(onPlayerDimensionChange)); + core.Library.Client.Event_SetPlayerDimensionChangeDelegate(this.NativePointer, onPlayerDimensionChange); } }