Skip to content

Commit 5fbab47

Browse files
committed
Added GetLoadedVehicleModels
1 parent 521e927 commit 5fbab47

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public unsafe interface IClientLibrary
886886

887887
public unsafe class ClientLibrary : IClientLibrary
888888
{
889-
public readonly uint Methods = 1728;
889+
public readonly uint Methods = 1729;
890890
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
891891
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
892892
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -3512,7 +3512,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35123512
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35133513
{
35143514
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3515-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 557522308693843528UL) Outdated = true;
3515+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17234525495073991761UL) Outdated = true;
35163516
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35173517
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35183518
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public unsafe interface IServerLibrary
7070
public delegate* unmanaged[Cdecl]<nint, int, ulong, ulong> Core_GetEntitiesInDimensionCount { get; }
7171
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, nint[], byte[], ulong, void> Core_GetEntitiesInRange { get; }
7272
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, ulong> Core_GetEntitiesInRangeCount { get; }
73+
public delegate* unmanaged[Cdecl]<nint, nint*, ulong*, void> Core_GetLoadedVehicleModels { get; }
7374
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingObjects { get; }
7475
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingPeds { get; }
7576
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingVehicles { get; }
@@ -472,7 +473,7 @@ public unsafe interface IServerLibrary
472473

473474
public unsafe class ServerLibrary : IServerLibrary
474475
{
475-
public readonly uint Methods = 1728;
476+
public readonly uint Methods = 1729;
476477
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
477478
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
478479
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
@@ -533,6 +534,7 @@ public unsafe class ServerLibrary : IServerLibrary
533534
public delegate* unmanaged[Cdecl]<nint, int, ulong, ulong> Core_GetEntitiesInDimensionCount { get; }
534535
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, nint[], byte[], ulong, void> Core_GetEntitiesInRange { get; }
535536
public delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, ulong> Core_GetEntitiesInRangeCount { get; }
537+
public delegate* unmanaged[Cdecl]<nint, nint*, ulong*, void> Core_GetLoadedVehicleModels { get; }
536538
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingObjects { get; }
537539
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingPeds { get; }
538540
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetMaxStreamingVehicles { get; }
@@ -1051,6 +1053,8 @@ public unsafe class ServerLibrary : IServerLibrary
10511053
private static void Core_GetEntitiesInRangeFallback(nint _core, Vector3 _position, int _range, int _dimension, ulong _allowedTypes, nint[] entities, byte[] types, ulong _size) => throw new Exceptions.OutdatedSdkException("Core_GetEntitiesInRange", "Core_GetEntitiesInRange SDK method is outdated. Please update your module nuget");
10521054
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetEntitiesInRangeCountDelegate(nint _core, Vector3 _position, int _range, int _dimension, ulong _allowedTypes);
10531055
private static ulong Core_GetEntitiesInRangeCountFallback(nint _core, Vector3 _position, int _range, int _dimension, ulong _allowedTypes) => throw new Exceptions.OutdatedSdkException("Core_GetEntitiesInRangeCount", "Core_GetEntitiesInRangeCount SDK method is outdated. Please update your module nuget");
1056+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetLoadedVehicleModelsDelegate(nint _core, nint* _loadedVehicleModelsOut, ulong* _size);
1057+
private static void Core_GetLoadedVehicleModelsFallback(nint _core, nint* _loadedVehicleModelsOut, ulong* _size) => throw new Exceptions.OutdatedSdkException("Core_GetLoadedVehicleModels", "Core_GetLoadedVehicleModels SDK method is outdated. Please update your module nuget");
10541058
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetMaxStreamingObjectsDelegate(nint _core);
10551059
private static ushort Core_GetMaxStreamingObjectsFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetMaxStreamingObjects", "Core_GetMaxStreamingObjects SDK method is outdated. Please update your module nuget");
10561060
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetMaxStreamingPedsDelegate(nint _core);
@@ -1856,7 +1860,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
18561860
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
18571861
{
18581862
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1859-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 557522308693843528UL) Outdated = true;
1863+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17234525495073991761UL) Outdated = true;
18601864
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
18611865
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
18621866
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);
@@ -1917,6 +1921,7 @@ public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
19171921
Core_GetEntitiesInDimensionCount = (delegate* unmanaged[Cdecl]<nint, int, ulong, ulong>) GetUnmanagedPtr<Core_GetEntitiesInDimensionCountDelegate>(funcTable, 12784287737200780200UL, Core_GetEntitiesInDimensionCountFallback);
19181922
Core_GetEntitiesInRange = (delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, nint[], byte[], ulong, void>) GetUnmanagedPtr<Core_GetEntitiesInRangeDelegate>(funcTable, 12414549446254212526UL, Core_GetEntitiesInRangeFallback);
19191923
Core_GetEntitiesInRangeCount = (delegate* unmanaged[Cdecl]<nint, Vector3, int, int, ulong, ulong>) GetUnmanagedPtr<Core_GetEntitiesInRangeCountDelegate>(funcTable, 6795936790869684439UL, Core_GetEntitiesInRangeCountFallback);
1924+
Core_GetLoadedVehicleModels = (delegate* unmanaged[Cdecl]<nint, nint*, ulong*, void>) GetUnmanagedPtr<Core_GetLoadedVehicleModelsDelegate>(funcTable, 5931751806478777368UL, Core_GetLoadedVehicleModelsFallback);
19201925
Core_GetMaxStreamingObjects = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetMaxStreamingObjectsDelegate>(funcTable, 3581368898059030296UL, Core_GetMaxStreamingObjectsFallback);
19211926
Core_GetMaxStreamingPeds = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetMaxStreamingPedsDelegate>(funcTable, 6049887365767315904UL, Core_GetMaxStreamingPedsFallback);
19221927
Core_GetMaxStreamingVehicles = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetMaxStreamingVehiclesDelegate>(funcTable, 17973186281360658901UL, Core_GetMaxStreamingVehiclesFallback);

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

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

