Skip to content

Commit 48decda

Browse files
committed
add all weapon data getter
1 parent cef6fe3 commit 48decda

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

api/AltV.Net.CApi.Generator/TypeRegistry.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static class TypeRegistry
2222
{ "void", "void" },
2323
{ "char*", "nint" },
2424
{ "char[]", "nint" },
25+
{ "uint32_t[]", "uint[]" },
2526
{ "char*&", "nint*" },
2627
{ "char*[]", "nint[]" },
2728
{ "int*", "int*" },

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public unsafe interface IClientLibrary
131131
public delegate* unmanaged[Cdecl]<nint, void> Core_DeallocDiscordUser { get; }
132132
public delegate* unmanaged[Cdecl]<nint, nint, ClientEvents.DiscordOAuth2TokenResultModuleDelegate, void> Core_Discord_GetOAuth2Token { get; }
133133
public delegate* unmanaged[Cdecl]<nint, nint, byte> Core_DoesConfigFlagExist { get; }
134+
public delegate* unmanaged[Cdecl]<nint, uint[], ulong, void> Core_GetAllWeaponData { get; }
135+
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetAllWeaponDataCount { get; }
134136
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetAudioCount { get; }
135137
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetAudioOutputs { get; }
136138
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetAudios { get; }
@@ -865,7 +867,7 @@ public unsafe interface IClientLibrary
865867

866868
public unsafe class ClientLibrary : IClientLibrary
867869
{
868-
public readonly uint Methods = 1619;
870+
public readonly uint Methods = 1621;
869871
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
870872
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
871873
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -987,6 +989,8 @@ public unsafe class ClientLibrary : IClientLibrary
987989
public delegate* unmanaged[Cdecl]<nint, void> Core_DeallocDiscordUser { get; }
988990
public delegate* unmanaged[Cdecl]<nint, nint, ClientEvents.DiscordOAuth2TokenResultModuleDelegate, void> Core_Discord_GetOAuth2Token { get; }
989991
public delegate* unmanaged[Cdecl]<nint, nint, byte> Core_DoesConfigFlagExist { get; }
992+
public delegate* unmanaged[Cdecl]<nint, uint[], ulong, void> Core_GetAllWeaponData { get; }
993+
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetAllWeaponDataCount { get; }
990994
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetAudioCount { get; }
991995
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetAudioOutputs { get; }
992996
public delegate* unmanaged[Cdecl]<nint, ulong*, nint> Core_GetAudios { get; }
@@ -1959,6 +1963,10 @@ public unsafe class ClientLibrary : IClientLibrary
19591963
private static void Core_Discord_GetOAuth2TokenFallback(nint _core, nint _appId, ClientEvents.DiscordOAuth2TokenResultModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Core_Discord_GetOAuth2Token", "Core_Discord_GetOAuth2Token SDK method is outdated. Please update your module nuget");
19601964
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_DoesConfigFlagExistDelegate(nint _core, nint _flag);
19611965
private static byte Core_DoesConfigFlagExistFallback(nint _core, nint _flag) => throw new Exceptions.OutdatedSdkException("Core_DoesConfigFlagExist", "Core_DoesConfigFlagExist SDK method is outdated. Please update your module nuget");
1966+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetAllWeaponDataDelegate(nint _core, uint[] weaponHashes, ulong _size);
1967+
private static void Core_GetAllWeaponDataFallback(nint _core, uint[] weaponHashes, ulong _size) => throw new Exceptions.OutdatedSdkException("Core_GetAllWeaponData", "Core_GetAllWeaponData SDK method is outdated. Please update your module nuget");
1968+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetAllWeaponDataCountDelegate(nint _core);
1969+
private static ulong Core_GetAllWeaponDataCountFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetAllWeaponDataCount", "Core_GetAllWeaponDataCount SDK method is outdated. Please update your module nuget");
19621970
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetAudioCountDelegate(nint _core);
19631971
private static ulong Core_GetAudioCountFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetAudioCount", "Core_GetAudioCount SDK method is outdated. Please update your module nuget");
19641972
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetAudioOutputsDelegate(nint _core, ulong* _size);
@@ -3428,7 +3436,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
34283436
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
34293437
{
34303438
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3431-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3791551142871488314UL) Outdated = true;
3439+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11130246753470560260UL) Outdated = true;
34323440
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
34333441
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
34343442
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
@@ -3550,6 +3558,8 @@ public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35503558
Core_DeallocDiscordUser = (delegate* unmanaged[Cdecl]<nint, void>) GetUnmanagedPtr<Core_DeallocDiscordUserDelegate>(funcTable, 1212339219242517554UL, Core_DeallocDiscordUserFallback);
35513559
Core_Discord_GetOAuth2Token = (delegate* unmanaged[Cdecl]<nint, nint, ClientEvents.DiscordOAuth2TokenResultModuleDelegate, void>) GetUnmanagedPtr<Core_Discord_GetOAuth2TokenDelegate>(funcTable, 11971296438427190394UL, Core_Discord_GetOAuth2TokenFallback);
35523560
Core_DoesConfigFlagExist = (delegate* unmanaged[Cdecl]<nint, nint, byte>) GetUnmanagedPtr<Core_DoesConfigFlagExistDelegate>(funcTable, 2905154853369701790UL, Core_DoesConfigFlagExistFallback);
3561+
Core_GetAllWeaponData = (delegate* unmanaged[Cdecl]<nint, uint[], ulong, void>) GetUnmanagedPtr<Core_GetAllWeaponDataDelegate>(funcTable, 17040861123821249134UL, Core_GetAllWeaponDataFallback);
3562+
Core_GetAllWeaponDataCount = (delegate* unmanaged[Cdecl]<nint, ulong>) GetUnmanagedPtr<Core_GetAllWeaponDataCountDelegate>(funcTable, 10675436726413059015UL, Core_GetAllWeaponDataCountFallback);
35533563
Core_GetAudioCount = (delegate* unmanaged[Cdecl]<nint, ulong>) GetUnmanagedPtr<Core_GetAudioCountDelegate>(funcTable, 18419578908798121866UL, Core_GetAudioCountFallback);
35543564
Core_GetAudioOutputs = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetAudioOutputsDelegate>(funcTable, 17324382311220306947UL, Core_GetAudioOutputsFallback);
35553565
Core_GetAudios = (delegate* unmanaged[Cdecl]<nint, ulong*, nint>) GetUnmanagedPtr<Core_GetAudiosDelegate>(funcTable, 16659676766335434349UL, Core_GetAudiosFallback);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public unsafe interface IServerLibrary
430430

431431
public unsafe class ServerLibrary : IServerLibrary
432432
{
433-
public readonly uint Methods = 1619;
433+
public readonly uint Methods = 1621;
434434
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
435435
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
436436
public delegate* unmanaged[Cdecl]<nint, nint, void> Blip_AddTargetPlayer { get; }
@@ -1688,7 +1688,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
16881688
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
16891689
{
16901690
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1691-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3791551142871488314UL) Outdated = true;
1691+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11130246753470560260UL) Outdated = true;
16921692
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
16931693
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);
16941694
Blip_AddTargetPlayer = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Blip_AddTargetPlayerDelegate>(funcTable, 12411235729553386187UL, Blip_AddTargetPlayerFallback);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public unsafe interface ISharedLibrary
364364

