Skip to content

Commit 4ea7e0d

Browse files
committed
Merge branch 'dev' into rc
2 parents 5963dfd + 1552a52 commit 4ea7e0d

File tree

35 files changed

+581
-44
lines changed

35 files changed

+581
-44
lines changed

api/AltV.Net.Async/AsyncCore.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,9 @@ await ServerStartedAsyncEventHandler.CallAsync(@delegate =>
724724
});
725725
}
726726

727-
public override void OnPlayerRequestControlEvent(IEntity target, IPlayer player)
727+
public override void OnPlayerRequestControlEvent(IntPtr eventPtr, IEntity target, IPlayer player)
728728
{
729-
base.OnPlayerRequestControlEvent(target, player);
729+
base.OnPlayerRequestControlEvent(eventPtr, target, player);
730730

731731
if (!PlayerRequestControlAsyncEventHandler.HasEvents()) return;
732732
Task.Run(async () =>
@@ -968,17 +968,35 @@ public override void OnPlayerStopTalkingEvent(IPlayer player)
968968
});
969969
}
970970

971-
public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId)
971+
public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async)
972972
{
973-
base.OnScriptRPCEvent(eventpointer, target, name, args, answerId);
973+
if (!UnansweredServerRpcRequest.Contains(answerId))
974+
{
975+
UnansweredServerRpcRequest.Add(answerId);
976+
}
977+
base.OnScriptRPCEvent(eventpointer, target, name, args, answerId, true);
978+
979+
if (UnansweredServerRpcRequest.Contains(answerId))
980+
{
981+
unsafe
982+
{
983+
Library.Shared.Event_ScriptRPCEvent_WillAnswer(eventpointer);
984+
}
985+
}
974986

975987
if (!ScriptRpcAsyncEventHandler.HasEvents()) return;
976988
Task.Run(async () =>
977989
{
978990
var mValues = MValueConst.CreateFrom(this, args);
979-
var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer);
991+
var clientScriptRPCEvent = new AsyncScriptRpcEvent(target, answerId);
980992
await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, mValues.Select(x => x.ToObject()).ToArray(), answerId));
981993
});
994+
995+
if (UnansweredServerRpcRequest.Contains(answerId))
996+
{
997+
target.EmitRPCAnswer(answerId, null, "Answer not handled");
998+
UnansweredServerRpcRequest.Remove(answerId);
999+
}
9821000
}
9831001

9841002
public override void OnScriptAnswerRPCEvent(IPlayer target, ushort answerid, IntPtr mValue, string answererror)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using AltV.Net.Elements.Entities;
3+
using AltV.Net.Shared.Elements.Entities;
4+
5+
namespace AltV.Net.Async;
6+
7+
public class AsyncScriptRpcEvent : IScriptRPCEvent
8+
{
9+
private readonly IPlayer _target;
10+
private readonly ushort _answerId;
11+
12+
public AsyncScriptRpcEvent(IPlayer target, ushort answerId)
13+
{
14+
_target = target;
15+
_answerId = answerId;
16+
}
17+
18+
public IntPtr ScriptRPCNativePointer { get; }
19+
20+
public bool WillAnswer()
21+
{
22+
return true;
23+
}
24+
25+
public bool Answer(object answer)
26+
{
27+
_target.EmitRPCAnswer(_answerId, answer, "");
28+
return true;
29+
}
30+
31+
public bool AnswerWithError(string error)
32+
{
33+
_target.EmitRPCAnswer(_answerId, null, error);
34+
return true;
35+
}
36+
}

api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,11 @@ public void EmitRPCAnswer(ushort answerId, object answer, string error)
722722
mValue.Dispose();
723723

724724
Marshal.FreeHGlobal(errorPtr);
725+
726+
if (Core.UnansweredServerRpcRequest.Contains(answerId))
727+
{
728+
Core.UnansweredServerRpcRequest.Remove(answerId);
729+
}
725730
}
726731

727732
public void EmitUnreliable(string eventName, params object[] args)
@@ -898,6 +903,15 @@ public bool SetDlcClothes(byte component, ushort drawable, byte texture, byte pa
898903
}
899904
}
900905

