Skip to content

Commit 09c0b12

Browse files
committed
feat(client): server time getter
1 parent 7b47b8d commit 09c0b12

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public unsafe interface IClientLibrary
168168
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
169169
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
170170
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
171+
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetServerTime { get; }
171172
public delegate* unmanaged[Cdecl]<nint, nint, byte> Core_GetStatBool { get; }
172173
public delegate* unmanaged[Cdecl]<nint, nint, nint> Core_GetStatData { get; }
173174
public delegate* unmanaged[Cdecl]<nint, nint, float> Core_GetStatFloat { get; }
@@ -901,7 +902,7 @@ public unsafe interface IClientLibrary
901902

902903
public unsafe class ClientLibrary : IClientLibrary
903904
{
904-
public readonly uint Methods = 1769;
905+
public readonly uint Methods = 1770;
905906
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
906907
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
907908
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
@@ -1059,6 +1060,7 @@ public unsafe class ClientLibrary : IClientLibrary
10591060
public delegate* unmanaged[Cdecl]<nint, Vector2*, void> Core_GetScreenResolution { get; }
10601061
public delegate* unmanaged[Cdecl]<nint, int*, nint> Core_GetServerIp { get; }
10611062
public delegate* unmanaged[Cdecl]<nint, ushort> Core_GetServerPort { get; }
1063+
public delegate* unmanaged[Cdecl]<nint, ulong> Core_GetServerTime { get; }
10621064
public delegate* unmanaged[Cdecl]<nint, nint, byte> Core_GetStatBool { get; }
10631065
public delegate* unmanaged[Cdecl]<nint, nint, nint> Core_GetStatData { get; }
10641066
public delegate* unmanaged[Cdecl]<nint, nint, float> Core_GetStatFloat { get; }
@@ -2102,6 +2104,8 @@ public unsafe class ClientLibrary : IClientLibrary
21022104
private static nint Core_GetServerIpFallback(nint _core, int* _size) => throw new Exceptions.OutdatedSdkException("Core_GetServerIp", "Core_GetServerIp SDK method is outdated. Please update your module nuget");
21032105
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetServerPortDelegate(nint _core);
21042106
private static ushort Core_GetServerPortFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetServerPort", "Core_GetServerPort SDK method is outdated. Please update your module nuget");
2107+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetServerTimeDelegate(nint _core);
2108+
private static ulong Core_GetServerTimeFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetServerTime", "Core_GetServerTime SDK method is outdated. Please update your module nuget");
21052109
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetStatBoolDelegate(nint _core, nint _stat);
21062110
private static byte Core_GetStatBoolFallback(nint _core, nint _stat) => throw new Exceptions.OutdatedSdkException("Core_GetStatBool", "Core_GetStatBool SDK method is outdated. Please update your module nuget");
21072111
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetStatDataDelegate(nint _core, nint _stat);
@@ -3569,7 +3573,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
35693573
public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
35703574
{
35713575
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
3572-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 12612033657027659340UL) Outdated = true;
3576+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true;
35733577
Audio_AddOutput = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<Audio_AddOutputDelegate>(funcTable, 9914412815391408844UL, Audio_AddOutputFallback);
35743578
Audio_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<Audio_GetBaseObjectDelegate>(funcTable, 6330360502401226894UL, Audio_GetBaseObjectFallback);
35753579
Audio_GetCurrentTime = (delegate* unmanaged[Cdecl]<nint, double>) GetUnmanagedPtr<Audio_GetCurrentTimeDelegate>(funcTable, 2944324482134975819UL, Audio_GetCurrentTimeFallback);
@@ -3727,6 +3731,7 @@ public ClientLibrary(Dictionary<ulong, IntPtr> funcTable)
37273731
Core_GetScreenResolution = (delegate* unmanaged[Cdecl]<nint, Vector2*, void>) GetUnmanagedPtr<Core_GetScreenResolutionDelegate>(funcTable, 16078537130538515891UL, Core_GetScreenResolutionFallback);
37283732
Core_GetServerIp = (delegate* unmanaged[Cdecl]<nint, int*, nint>) GetUnmanagedPtr<Core_GetServerIpDelegate>(funcTable, 1389091625205062844UL, Core_GetServerIpFallback);
37293733
Core_GetServerPort = (delegate* unmanaged[Cdecl]<nint, ushort>) GetUnmanagedPtr<Core_GetServerPortDelegate>(funcTable, 14148467334937601992UL, Core_GetServerPortFallback);
3734+
Core_GetServerTime = (delegate* unmanaged[Cdecl]<nint, ulong>) GetUnmanagedPtr<Core_GetServerTimeDelegate>(funcTable, 8910809418132103019UL, Core_GetServerTimeFallback);
37303735
Core_GetStatBool = (delegate* unmanaged[Cdecl]<nint, nint, byte>) GetUnmanagedPtr<Core_GetStatBoolDelegate>(funcTable, 4132285709171755304UL, Core_GetStatBoolFallback);
37313736
Core_GetStatData = (delegate* unmanaged[Cdecl]<nint, nint, nint>) GetUnmanagedPtr<Core_GetStatDataDelegate>(funcTable, 311843349031918009UL, Core_GetStatDataFallback);
37323737
Core_GetStatFloat = (delegate* unmanaged[Cdecl]<nint, nint, float>) GetUnmanagedPtr<Core_GetStatFloatDelegate>(funcTable, 175428875067811253UL, Core_GetStatFloatFallback);

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

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

486486
public unsafe class ServerLibrary : IServerLibrary
487487
{
488-
public readonly uint Methods = 1769;
488+
public readonly uint Methods = 1770;
489489
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
490490
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
491491
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
@@ -1905,7 +1905,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
19051905
public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
19061906
{
19071907
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1908-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 12612033657027659340UL) Outdated = true;
1908+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true;
19091909
BaseObject_DeleteSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<BaseObject_DeleteSyncedMetaDataDelegate>(funcTable, 8228424877092269355UL, BaseObject_DeleteSyncedMetaDataFallback);
19101910
BaseObject_SetMultipleSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void>) GetUnmanagedPtr<BaseObject_SetMultipleSyncedMetaDataDelegate>(funcTable, 1390762125822890831UL, BaseObject_SetMultipleSyncedMetaDataFallback);
19111911
BaseObject_SetSyncedMetaData = (delegate* unmanaged[Cdecl]<nint, nint, nint, void>) GetUnmanagedPtr<BaseObject_SetSyncedMetaDataDelegate>(funcTable, 8002999088966424231UL, BaseObject_SetSyncedMetaDataFallback);

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

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

427427
public unsafe class SharedLibrary : ISharedLibrary
428428
{
429-
public readonly uint Methods = 1769;
429+
public readonly uint Methods = 1770;
430430
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
431431
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
432432
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
@@ -1669,7 +1669,7 @@ private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong ha
16691669
public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
16701670
{
16711671
if (!funcTable.TryGetValue(0, out var capiHash)) Outdated = true;
1672-
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 12612033657027659340UL) Outdated = true;
1672+
else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) Outdated = true;
16731673
Audio_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<Audio_GetIDDelegate>(funcTable, 4464042055475980737UL, Audio_GetIDFallback);
16741674
AudioAttachedOutput_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioAttachedOutput_GetIDDelegate>(funcTable, 17725794901805112189UL, AudioAttachedOutput_GetIDFallback);
16751675
AudioFilter_GetID = (delegate* unmanaged[Cdecl]<nint, uint>) GetUnmanagedPtr<AudioFilter_GetIDDelegate>(funcTable, 8824535635529306325UL, AudioFilter_GetIDFallback);

api/AltV.Net.Client/Alt.Globals.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,7 @@ public static partial class Alt
118118
public static bool RmlControlsEnabled { get => Core.RmlControlsEnabled; set => Core.RmlControlsEnabled = value; }
119119
public static bool VoiceControlsEnabled { get => Core.VoiceControlsEnabled; set => Core.VoiceControlsEnabled = value; }
120120
public static int MsPerGameMinute { get => Core.MsPerGameMinute; set => Core.MsPerGameMinute = value; }
121+
122+
public static ulong ServerTime => Core.ServerTime;
121123
}
122124
}

api/AltV.Net.Client/Core.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,17 @@ public void UpdateClipContext(Dictionary<string, string> context)
732732
}
733733
}
734734

735+
public ulong ServerTime
736+
{
737+
get
738+
{
739+
unsafe
740+
{
741+
return this.Library.Client.Core_GetServerTime(NativePointer);
742+
}
743+
}
744+
}
745+
735746
#endregion
736747

737748
#region TriggerServerEvent

api/AltV.Net.Client/ICore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,7 @@ ILocalObject CreateLocalObject(uint modelHash, Position position, Rotation rotat
229229
IAudioFilter GetVoiceFilter(uint playerRemoteId);
230230

231231
void UpdateClipContext(Dictionary<string, string> context);
232+
233+
ulong ServerTime { get; }
232234
}
233235
}

runtime

0 commit comments

Comments
 (0)