365365
public unsafe class SharedLibrary : ISharedLibrary
366366
{
367-
public readonly uint Methods = 1619;
367+
public readonly uint Methods = 1621;
368368
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
369369
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
370370
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
@@ -1424,7 +1424,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
14241424
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
14251425
{
14261426
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1427-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 3791551142871488314UL) Outdated = true;
1427+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 11130246753470560260UL) Outdated = true;
14281428
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
14291429
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
14301430
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);

api/AltV.Net.Client/Core.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,25 @@ public IAudioAttachedOutput CreateAttachedOutput(uint categoryHash, IWorldObject
456456
return PoolManager.AudioAttachedOutput.Create(this, ptr, id);
457457
}
458458

459+
public WeaponData[] GetAllWeaponData()
460+
{
461+
unsafe
462+
{
463+
CheckIfCallIsValid();
464+
var weaponDataCount = Library.Client.Core_GetAllWeaponDataCount(NativePointer);
465+
var weaponHashes = new uint[weaponDataCount];
466+
Library.Client.Core_GetAllWeaponData(NativePointer, weaponHashes, weaponDataCount);
467+
var weaponDatas = new WeaponData[weaponDataCount];
468+
for (ulong i = 0; i < weaponDataCount; i++)
469+
{
470+
var weaponHash = weaponHashes[i];
471+
weaponDatas[i] = new WeaponData(this, weaponHash);
472+
}
473+
474+
return weaponDatas;
475+
}
476+
}
477+
459478
public IntPtr CreateObjectPtr(out uint id, uint modelHash, Position position, Rotation rotation, bool noOffset = false,
460479
bool dynamic = false, bool useStreaming = false, uint streamingDistance = 0)
461480
{

api/AltV.Net.Client/ICore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public interface ICore : ISharedCore
144144
IAudioWorldOutput CreateWorldOutput(uint categoryHash, Position pos);
145145
IAudioAttachedOutput CreateAttachedOutput(uint categoryHash, IWorldObject worldObject);
146146

147+
WeaponData[] GetAllWeaponData();
148+
147149
IntPtr CreateObjectPtr(out uint id, uint modelHash, Position position, Rotation rotation, bool noOffset = false,
148150
bool dynamic = false, bool useStreaming = false, uint streamingDistance = 0);
149151
IObject CreateObject(uint modelHash, Position position, Rotation rotation, bool noOffset = false,

runtime

0 commit comments

Comments
 (0)