906+
public bool ClearClothes(byte component)
907+
{
908+
lock (Player)
909+
{
910+
if (!AsyncContext.CheckIfExistsNullable(Player)) return default;
911+
return Player.ClearClothes(component);
912+
}
913+
}
914+
901915
public Prop GetProps(byte component)
902916
{
903917
lock (Player)
@@ -1210,6 +1224,15 @@ public Rgba GetHeadBlendPaletteColor(byte id)
12101224
}
12111225
}
12121226

1227+
public void RemoveHeadBlendPaletteColor()
1228+
{
1229+
lock (Player)
1230+
{
1231+
if (!AsyncContext.CheckIfExistsNullable(Player)) return;
1232+
Player.RemoveHeadBlendPaletteColor();
1233+
}
1234+
}
1235+
12131236
public void SetHeadBlendData(uint shapeFirstID, uint shapeSecondID, uint shapeThirdID, uint skinFirstID,
12141237
uint skinSecondID, uint skinThirdID, float shapeMix, float skinMix, float thirdMix)
12151238
{

api/AltV.Net.CApi/Libraries/ClientLibrary.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public unsafe interface IClientLibrary
7272
public delegate* unmanaged[Cdecl]<nint, float, float, float, float, float, float, int, uint> AudioFilter_AddPhaserEffect { get; }
7373
public delegate* unmanaged[Cdecl]<nint, float, float, long, long, int, uint> AudioFilter_AddPitchshiftEffect { get; }
7474
public delegate* unmanaged[Cdecl]<nint, float, int, uint> AudioFilter_AddRotateEffect { get; }
75-
public delegate* unmanaged[Cdecl]<nint, float, int, uint> AudioFilter_AddVolumeEffect { get; }
75+
public delegate* unmanaged[Cdecl]<nint, float, int, int, uint> AudioFilter_AddVolumeEffect { get; }
7676
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetAudCategory { get; }
7777
public delegate* unmanaged[Cdecl]<nint, nint> AudioFilter_GetBaseObject { get; }
7878
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetHash { get; }
@@ -160,6 +160,9 @@ public unsafe interface IClientLibrary
160160
public delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void> Core_GetPedBonePos { get; }
161161
public delegate* unmanaged[Cdecl]<nint, byte, byte> Core_GetPermissionState { get; }
162162
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetPing { get; }
163+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolCount { get; }
164+
public delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void> Core_GetPoolEntities { get; }
165+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolSize { get; }
163166
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
164167
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
165168
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
@@ -886,7 +889,7 @@ public unsafe interface IClientLibrary
886889

887890
public unsafe class ClientLibrary : IClientLibrary
888891
{
889-
public readonly uint Methods = 1738;
892+
public readonly uint Methods = 1755;
890893
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
891894
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
892895
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -949,7 +952,7 @@ public unsafe class ClientLibrary : IClientLibrary
949952
public delegate* unmanaged[Cdecl]<nint, float, float, float, float, float, float, int, uint> AudioFilter_AddPhaserEffect { get; }
950953
public delegate* unmanaged[Cdecl]<nint, float, float, long, long, int, uint> AudioFilter_AddPitchshiftEffect { get; }
951954
public delegate* unmanaged[Cdecl]<nint, float, int, uint> AudioFilter_AddRotateEffect { get; }
952-
public delegate* unmanaged[Cdecl]<nint, float, int, uint> AudioFilter_AddVolumeEffect { get; }
955+
public delegate* unmanaged[Cdecl]<nint, float, int, int, uint> AudioFilter_AddVolumeEffect { get; }
953956
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetAudCategory { get; }
954957
public delegate* unmanaged[Cdecl]<nint, nint> AudioFilter_GetBaseObject { get; }
955958
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetHash { get; }
@@ -1037,6 +1040,9 @@ public unsafe class ClientLibrary : IClientLibrary
10371040
public delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void> Core_GetPedBonePos { get; }
10381041
public delegate* unmanaged[Cdecl]<nint, byte, byte> Core_GetPermissionState { get; }
10391042
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetPing { get; }
1043+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolCount { get; }
1044+
public delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void> Core_GetPoolEntities { get; }
1045+
public delegate* unmanaged[Cdecl]<nint, nint, uint> Core_GetPoolSize { get; }
10401046
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
10411047
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
10421048
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
@@ -1883,8 +1889,8 @@ public unsafe class ClientLibrary : IClientLibrary
18831889
private static uint AudioFilter_AddPitchshiftEffectFallback(nint _audioFilter, float _pitchShift, float _semitones, long _lFFTsize, long _lOsamp, int _priority) => throw new Exceptions.OutdatedSdkException("AudioFilter_AddPitchshiftEffect", "AudioFilter_AddPitchshiftEffect SDK method is outdated. Please update your module nuget");
18841890
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddRotateEffectDelegate(nint _audioFilter, float _rate, int _priority);
18851891
private static uint AudioFilter_AddRotateEffectFallback(nint _audioFilter, float _rate, int _priority) => throw new Exceptions.OutdatedSdkException("AudioFilter_AddRotateEffect", "AudioFilter_AddRotateEffect SDK method is outdated. Please update your module nuget");
1886-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddVolumeEffectDelegate(nint _audioFilter, float _volume, int _priority);
1887-
private static uint AudioFilter_AddVolumeEffectFallback(nint _audioFilter, float _volume, int _priority) => throw new Exceptions.OutdatedSdkException("AudioFilter_AddVolumeEffect", "AudioFilter_AddVolumeEffect SDK method is outdated. Please update your module nuget");
1892+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddVolumeEffectDelegate(nint _audioFilter, float _volume, int _priority, int _channel);
1893+
private static uint AudioFilter_AddVolumeEffectFallback(nint _audioFilter, float _volume, int _priority, int _channel) => throw new Exceptions.OutdatedSdkException("AudioFilter_AddVolumeEffect", "AudioFilter_AddVolumeEffect SDK method is outdated. Please update your module nuget");
18881894
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_GetAudCategoryDelegate(nint _audioFilter);
18891895
private static uint AudioFilter_GetAudCategoryFallback(nint _audioFilter) => throw new Exceptions.OutdatedSdkException("AudioFilter_GetAudCategory", "AudioFilter_GetAudCategory SDK method is outdated. Please update your module nuget");
18901896
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint AudioFilter_GetBaseObjectDelegate(nint _audioFilter);
@@ -2059,6 +2065,12 @@ public unsafe class ClientLibrary : IClientLibrary
20592065
private static byte Core_GetPermissionStateFallback(nint _core, byte _permission) => throw new Exceptions.OutdatedSdkException("Core_GetPermissionState", "Core_GetPermissionState SDK method is outdated. Please update your module nuget");
20602066
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetPingDelegate(nint _core);
20612067
private static ushort Core_GetPingFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetPing", "Core_GetPing SDK method is outdated. Please update your module nuget");
2068+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolCountDelegate(nint _core, nint _pool);
2069+
private static uint Core_GetPoolCountFallback(nint _core, nint _pool) => throw new Exceptions.OutdatedSdkException("Core_GetPoolCount", "Core_GetPoolCount SDK method is outdated. Please update your module nuget");
2070+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetPoolEntitiesDelegate(nint _core, nint _pool, nint* _poolEntities, uint* _size);
2071+
private static void Core_GetPoolEntitiesFallback(nint _core, nint _pool, nint* _poolEntities, uint* _size) => throw new Exceptions.OutdatedSdkException("Core_GetPoolEntities", "Core_GetPoolEntities SDK method is outdated. Please update your module nuget");
2072+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolSizeDelegate(nint _core, nint _pool);
2073+
private static uint Core_GetPoolSizeFallback(nint _core, nint _pool) => throw new Exceptions.OutdatedSdkException("Core_GetPoolSize", "Core_GetPoolSize SDK method is outdated. Please update your module nuget");
20622074
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetScreenResolutionDelegate(nint _core, Vector2* _out);
20632075
private static void Core_GetScreenResolutionFallback(nint _core, Vector2* _out) => throw new Exceptions.OutdatedSdkException("Core_GetScreenResolution", "Core_GetScreenResolution SDK method is outdated. Please update your module nuget");
20642076
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetServerIpDelegate(nint _core, int* _size);
@@ -3512,7 +3524,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35123524
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35133525
{
35143526
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3515-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13325244553859733034UL) Outdated = true;
3527+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 554522947139118248UL) Outdated = true;
35163528
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35173529
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35183530
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
@@ -3575,7 +3587,7 @@ public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35753587
AudioFilter_AddPhaserEffect = (delegate* unmanaged[Cdecl]<nint, float, float, float, float, float, float, int, uint>) GetUnmanagedPtr<AudioFilter_AddPhaserEffectDelegate>(funcTable, 4076092769167870615UL, AudioFilter_AddPhaserEffectFallback);
35763588
AudioFilter_AddPitchshiftEffect = (delegate* unmanaged[Cdecl]<nint, float, float, long, long, int, uint>) GetUnmanagedPtr<AudioFilter_AddPitchshiftEffectDelegate>(funcTable, 13860375026413797308UL, AudioFilter_AddPitchshiftEffectFallback);
35773589
AudioFilter_AddRotateEffect = (delegate* unmanaged[Cdecl]<nint, float, int, uint>) GetUnmanagedPtr<AudioFilter_AddRotateEffectDelegate>(funcTable, 3023765297763740660UL, AudioFilter_AddRotateEffectFallback);
3578-
AudioFilter_AddVolumeEffect = (delegate* unmanaged[Cdecl]<nint, float, int, uint>) GetUnmanagedPtr<AudioFilter_AddVolumeEffectDelegate>(funcTable, 4712013335136464389UL, AudioFilter_AddVolumeEffectFallback);
3590+
AudioFilter_AddVolumeEffect = (delegate* unmanaged[Cdecl]<nint, float, int, int, uint>) GetUnmanagedPtr<AudioFilter_AddVolumeEffectDelegate>(funcTable, 734963942086458615UL, AudioFilter_AddVolumeEffectFallback);
35793591
AudioFilter_GetAudCategory = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetAudCategoryDelegate>(funcTable, 6059317348005410766UL, AudioFilter_GetAudCategoryFallback);
35803592
AudioFilter_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<AudioFilter_GetBaseObjectDelegate>(funcTable, 8867334748367703826UL, AudioFilter_GetBaseObjectFallback);
35813593
AudioFilter_GetHash = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetHashDelegate>(funcTable, 10116851781453819636UL, AudioFilter_GetHashFallback);
@@ -3663,6 +3675,9 @@ public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
36633675
Core_GetPedBonePos = (delegate* unmanaged[Cdecl]<nint, int, ushort, Vector3*, void>) GetUnmanagedPtr<Core_GetPedBonePosDelegate>(funcTable, 9678094278922411472UL, Core_GetPedBonePosFallback);
36643676
Core_GetPermissionState = (delegate* unmanaged[Cdecl]<nint, byte, byte>) GetUnmanagedPtr<Core_GetPermissionStateDelegate>(funcTable, 6070013237365852957UL, Core_GetPermissionStateFallback);
36653677
Core_GetPing = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetPingDelegate>(funcTable, 17183361268059997356UL, Core_GetPingFallback);
3678+
Core_GetPoolCount = (delegate* unmanaged[Cdecl]<nint, nint, uint>) GetUnmanagedPtr<Core_GetPoolCountDelegate>(funcTable, 10058355141969516360UL, Core_GetPoolCountFallback);
3679+
Core_GetPoolEntities = (delegate* unmanaged[Cdecl]<nint, nint, nint*, uint*, void>) GetUnmanagedPtr<Core_GetPoolEntitiesDelegate>(funcTable, 5989408698388544472UL, Core_GetPoolEntitiesFallback);
3680+
Core_GetPoolSize = (delegate* unmanaged[Cdecl]<nint, nint, uint>) GetUnmanagedPtr<Core_GetPoolSizeDelegate>(funcTable, 3048778071876483320UL, Core_GetPoolSizeFallback);
36663681
Core_GetScreenResolution = (delegate* unmanaged[Cdecl]<nint, Vector2*, void>) GetUnmanagedPtr<Core_GetScreenResolutionDelegate>(funcTable, 16078537130538515891UL, Core_GetScreenResolutionFallback);
36673682
Core_GetServerIp = (delegate* unmanaged[Cdecl]<nint, int*, nint>) GetUnmanagedPtr<Core_GetServerIpDelegate>(funcTable, 1389091625205062844UL, Core_GetServerIpFallback);
36683683
Core_GetServerPort = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetServerPortDelegate>(funcTable, 14148467334937601992UL, Core_GetServerPortFallback);

0 commit comments

Comments
 (0)