411411
public unsafe class SharedLibrary : ISharedLibrary
412412
{
413-
public readonly uint Methods = 1728;
413+
public readonly uint Methods = 1729;
414414
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
415415
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
416416
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
@@ -1608,7 +1608,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
16081608
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
16091609
{
16101610
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1611-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 557522308693843528UL) Outdated = true;
1611+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 17234525495073991761UL) Outdated = true;
16121612
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
16131613
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
16141614
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);

api/AltV.Net/Core.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,32 @@ public byte SyncSendThreadCount
16801680
}
16811681
}
16821682

1683+
public uint[] LoadedVehicleModels
1684+
{
1685+
get
1686+
{
1687+
unsafe
1688+
{
1689+
var ptr = IntPtr.Zero;
1690+
ulong size = 0;
1691+
Library.Server.Core_GetLoadedVehicleModels(NativePointer, &ptr, &size);
1692+
1693+
var uintArray = new UIntArray
1694+
{
1695+
data = ptr,
1696+
size = size,
1697+
capacity = size
1698+
};
1699+
1700+
var result = uintArray.ToArray();
1701+
1702+
Library.Shared.FreeUInt32Array(ptr);
1703+
1704+
return result;
1705+
}
1706+
}
1707+
}
1708+
16831709
public IReadOnlyCollection<IMetric> GetAllMetrics()
16841710
{
16851711
return metricCache.Values.ToList();

api/AltV.Net/ICore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,7 @@ IBaseObject[] GetClosestEntities(Position position, int range, int dimension, in
220220
uint MigrationTickRate { get; set; }
221221
byte SyncReceiveThreadCount { get; set; }
222222
byte SyncSendThreadCount { get; set; }
223+
224+
uint[] LoadedVehicleModels { get; }
223225
}
224226
}

runtime

0 commit comments

Comments
 (0)