diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8cbd648c8..e7ca8d6dca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ on: push: tags: - '*.*.*' - - '*.*.*-*' + - '*.*.*-*.*' jobs: fetch-nethost-linux: runs-on: ubuntu-22.04 diff --git a/api/AltV.Net.Async/AltAsync.Vehicle.cs b/api/AltV.Net.Async/AltAsync.Vehicle.cs index d8d9e76b72..cf6eeb493f 100644 --- a/api/AltV.Net.Async/AltAsync.Vehicle.cs +++ b/api/AltV.Net.Async/AltAsync.Vehicle.cs @@ -22,18 +22,6 @@ public static Task CreateVehicle(VehicleModel model, Position pos, Rot public static Task CreateVehicle(string model, Position pos, Rotation rot, uint streamingDistance = 0) => CreateVehicle(Alt.Hash(model), pos, rot, streamingDistance); - [Obsolete("Use AltAsync.CreateVehicle or Alt.CreateVehicle instead")] - public static IVehicleBuilder CreateVehicleBuilder(uint model, Position pos, Rotation rot) => - new VehicleBuilder(model, pos, rot); - - [Obsolete("Use AltAsync.CreateVehicle or Alt.CreateVehicle instead")] - public static IVehicleBuilder CreateVehicleBuilder(VehicleModel model, Position pos, Rotation rot) => - new VehicleBuilder((uint) model, pos, rot); - - [Obsolete("Use AltAsync.CreateVehicle or Alt.CreateVehicle instead")] - public static IVehicleBuilder CreateVehicleBuilder(string model, Position pos, Rotation rot) => - new VehicleBuilder(Alt.Hash(model), pos, rot); - [Obsolete("Use async entities instead")] public static Task GetDriverAsync(this IVehicle vehicle) => AltVAsync.Schedule(() => !vehicle.Exists ? null : vehicle.Driver); diff --git a/api/AltV.Net.Async/AsyncCore.cs b/api/AltV.Net.Async/AsyncCore.cs index 92c5fcece2..84305b97c8 100644 --- a/api/AltV.Net.Async/AsyncCore.cs +++ b/api/AltV.Net.Async/AsyncCore.cs @@ -724,9 +724,9 @@ await ServerStartedAsyncEventHandler.CallAsync(@delegate => }); } - public override void OnPlayerRequestControlEvent(IEntity target, IPlayer player) + public override void OnPlayerRequestControlEvent(IntPtr eventPtr, IEntity target, IPlayer player) { - base.OnPlayerRequestControlEvent(target, player); + base.OnPlayerRequestControlEvent(eventPtr, target, player); if (!PlayerRequestControlAsyncEventHandler.HasEvents()) return; Task.Run(async () => @@ -869,14 +869,14 @@ public override void OnGivePedScriptedTaskEvent(IntPtr eventPointer, IPlayer sou } public override void OnPlayerConnectDeniedEvent(PlayerConnectDeniedReason reason, string name, string ip, ulong passwordHash, - bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId) + bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId) { - base.OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, discordId); + base.OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId); if (!PlayerConnectDeniedAsyncEventHandler.HasEvents()) return; Task.Run(async () => { - await PlayerConnectDeniedAsyncEventHandler.CallAsync(@delegate => @delegate(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, discordId)); + await PlayerConnectDeniedAsyncEventHandler.CallAsync(@delegate => @delegate(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId)); }); } @@ -968,17 +968,35 @@ public override void OnPlayerStopTalkingEvent(IPlayer player) }); } - public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId) + public override void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async) { - base.OnScriptRPCEvent(eventpointer, target, name, args, answerId); + if (!UnansweredServerRpcRequest.Contains(answerId)) + { + UnansweredServerRpcRequest.Add(answerId); + } + base.OnScriptRPCEvent(eventpointer, target, name, args, answerId, true); + + if (UnansweredServerRpcRequest.Contains(answerId)) + { + unsafe + { + Library.Shared.Event_ScriptRPCEvent_WillAnswer(eventpointer); + } + } if (!ScriptRpcAsyncEventHandler.HasEvents()) return; Task.Run(async () => { var mValues = MValueConst.CreateFrom(this, args); - var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer); + var clientScriptRPCEvent = new AsyncScriptRpcEvent(target, answerId); await ScriptRpcAsyncEventHandler.CallAsync(@delegate => @delegate(clientScriptRPCEvent, target, name, mValues.Select(x => x.ToObject()).ToArray(), answerId)); }); + + if (UnansweredServerRpcRequest.Contains(answerId)) + { + target.EmitRPCAnswer(answerId, null, "Answer not handled"); + UnansweredServerRpcRequest.Remove(answerId); + } } public override void OnScriptAnswerRPCEvent(IPlayer target, ushort answerid, IntPtr mValue, string answererror) diff --git a/api/AltV.Net.Async/AsyncScriptRpcEvent.cs b/api/AltV.Net.Async/AsyncScriptRpcEvent.cs new file mode 100644 index 0000000000..aa8c262b96 --- /dev/null +++ b/api/AltV.Net.Async/AsyncScriptRpcEvent.cs @@ -0,0 +1,36 @@ +using System; +using AltV.Net.Elements.Entities; +using AltV.Net.Shared.Elements.Entities; + +namespace AltV.Net.Async; + +public class AsyncScriptRpcEvent : IScriptRPCEvent +{ + private readonly IPlayer _target; + private readonly ushort _answerId; + + public AsyncScriptRpcEvent(IPlayer target, ushort answerId) + { + _target = target; + _answerId = answerId; + } + + public IntPtr ScriptRPCNativePointer { get; } + + public bool WillAnswer() + { + return true; + } + + public bool Answer(object answer) + { + _target.EmitRPCAnswer(_answerId, answer, ""); + return true; + } + + public bool AnswerWithError(string error) + { + _target.EmitRPCAnswer(_answerId, null, error); + return true; + } +} \ No newline at end of file diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs b/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs index 2f86645b69..2e7d20925b 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncBaseObject.cs @@ -95,51 +95,6 @@ public bool GetMetaData(string key, out T result) } } - public bool GetMetaData(string key, out int result) - { - AsyncContext?.RunAll(); - lock (BaseObject) - { - if (!AsyncContext.CheckIfExistsOrCachedNullable(BaseObject)) - { - result = default; - return false; - } - - return BaseObject.GetMetaData(key, out result); - } - } - - public bool GetMetaData(string key, out uint result) - { - AsyncContext?.RunAll(); - lock (BaseObject) - { - if (!AsyncContext.CheckIfExistsOrCachedNullable(BaseObject)) - { - result = default; - return false; - } - - return BaseObject.GetMetaData(key, out result); - } - } - - public bool GetMetaData(string key, out float result) - { - AsyncContext?.RunAll(); - lock (BaseObject) - { - if (!AsyncContext.CheckIfExistsOrCachedNullable(BaseObject)) - { - result = default; - return false; - } - - return BaseObject.GetMetaData(key, out result); - } - } - public void SetMetaData(string key, in MValueConst value) { lock (BaseObject) @@ -232,9 +187,6 @@ public void OnDestroy() BaseObject.OnDestroy(); } - [Obsolete("Use Destroy() instead")] - public void Remove() => Destroy(); - public void Destroy() { AsyncContext.RunOnMainThreadBlockingNullable(() => BaseObject.Destroy()); diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs b/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs index 141fd738fd..b5e732b6f2 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs @@ -96,17 +96,31 @@ public string Branch } } } - public uint Build + + public ushort VersionMajor + { + get + { + lock (ConnectionInfo) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default; + return ConnectionInfo.VersionMajor; + } + } + } + + public ushort VersionMinor { get { lock (ConnectionInfo) { if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default; - return ConnectionInfo.Build; + return ConnectionInfo.VersionMinor; } } } + public string CdnUrl { get diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs b/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs index 9d4a68d759..80054f55ab 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs @@ -1,10 +1,12 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.Numerics; using System.Runtime.InteropServices; using System.Threading.Tasks; using AltV.Net.Data; using AltV.Net.Elements.Args; using AltV.Net.Elements.Entities; +using AltV.Net.Enums; using AltV.Net.Native; using AltV.Net.Shared.Elements.Entities; using AltV.Net.Shared.Utils; @@ -615,6 +617,15 @@ public void SetWeather(uint weather) } } + public void SetWeather(WeatherType weatherType) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.SetWeather(weatherType); + } + } + public void GiveWeapon(uint weapon, int ammo, bool selectWeapon) { lock (Player) @@ -624,6 +635,15 @@ public void GiveWeapon(uint weapon, int ammo, bool selectWeapon) } } + public void GiveWeapon(WeaponModel weaponModel, int ammo, bool selectWeapon) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.GiveWeapon(weaponModel, ammo, selectWeapon); + } + } + public bool RemoveWeapon(uint weapon) { lock (Player) @@ -633,6 +653,15 @@ public bool RemoveWeapon(uint weapon) } } + public bool RemoveWeapon(WeaponModel weaponModel) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return false; + return Player.RemoveWeapon(weaponModel); + } + } + public void RemoveAllWeapons(bool removeAllAmmo) { lock (Player) @@ -651,6 +680,15 @@ public bool HasWeapon(uint weapon) } } + public bool HasWeapon(WeaponModel weapon) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return default; + return Player.HasWeapon(weapon); + } + } + public void Kick(string reason) { lock (Player) @@ -722,6 +760,11 @@ public void EmitRPCAnswer(ushort answerId, object answer, string error) mValue.Dispose(); Marshal.FreeHGlobal(errorPtr); + + if (Core.UnansweredServerRpcRequest.Contains(answerId)) + { + Core.UnansweredServerRpcRequest.Remove(answerId); + } } public void EmitUnreliable(string eventName, params object[] args) @@ -755,6 +798,15 @@ public void AddWeaponComponent(uint weapon, uint weaponComponent) } } + public void AddWeaponComponent(WeaponModel weaponModel, uint weaponComponent) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.AddWeaponComponent(weaponModel, weaponComponent); + } + } + public void RemoveWeaponComponent(uint weapon, uint weaponComponent) { lock (Player) @@ -764,6 +816,15 @@ public void RemoveWeaponComponent(uint weapon, uint weaponComponent) } } + public void RemoveWeaponComponent(WeaponModel weaponModel, uint weaponComponent) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.RemoveWeaponComponent(weaponModel, weaponComponent); + } + } + public bool HasWeaponComponent(uint weapon, uint weaponComponent) { lock (Player) @@ -773,6 +834,15 @@ public bool HasWeaponComponent(uint weapon, uint weaponComponent) } } + public bool HasWeaponComponent(WeaponModel weapon, uint weaponComponent) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return false; + return Player.HasWeaponComponent(weapon, weaponComponent); + } + } + public void GetCurrentWeaponComponents(out uint[] weaponComponents) { lock (Player) @@ -808,6 +878,15 @@ public void SetWeaponTintIndex(uint weapon, byte tintIndex) } } + public void SetWeaponTintIndex(WeaponModel weaponModel, byte tintIndex) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.SetWeaponTintIndex(weaponModel, tintIndex); + } + } + public byte GetWeaponTintIndex(uint weapon) { lock (Player) @@ -817,6 +896,15 @@ public byte GetWeaponTintIndex(uint weapon) } } + public byte GetWeaponTintIndex(WeaponModel weapon) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return default; + return Player.GetWeaponTintIndex(weapon); + } + } + public byte GetCurrentWeaponTintIndex() { lock (Player) @@ -898,6 +986,15 @@ public bool SetDlcClothes(byte component, ushort drawable, byte texture, byte pa } } + public bool ClearClothes(byte component) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return default; + return Player.ClearClothes(component); + } + } + public Prop GetProps(byte component) { lock (Player) @@ -1210,6 +1307,15 @@ public Rgba GetHeadBlendPaletteColor(byte id) } } + public void RemoveHeadBlendPaletteColor() + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) return; + Player.RemoveHeadBlendPaletteColor(); + } + } + public void SetHeadBlendData(uint shapeFirstID, uint shapeSecondID, uint shapeThirdID, uint skinFirstID, uint skinSecondID, uint skinThirdID, float shapeMix, float skinMix, float thirdMix) { @@ -1252,6 +1358,31 @@ public void GetLocalMetaData(string key, out MValueConst value) } } + public bool GetLocalMetaData(string key, out T result) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) + { + result = default; + return false; + } + return Player.GetLocalMetaData(key, out result); + } + } + + public void SetLocalMetaData(string key, object value) + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsNullable(Player)) + { + return; + } + Player.SetLocalMetaData(key, value); + } + } + public void SetLocalMetaData(string key, in MValueConst value) { lock (Player) @@ -1459,12 +1590,12 @@ public int GetAmmoMax100(uint ammoHash) } } - public void AddDecoration(uint collection, uint overlay) + public void AddDecoration(uint collection, uint overlay, byte count = 1) { lock (Player) { if (!AsyncContext.CheckIfExistsNullable(Player)) return; - Player.AddDecoration(collection, overlay); + Player.AddDecoration(collection, overlay, count); } } @@ -1548,6 +1679,15 @@ public string BloodDamage } } + public Vector3 GetForwardVector() + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(Player)) return default; + return Player.GetForwardVector(); + } + } + [Obsolete("Use new async API instead")] public IPlayer ToAsync(IAsyncContext asyncContext) { diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs b/api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs index f1dc2fb86d..61ee51e9dc 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncVehicle.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using AltV.Net.CApi.Data; using AltV.Net.Data; using AltV.Net.Elements.Entities; using AltV.Net.Enums; @@ -585,13 +586,6 @@ public AsyncVehicle(ICore core, IntPtr nativePointer, uint id) : this(new Vehicl { } - [Obsolete("Use AltAsync.CreateVehicle instead")] - public AsyncVehicle(ICore core, uint model, Position position, Rotation rotation, uint streamingDistance = 0) : this( - core, core.CreateVehicleEntity(out var id, model, position, rotation, streamingDistance), id) - { - core.PoolManager.Vehicle.Add(this); - } - public byte GetMod(byte category) { lock (Vehicle) @@ -2000,6 +1994,24 @@ public List Passengers } } + public void SetBage(string textureDictionary, string texture, VehicleBadgePosition[] vehicleBadgePosition) + { + lock (Vehicle) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(Vehicle)) return; + Vehicle.SetBage(textureDictionary, texture, vehicleBadgePosition); + } + } + + public void SetBage(uint textureDictionary, uint texture, VehicleBadgePosition[] vehicleBadgePosition) + { + lock (Vehicle) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(Vehicle)) return; + Vehicle.SetBage(textureDictionary, texture, vehicleBadgePosition); + } + } + [Obsolete("Use new async API instead")] public IVehicle ToAsync(IAsyncContext asyncContext) { diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncVirtualEntity.cs b/api/AltV.Net.Async/Elements/Entities/AsyncVirtualEntity.cs index 6ddcb16174..96a1a044e2 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncVirtualEntity.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncVirtualEntity.cs @@ -33,48 +33,6 @@ public bool HasStreamSyncedMetaData(string key) } } - public bool GetStreamSyncedMetaData(string key, out int result) - { - lock (VirtualEntity) - { - if (!AsyncContext.CheckIfExistsNullable(VirtualEntity)) - { - result = default; - return false; - } - - return VirtualEntity.GetStreamSyncedMetaData(key, out result); - } - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - lock (VirtualEntity) - { - if (!AsyncContext.CheckIfExistsNullable(VirtualEntity)) - { - result = default; - return false; - } - - return VirtualEntity.GetStreamSyncedMetaData(key, out result); - } - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - lock (VirtualEntity) - { - if (!AsyncContext.CheckIfExistsNullable(VirtualEntity)) - { - result = default; - return false; - } - - return VirtualEntity.GetStreamSyncedMetaData(key, out result); - } - } - public bool GetStreamSyncedMetaData(string key, out T result) { lock (VirtualEntity) diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncWorldObject.cs b/api/AltV.Net.Async/Elements/Entities/AsyncWorldObject.cs index c4b113680d..95305856ed 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncWorldObject.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncWorldObject.cs @@ -53,5 +53,32 @@ public AsyncWorldObject(IWorldObject worldObject, IAsyncContext asyncContext) : { WorldObject = worldObject; } + + public void SetPosition((float X, float Y, float Z) position) + { + lock (WorldObject) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(WorldObject)) return; + WorldObject.SetPosition(position); + } + } + + public void SetPosition(float x, float y, float z) + { + lock (WorldObject) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(WorldObject)) return; + WorldObject.SetPosition(x, y, z); + } + } + + public (float X, float Y, float Z) GetPosition() + { + lock (WorldObject) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(WorldObject)) return default; + return WorldObject.GetPosition(); + } + } } } \ No newline at end of file diff --git a/api/AltV.Net.Async/Elements/Entities/VehicleBuilder.cs b/api/AltV.Net.Async/Elements/Entities/VehicleBuilder.cs deleted file mode 100644 index be5bf09421..0000000000 --- a/api/AltV.Net.Async/Elements/Entities/VehicleBuilder.cs +++ /dev/null @@ -1,466 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using AltV.Net.Data; -using AltV.Net.Elements.Entities; -using AltV.Net.Enums; -using AltV.Net.Native; -using AltV.Net.Shared.Utils; - -namespace AltV.Net.Async.Elements.Entities -{ - [Obsolete("Use Vehicle constructor instead")] - public class VehicleBuilder : IVehicleBuilder - { - private readonly uint model; - - private readonly Position position; - - private readonly Rotation rotation; - - private readonly uint streamingDistance; - - private readonly Dictionary> functions = new Dictionary>(); - - private readonly List memoryToFree = new List(); - - public VehicleBuilder(uint model, Position position, Rotation rotation, uint streamingDistance = 0) - { - this.model = model; - this.position = position; - this.rotation = rotation; - this.streamingDistance = streamingDistance; - } - - public IVehicleBuilder ModKit(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetModKit(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder PrimaryColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetPrimaryColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder PrimaryColorRgb(Rgba value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetPrimaryColorRGB(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder SecondaryColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetSecondaryColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder SecondaryColorRgb(Rgba value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetSecondaryColorRGB(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder PearlColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetPearlColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder WheelColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetWheelColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder InteriorColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetInteriorColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder DashboardColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetDashboardColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder TireSmokeColor(Rgba value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetTireSmokeColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder CustomTires(bool value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetCustomTires(ptr, value ? (byte) 1 : (byte) 0); - } - }); - return this; - } - - public IVehicleBuilder SpecialDarkness(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetSpecialDarkness(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder NumberplateIndex(uint value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetNumberplateIndex(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder NumberplateText(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetNumberplateText(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public IVehicleBuilder WindowTint(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetWindowTint(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder DirtLevel(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetDirtLevel(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder NeonColor(Rgba value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetNeonColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder EngineOn(bool value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetEngineOn(ptr, value ? (byte) 1 : (byte) 0); - } - }); - return this; - } - - public IVehicleBuilder HeadlightColor(byte value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetHeadlightColor(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder SirenActive(bool value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetSirenActive(ptr, value ? (byte) 1 : (byte) 0); - } - }); - return this; - } - - public IVehicleBuilder LockState(VehicleLockState value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetLockState(ptr, (byte) value); - } - }); - return this; - } - - public IVehicleBuilder IsRoofClosed(bool state) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetRoofState(ptr, state ? (byte)1: (byte)0); - } - }); - return this; - } - - public IVehicleBuilder State(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_LoadGameStateFromBase64(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public IVehicleBuilder EngineHealth(int value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetEngineHealth(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder PetrolTankHealth(int value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetPetrolTankHealth(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder BodyHealth(uint value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetBodyHealth(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder BodyAdditionalHealth(uint value) - { - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_SetBodyAdditionalHealth(ptr, value); - } - }); - return this; - } - - public IVehicleBuilder HealthData(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_LoadHealthDataFromBase64(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public IVehicleBuilder DamageData(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_LoadDamageDataFromBase64(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public IVehicleBuilder Appearance(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_LoadAppearanceDataFromBase64(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public IVehicleBuilder ScriptData(string value) - { - var valuePtr = StringToHGlobalUtf8(value); - Add(ptr => - { - unsafe - { - Alt.Core.Library.Server.Vehicle_LoadScriptDataFromBase64(ptr, valuePtr); - Marshal.FreeHGlobal(valuePtr); - } - }); - return this; - } - - public async Task Build() - { - var enumerator = functions.Values.GetEnumerator(); - var (vehiclePtr, vehicleId) = await AltAsync.AltVAsync.Schedule(() => - { - unsafe - { - uint id = default; - var ptr = Alt.Core.Library.Server.Core_CreateVehicle(((Core) Alt.Core).NativePointer, model, - position, rotation, streamingDistance, &id); - - while (enumerator.MoveNext()) - { - enumerator.Current(ptr); - } - - return (ptr, id); - } - }); - enumerator.Dispose(); - Dispose(); - return Alt.Core.PoolManager.Vehicle.Create(Alt.Core, vehiclePtr, vehicleId); - } - - // Call Dispose when you don't wanna continue building the vehicle anymore to cleanup memory - public void Dispose() - { - foreach (var ptr in memoryToFree) - { - Marshal.FreeHGlobal(ptr); - } - } - - private void Add(Action action, [CallerMemberName] string memberName = "") - { - functions[memberName] = action; - } - - private IntPtr StringToHGlobalUtf8(string str) - { - var strPtr = MemoryUtils.StringToHGlobalUtf8(str); - memoryToFree.Add(strPtr); - return strPtr; - } - } -} \ No newline at end of file diff --git a/api/AltV.Net.Async/Events/Events.cs b/api/AltV.Net.Async/Events/Events.cs index 8a27656396..6314681acd 100644 --- a/api/AltV.Net.Async/Events/Events.cs +++ b/api/AltV.Net.Async/Events/Events.cs @@ -14,7 +14,7 @@ namespace AltV.Net.Async.Events public delegate Task PlayerConnectAsyncDelegate(IPlayer player, string reason); public delegate Task PlayerConnectDeniedAsyncDelegate(PlayerConnectDeniedReason reason, string name, string ip, - ulong passwordHash, bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId); + ulong passwordHash, bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId); public delegate Task ResourceEventAsyncDelegate(INativeResource resource); diff --git a/api/AltV.Net.CApi.Generator/Program.cs b/api/AltV.Net.CApi.Generator/Program.cs index a1ee8a2d90..f9b55b2b85 100644 --- a/api/AltV.Net.CApi.Generator/Program.cs +++ b/api/AltV.Net.CApi.Generator/Program.cs @@ -15,7 +15,7 @@ private static string GetCMethodDelegateType(CMethod method) var args = string.Join("", method.Params.Select(p => p.Type + ", ")); return $"delegate* unmanaged[Cdecl{noGc}]<{args}{method.ReturnType}>"; } - + private static string GetCMethodArgs(CMethod method) { return string.Join(", ", method.Params.Select(p => p.Type + " " + p.Name)); @@ -23,7 +23,7 @@ private static string GetCMethodArgs(CMethod method) public static void Generate() { - var libOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../AltV.Net.CApi/Libraries"); + var libOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../AltV.Net.CApi/Libraries"); var tableOutputPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "../../../../../runtime/c-api/func_table.cpp"); var tableHashes = new StringBuilder(); @@ -40,31 +40,32 @@ public static void Generate() collisionFound = true; Console.WriteLine("Colliding methods: " + string.Join(",", collision.Select(e => e.Name))); } - + if (collisionFound) throw new Exception("Collision found!"); var capiHash = FnvHash.Generate(string.Join(";", parsedMethods.Select(e => e.Hash))); - + foreach (var group in parsedMethods.OrderBy(e => e.Name).GroupBy(e => e.Target)) { #region C# bindings var target = group.Key.ForceCapitalize(); - + var methods = string.Join("\n", group.Where(e => !e.OnlyManual) .Select(e => $" public {GetCMethodDelegateType(e)} {e.Name} {{ get; }}")); - + // todo add docs link to the exception var fallbacks = string.Join("\n", group.Where(e => !e.OnlyManual) .Select(e => $" [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate {e.ReturnType} {e.Name}Delegate({GetCMethodArgs(e)});\n" + $" private static {e.ReturnType} {e.Name}Fallback({GetCMethodArgs(e)}) => throw new Exceptions.OutdatedSdkException(\"{e.Name}\", \"{e.Name} SDK method is outdated. Please update your module nuget\");")); - + var loads = string.Join("\n", group.Where(e => !e.OnlyManual) .Select(e => $" {e.Name} = ({GetCMethodDelegateType(e)}) GetUnmanagedPtr<{e.Name}Delegate>(funcTable, {e.Hash}UL, {e.Name}Fallback);")); - + var output = new StringBuilder(); output.Append("// ReSharper disable InconsistentNaming\n"); output.Append("using AltV.Net.Data;\n"); + output.Append("using AltV.Net.CApi.Data;\n"); output.Append("using System.Numerics;\n"); output.Append("using System.Runtime.InteropServices;\n"); output.Append("using AltV.Net.Elements.Args;\n"); @@ -100,7 +101,7 @@ public static void Generate() File.WriteAllText(Path.Combine(libOutputPath, $"{target}Library.cs"), output.ToString()); #endregion - + #region Func table if (group.Key != "SHARED") @@ -108,13 +109,13 @@ public static void Generate() tableHashes.Append($" #ifdef ALT_{group.Key}_API\n"); tablePointers.Append($" #ifdef ALT_{group.Key}_API\n"); } - + foreach (var e in group) { tableHashes.Append($" {e.Hash}UL,\n"); tablePointers.Append($" (void*) {e.Name},\n"); } - + if (group.Key != "SHARED") { tableHashes.Append($" #endif\n"); @@ -125,13 +126,13 @@ public static void Generate() var table = new StringBuilder(); table.Append("#include \"func_table.h\"\n\n"); - + table.Append($"inline uint64_t capiHash = {capiHash}UL;\n"); table.Append("inline uint64_t capiHashes[] = {\n"); table.Append(" 0,\n"); table.Append(tableHashes); table.Append("};\n\n"); - + table.Append("inline void* capiPointers[] = {\n"); table.Append(" (void*) &capiHash,\n"); table.Append(tablePointers); @@ -145,10 +146,10 @@ public static void Generate() table.Append(" };\n"); table.Append(" return &data;\n"); table.Append("}"); - + File.WriteAllText(tableOutputPath, table.ToString()); - } - + } + public static void Main() { Generate(); diff --git a/api/AltV.Net.CApi.Generator/TypeRegistry.cs b/api/AltV.Net.CApi.Generator/TypeRegistry.cs index 7feb9f21d8..97570fdd1d 100644 --- a/api/AltV.Net.CApi.Generator/TypeRegistry.cs +++ b/api/AltV.Net.CApi.Generator/TypeRegistry.cs @@ -112,17 +112,15 @@ public static class TypeRegistry { "rgba_t", "Rgba" }, { "rgba_t&", "Rgba*" }, { "std::vector", "UIntArray*" }, - { "alt::Quaternion", "Quaternion" }, { "alt::Quaternion&", "Quaternion*" }, - { "position_t&", "Vector3*" }, { "position_t", "Vector3" }, { "alt::Position", "Vector3" }, { "rotation_t&", "Rotation*" }, { "rotation_t", "Rotation" }, { "alt::Rotation", "Rotation" }, - + { "vehicleBadgePosition_t[]", "VehicleBadgePosition[]" }, { "cloth_t&", "Cloth*" }, { "cloth_t", "Cloth" }, { "dlccloth_t&", "DlcCloth*" }, @@ -168,9 +166,7 @@ public static class TypeRegistry { "const alt::MValueList&", "MValue*" }, //no c# representation for MValue list memory layout yet { "alt::MValueDict&", "MValue*" }, //no c# representation for MValue dictionary memory layout yet { "alt::ICheckpoint*", "nint" }, - { - "alt::MValueFunction&", "MValue*" - }, //no c# representation for MValue function memory layout yet, this is only in commented code and not required + { "alt::MValueFunction&", "MValue*" }, //no c# representation for MValue function memory layout yet, this is only in commented code and not required { "alt::CEvent::Type", "ushort" }, { "alt::CEvent*", "nint" }, { "alt::CCancellableEvent*", "nint" }, diff --git a/api/AltV.Net.CApi/Data/VehicleBadgePosition.cs b/api/AltV.Net.CApi/Data/VehicleBadgePosition.cs new file mode 100644 index 0000000000..7e84a7aa7b --- /dev/null +++ b/api/AltV.Net.CApi/Data/VehicleBadgePosition.cs @@ -0,0 +1,39 @@ +using System.Numerics; +using System.Runtime.InteropServices; + +namespace AltV.Net.CApi.Data; + +[StructLayout(LayoutKind.Sequential)] +public struct VehicleBadgePosition : IEquatable +{ + public VehicleBadgePosition(bool active, byte alpha, float size, short boneIndex, Vector3 offset, Vector3 direction, Vector3 side) + { + Active = active ? (byte)1 : (byte)0; + Alpha = alpha; + Size = size; + BoneIndex = boneIndex; + Offset = offset; + Direction = direction; + Side = side; + } + + public byte Active { get; set; } = 0; + public byte Alpha { get; set; } = 255; + public float Size { get; set; } = 1f; + public short BoneIndex { get; set; } = 0; + public Vector3 Offset { get; set; } = new(0, 0, 0); + public Vector3 Direction { get; set; } = new(0, 0, 0); + public Vector3 Side { get; set; } = new(0, 0, 0); + + public bool Equals(VehicleBadgePosition other) + { + return Active == other.Active && Alpha == other.Alpha && Size.Equals(other.Size) && BoneIndex == other.BoneIndex && Offset.Equals(other.Offset) && Direction.Equals(other.Direction) && Side.Equals(other.Side); + } + + public override bool Equals(object? obj) + { + return obj is VehicleBadgePosition other && Equals(other); + } + + public override int GetHashCode() => HashCode.Combine(Active.GetHashCode(), Alpha.GetHashCode(), Size.GetHashCode(), BoneIndex.GetHashCode(), Offset.GetHashCode(), Direction.GetHashCode(), Side.GetHashCode()); +} \ 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 15cd4b6412..87282b950a 100644 --- a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs @@ -1,5 +1,6 @@ // ReSharper disable InconsistentNaming using AltV.Net.Data; +using AltV.Net.CApi.Data; using System.Numerics; using System.Runtime.InteropServices; using AltV.Net.Elements.Args; @@ -72,7 +73,7 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] AudioFilter_AddPhaserEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_AddPitchshiftEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_AddRotateEffect { get; } - public delegate* unmanaged[Cdecl] AudioFilter_AddVolumeEffect { get; } + public delegate* unmanaged[Cdecl] AudioFilter_AddVolumeEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetAudCategory { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetBaseObject { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetHash { get; } @@ -99,6 +100,7 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Checkpoint_GetGameID { get; } public delegate* unmanaged[Cdecl] Checkpoint_IsStreamedIn { get; } public delegate* unmanaged[Cdecl] Core_AddGXTText { get; } + public delegate* unmanaged[Cdecl] Core_AddVoiceFilter { get; } public delegate* unmanaged[Cdecl] Core_AreGameControlsEnabled { get; } public delegate* unmanaged[Cdecl] Core_AreRmlControlsEnabled { get; } public delegate* unmanaged[Cdecl] Core_AreVoiceControlsEnabled { get; } @@ -160,9 +162,13 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Core_GetPedBonePos { get; } public delegate* unmanaged[Cdecl] Core_GetPermissionState { get; } public delegate* unmanaged[Cdecl] Core_GetPing { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolCount { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolEntities { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolSize { get; } public delegate* unmanaged[Cdecl] Core_GetScreenResolution { get; } public delegate* unmanaged[Cdecl] Core_GetServerIp { get; } public delegate* unmanaged[Cdecl] Core_GetServerPort { get; } + public delegate* unmanaged[Cdecl] Core_GetServerTime { get; } public delegate* unmanaged[Cdecl] Core_GetStatBool { get; } public delegate* unmanaged[Cdecl] Core_GetStatData { get; } public delegate* unmanaged[Cdecl] Core_GetStatFloat { get; } @@ -178,7 +184,11 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Core_GetTotalPacketsSent { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceActivationKey { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceActivationLevel { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceFilter { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceInputMuted { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceNonSpatialVolume { get; } + public delegate* unmanaged[Cdecl] Core_GetVoicePlayers { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceSpatialVolume { get; } public delegate* unmanaged[Cdecl] Core_GetWeaponObjects { get; } public delegate* unmanaged[Cdecl] Core_GetWebViewCount { get; } public delegate* unmanaged[Cdecl] Core_GetWebViews { get; } @@ -210,6 +220,8 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Core_RegisterFont { get; } public delegate* unmanaged[Cdecl] Core_RemoveGXTText { get; } public delegate* unmanaged[Cdecl] Core_RemoveIpl { get; } + public delegate* unmanaged[Cdecl] Core_RemoveVoiceFilter { get; } + public delegate* unmanaged[Cdecl] Core_RemoveVoicePlayer { get; } public delegate* unmanaged[Cdecl] Core_RequestIpl { get; } public delegate* unmanaged[Cdecl] Core_ResetAllMapZoomData { get; } public delegate* unmanaged[Cdecl] Core_ResetMapZoomData { get; } @@ -236,6 +248,8 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Core_SetStatUInt8 { get; } public delegate* unmanaged[Cdecl] Core_SetVoiceActivationLevel { get; } public delegate* unmanaged[Cdecl] Core_SetVoiceInputMuted { get; } + public delegate* unmanaged[Cdecl] Core_SetVoiceNonSpatialVolume { get; } + public delegate* unmanaged[Cdecl] Core_SetVoiceSpatialVolume { get; } public delegate* unmanaged[Cdecl] Core_SetWatermarkPosition { get; } public delegate* unmanaged[Cdecl] Core_SetWeatherCycle { get; } public delegate* unmanaged[Cdecl] Core_SetWeatherSyncActive { get; } @@ -255,10 +269,12 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Core_TriggerServerRPCEvent { get; } public delegate* unmanaged[Cdecl] Core_TriggerWebViewEvent { get; } public delegate* unmanaged[Cdecl] Core_UnloadYtyp { get; } + public delegate* unmanaged[Cdecl] Core_UpdateClipContext { get; } public delegate* unmanaged[Cdecl] Core_WorldToScreen { get; } public delegate* unmanaged[Cdecl] CustomTexture_GetBaseObject { get; } public delegate* unmanaged[Cdecl] CustomTexture_GetID { get; } public delegate* unmanaged[Cdecl] Entity_GetScriptID { get; } + public delegate* unmanaged[Cdecl] Entity_GetSyncInfo { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceErrorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceStartDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceStopDelegate { get; } @@ -886,7 +902,7 @@ public unsafe interface IClientLibrary public unsafe class ClientLibrary : IClientLibrary { - public readonly uint Methods = 1738; + public readonly uint Methods = 1770; public delegate* unmanaged[Cdecl] Audio_AddOutput { get; } public delegate* unmanaged[Cdecl] Audio_GetBaseObject { get; } public delegate* unmanaged[Cdecl] Audio_GetCurrentTime { get; } @@ -949,7 +965,7 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] AudioFilter_AddPhaserEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_AddPitchshiftEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_AddRotateEffect { get; } - public delegate* unmanaged[Cdecl] AudioFilter_AddVolumeEffect { get; } + public delegate* unmanaged[Cdecl] AudioFilter_AddVolumeEffect { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetAudCategory { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetBaseObject { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetHash { get; } @@ -976,6 +992,7 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Checkpoint_GetGameID { get; } public delegate* unmanaged[Cdecl] Checkpoint_IsStreamedIn { get; } public delegate* unmanaged[Cdecl] Core_AddGXTText { get; } + public delegate* unmanaged[Cdecl] Core_AddVoiceFilter { get; } public delegate* unmanaged[Cdecl] Core_AreGameControlsEnabled { get; } public delegate* unmanaged[Cdecl] Core_AreRmlControlsEnabled { get; } public delegate* unmanaged[Cdecl] Core_AreVoiceControlsEnabled { get; } @@ -1037,9 +1054,13 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Core_GetPedBonePos { get; } public delegate* unmanaged[Cdecl] Core_GetPermissionState { get; } public delegate* unmanaged[Cdecl] Core_GetPing { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolCount { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolEntities { get; } + public delegate* unmanaged[Cdecl] Core_GetPoolSize { get; } public delegate* unmanaged[Cdecl] Core_GetScreenResolution { get; } public delegate* unmanaged[Cdecl] Core_GetServerIp { get; } public delegate* unmanaged[Cdecl] Core_GetServerPort { get; } + public delegate* unmanaged[Cdecl] Core_GetServerTime { get; } public delegate* unmanaged[Cdecl] Core_GetStatBool { get; } public delegate* unmanaged[Cdecl] Core_GetStatData { get; } public delegate* unmanaged[Cdecl] Core_GetStatFloat { get; } @@ -1055,7 +1076,11 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Core_GetTotalPacketsSent { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceActivationKey { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceActivationLevel { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceFilter { get; } public delegate* unmanaged[Cdecl] Core_GetVoiceInputMuted { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceNonSpatialVolume { get; } + public delegate* unmanaged[Cdecl] Core_GetVoicePlayers { get; } + public delegate* unmanaged[Cdecl] Core_GetVoiceSpatialVolume { get; } public delegate* unmanaged[Cdecl] Core_GetWeaponObjects { get; } public delegate* unmanaged[Cdecl] Core_GetWebViewCount { get; } public delegate* unmanaged[Cdecl] Core_GetWebViews { get; } @@ -1087,6 +1112,8 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Core_RegisterFont { get; } public delegate* unmanaged[Cdecl] Core_RemoveGXTText { get; } public delegate* unmanaged[Cdecl] Core_RemoveIpl { get; } + public delegate* unmanaged[Cdecl] Core_RemoveVoiceFilter { get; } + public delegate* unmanaged[Cdecl] Core_RemoveVoicePlayer { get; } public delegate* unmanaged[Cdecl] Core_RequestIpl { get; } public delegate* unmanaged[Cdecl] Core_ResetAllMapZoomData { get; } public delegate* unmanaged[Cdecl] Core_ResetMapZoomData { get; } @@ -1113,6 +1140,8 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Core_SetStatUInt8 { get; } public delegate* unmanaged[Cdecl] Core_SetVoiceActivationLevel { get; } public delegate* unmanaged[Cdecl] Core_SetVoiceInputMuted { get; } + public delegate* unmanaged[Cdecl] Core_SetVoiceNonSpatialVolume { get; } + public delegate* unmanaged[Cdecl] Core_SetVoiceSpatialVolume { get; } public delegate* unmanaged[Cdecl] Core_SetWatermarkPosition { get; } public delegate* unmanaged[Cdecl] Core_SetWeatherCycle { get; } public delegate* unmanaged[Cdecl] Core_SetWeatherSyncActive { get; } @@ -1132,10 +1161,12 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Core_TriggerServerRPCEvent { get; } public delegate* unmanaged[Cdecl] Core_TriggerWebViewEvent { get; } public delegate* unmanaged[Cdecl] Core_UnloadYtyp { get; } + public delegate* unmanaged[Cdecl] Core_UpdateClipContext { get; } public delegate* unmanaged[Cdecl] Core_WorldToScreen { get; } public delegate* unmanaged[Cdecl] CustomTexture_GetBaseObject { get; } public delegate* unmanaged[Cdecl] CustomTexture_GetID { get; } public delegate* unmanaged[Cdecl] Entity_GetScriptID { get; } + public delegate* unmanaged[Cdecl] Entity_GetSyncInfo { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceErrorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceStartDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetAnyResourceStopDelegate { get; } @@ -1883,8 +1914,8 @@ public unsafe class ClientLibrary : IClientLibrary 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddRotateEffectDelegate(nint _audioFilter, float _rate, int _priority); 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"); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddVolumeEffectDelegate(nint _audioFilter, float _volume, int _priority); - 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"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_AddVolumeEffectDelegate(nint _audioFilter, float _volume, int _priority, int _channel); + 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint AudioFilter_GetAudCategoryDelegate(nint _audioFilter); private static uint AudioFilter_GetAudCategoryFallback(nint _audioFilter) => throw new Exceptions.OutdatedSdkException("AudioFilter_GetAudCategory", "AudioFilter_GetAudCategory SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint AudioFilter_GetBaseObjectDelegate(nint _audioFilter); @@ -1937,6 +1968,8 @@ public unsafe class ClientLibrary : IClientLibrary private static byte Checkpoint_IsStreamedInFallback(nint _checkpoint) => throw new Exceptions.OutdatedSdkException("Checkpoint_IsStreamedIn", "Checkpoint_IsStreamedIn SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_AddGXTTextDelegate(nint _core, nint _resource, uint _key, nint _value); private static void Core_AddGXTTextFallback(nint _core, nint _resource, uint _key, nint _value) => throw new Exceptions.OutdatedSdkException("Core_AddGXTText", "Core_AddGXTText SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_AddVoiceFilterDelegate(nint _core, uint _playerRemodeId, nint _filter); + private static void Core_AddVoiceFilterFallback(nint _core, uint _playerRemodeId, nint _filter) => throw new Exceptions.OutdatedSdkException("Core_AddVoiceFilter", "Core_AddVoiceFilter SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_AreGameControlsEnabledDelegate(nint _core); private static byte Core_AreGameControlsEnabledFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_AreGameControlsEnabled", "Core_AreGameControlsEnabled SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_AreRmlControlsEnabledDelegate(nint _core); @@ -2059,12 +2092,20 @@ public unsafe class ClientLibrary : IClientLibrary 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetPingDelegate(nint _core); private static ushort Core_GetPingFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetPing", "Core_GetPing SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolCountDelegate(nint _core, nint _pool); + 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"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetPoolEntitiesDelegate(nint _core, nint _pool, nint* _poolEntities, uint* _size); + 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"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Core_GetPoolSizeDelegate(nint _core, nint _pool); + 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetScreenResolutionDelegate(nint _core, Vector2* _out); 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetServerIpDelegate(nint _core, int* _size); 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort Core_GetServerPortDelegate(nint _core); private static ushort Core_GetServerPortFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetServerPort", "Core_GetServerPort SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetServerTimeDelegate(nint _core); + private static ulong Core_GetServerTimeFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetServerTime", "Core_GetServerTime SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetStatBoolDelegate(nint _core, nint _stat); 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"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetStatDataDelegate(nint _core, nint _stat); @@ -2095,8 +2136,16 @@ public unsafe class ClientLibrary : IClientLibrary private static uint Core_GetVoiceActivationKeyFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceActivationKey", "Core_GetVoiceActivationKey SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float Core_GetVoiceActivationLevelDelegate(nint _core); private static float Core_GetVoiceActivationLevelFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceActivationLevel", "Core_GetVoiceActivationLevel SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetVoiceFilterDelegate(nint _core, uint _playerRemodeId); + private static nint Core_GetVoiceFilterFallback(nint _core, uint _playerRemodeId) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceFilter", "Core_GetVoiceFilter SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_GetVoiceInputMutedDelegate(nint _core); private static byte Core_GetVoiceInputMutedFallback(nint _core) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceInputMuted", "Core_GetVoiceInputMuted SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float Core_GetVoiceNonSpatialVolumeDelegate(nint _core, uint _playerRemodeId); + private static float Core_GetVoiceNonSpatialVolumeFallback(nint _core, uint _playerRemodeId) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceNonSpatialVolume", "Core_GetVoiceNonSpatialVolume SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_GetVoicePlayersDelegate(nint _core, nint* _voicePlayers, uint* _size); + private static void Core_GetVoicePlayersFallback(nint _core, nint* _voicePlayers, uint* _size) => throw new Exceptions.OutdatedSdkException("Core_GetVoicePlayers", "Core_GetVoicePlayers SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float Core_GetVoiceSpatialVolumeDelegate(nint _core, uint _playerRemodeId); + private static float Core_GetVoiceSpatialVolumeFallback(nint _core, uint _playerRemodeId) => throw new Exceptions.OutdatedSdkException("Core_GetVoiceSpatialVolume", "Core_GetVoiceSpatialVolume SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Core_GetWeaponObjectsDelegate(nint _core, uint* _size); private static nint Core_GetWeaponObjectsFallback(nint _core, uint* _size) => throw new Exceptions.OutdatedSdkException("Core_GetWeaponObjects", "Core_GetWeaponObjects SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Core_GetWebViewCountDelegate(nint _core); @@ -2159,6 +2208,10 @@ public unsafe class ClientLibrary : IClientLibrary private static void Core_RemoveGXTTextFallback(nint _core, nint _resource, uint _key) => throw new Exceptions.OutdatedSdkException("Core_RemoveGXTText", "Core_RemoveGXTText SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_RemoveIplDelegate(nint _core, nint _path); private static void Core_RemoveIplFallback(nint _core, nint _path) => throw new Exceptions.OutdatedSdkException("Core_RemoveIpl", "Core_RemoveIpl SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_RemoveVoiceFilterDelegate(nint _core, uint _playerRemodeId); + private static void Core_RemoveVoiceFilterFallback(nint _core, uint _playerRemodeId) => throw new Exceptions.OutdatedSdkException("Core_RemoveVoiceFilter", "Core_RemoveVoiceFilter SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_RemoveVoicePlayerDelegate(nint _core, uint _playerRemodeId); + private static void Core_RemoveVoicePlayerFallback(nint _core, uint _playerRemodeId) => throw new Exceptions.OutdatedSdkException("Core_RemoveVoicePlayer", "Core_RemoveVoicePlayer SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_RequestIplDelegate(nint _core, nint _path); private static void Core_RequestIplFallback(nint _core, nint _path) => throw new Exceptions.OutdatedSdkException("Core_RequestIpl", "Core_RequestIpl SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_ResetAllMapZoomDataDelegate(nint _core); @@ -2211,6 +2264,10 @@ public unsafe class ClientLibrary : IClientLibrary private static byte Core_SetVoiceActivationLevelFallback(nint _core, float _level) => throw new Exceptions.OutdatedSdkException("Core_SetVoiceActivationLevel", "Core_SetVoiceActivationLevel SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_SetVoiceInputMutedDelegate(nint _core, byte _value); private static void Core_SetVoiceInputMutedFallback(nint _core, byte _value) => throw new Exceptions.OutdatedSdkException("Core_SetVoiceInputMuted", "Core_SetVoiceInputMuted SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_SetVoiceNonSpatialVolumeDelegate(nint _core, uint _playerRemodeId, float _volume); + private static void Core_SetVoiceNonSpatialVolumeFallback(nint _core, uint _playerRemodeId, float _volume) => throw new Exceptions.OutdatedSdkException("Core_SetVoiceNonSpatialVolume", "Core_SetVoiceNonSpatialVolume SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_SetVoiceSpatialVolumeDelegate(nint _core, uint _playerRemodeId, float _volume); + private static void Core_SetVoiceSpatialVolumeFallback(nint _core, uint _playerRemodeId, float _volume) => throw new Exceptions.OutdatedSdkException("Core_SetVoiceSpatialVolume", "Core_SetVoiceSpatialVolume SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_SetWatermarkPositionDelegate(nint _core, byte _position); private static void Core_SetWatermarkPositionFallback(nint _core, byte _position) => throw new Exceptions.OutdatedSdkException("Core_SetWatermarkPosition", "Core_SetWatermarkPosition SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_SetWeatherCycleDelegate(nint _core, byte[] weathers, int _weathersSize, byte[] multipliers, int _multipliersSize); @@ -2249,6 +2306,8 @@ public unsafe class ClientLibrary : IClientLibrary private static void Core_TriggerWebViewEventFallback(nint _core, nint _webview, nint _event, nint[] args, int _size) => throw new Exceptions.OutdatedSdkException("Core_TriggerWebViewEvent", "Core_TriggerWebViewEvent SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Core_UnloadYtypDelegate(nint _core, nint _path); private static byte Core_UnloadYtypFallback(nint _core, nint _path) => throw new Exceptions.OutdatedSdkException("Core_UnloadYtyp", "Core_UnloadYtyp SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_UpdateClipContextDelegate(nint _core, nint[] keys, nint[] values, ulong _size); + private static void Core_UpdateClipContextFallback(nint _core, nint[] keys, nint[] values, ulong _size) => throw new Exceptions.OutdatedSdkException("Core_UpdateClipContext", "Core_UpdateClipContext SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Core_WorldToScreenDelegate(nint _core, Vector3 _in, Vector2* _out); private static void Core_WorldToScreenFallback(nint _core, Vector3 _in, Vector2* _out) => throw new Exceptions.OutdatedSdkException("Core_WorldToScreen", "Core_WorldToScreen SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint CustomTexture_GetBaseObjectDelegate(nint _costumTexture); @@ -2257,6 +2316,8 @@ public unsafe class ClientLibrary : IClientLibrary private static uint CustomTexture_GetIDFallback(nint _costumTexture) => throw new Exceptions.OutdatedSdkException("CustomTexture_GetID", "CustomTexture_GetID SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Entity_GetScriptIDDelegate(nint _entity); private static uint Entity_GetScriptIDFallback(nint _entity) => throw new Exceptions.OutdatedSdkException("Entity_GetScriptID", "Entity_GetScriptID SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Entity_GetSyncInfoDelegate(nint _entity, nint* _syncInfo); + private static void Entity_GetSyncInfoFallback(nint _entity, nint* _syncInfo) => throw new Exceptions.OutdatedSdkException("Entity_GetSyncInfo", "Entity_GetSyncInfo SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetAnyResourceErrorDelegateDelegate(nint _resource, ClientEvents.AnyResourceErrorModuleDelegate _delegate); private static void Event_SetAnyResourceErrorDelegateFallback(nint _resource, ClientEvents.AnyResourceErrorModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetAnyResourceErrorDelegate", "Event_SetAnyResourceErrorDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetAnyResourceStartDelegateDelegate(nint _resource, ClientEvents.AnyResourceStartModuleDelegate _delegate); @@ -3512,7 +3573,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 != 13325244553859733034UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) 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); @@ -3575,7 +3636,7 @@ public ClientLibrary(Dictionary funcTable) AudioFilter_AddPhaserEffect = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4076092769167870615UL, AudioFilter_AddPhaserEffectFallback); AudioFilter_AddPitchshiftEffect = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13860375026413797308UL, AudioFilter_AddPitchshiftEffectFallback); AudioFilter_AddRotateEffect = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3023765297763740660UL, AudioFilter_AddRotateEffectFallback); - AudioFilter_AddVolumeEffect = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4712013335136464389UL, AudioFilter_AddVolumeEffectFallback); + AudioFilter_AddVolumeEffect = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 734963942086458615UL, AudioFilter_AddVolumeEffectFallback); AudioFilter_GetAudCategory = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6059317348005410766UL, AudioFilter_GetAudCategoryFallback); AudioFilter_GetBaseObject = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8867334748367703826UL, AudioFilter_GetBaseObjectFallback); AudioFilter_GetHash = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10116851781453819636UL, AudioFilter_GetHashFallback); @@ -3602,6 +3663,7 @@ public ClientLibrary(Dictionary funcTable) Checkpoint_GetGameID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10807368225937279665UL, Checkpoint_GetGameIDFallback); Checkpoint_IsStreamedIn = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11169437175796680635UL, Checkpoint_IsStreamedInFallback); Core_AddGXTText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15861482869617048160UL, Core_AddGXTTextFallback); + Core_AddVoiceFilter = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16092557757480797995UL, Core_AddVoiceFilterFallback); Core_AreGameControlsEnabled = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 332214446285856938UL, Core_AreGameControlsEnabledFallback); Core_AreRmlControlsEnabled = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6617672605820539119UL, Core_AreRmlControlsEnabledFallback); Core_AreVoiceControlsEnabled = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 787373906810962396UL, Core_AreVoiceControlsEnabledFallback); @@ -3663,9 +3725,13 @@ public ClientLibrary(Dictionary funcTable) Core_GetPedBonePos = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9678094278922411472UL, Core_GetPedBonePosFallback); Core_GetPermissionState = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6070013237365852957UL, Core_GetPermissionStateFallback); Core_GetPing = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17183361268059997356UL, Core_GetPingFallback); + Core_GetPoolCount = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10058355141969516360UL, Core_GetPoolCountFallback); + Core_GetPoolEntities = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5989408698388544472UL, Core_GetPoolEntitiesFallback); + Core_GetPoolSize = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3048778071876483320UL, Core_GetPoolSizeFallback); Core_GetScreenResolution = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16078537130538515891UL, Core_GetScreenResolutionFallback); Core_GetServerIp = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1389091625205062844UL, Core_GetServerIpFallback); Core_GetServerPort = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14148467334937601992UL, Core_GetServerPortFallback); + Core_GetServerTime = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8910809418132103019UL, Core_GetServerTimeFallback); Core_GetStatBool = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4132285709171755304UL, Core_GetStatBoolFallback); Core_GetStatData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 311843349031918009UL, Core_GetStatDataFallback); Core_GetStatFloat = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 175428875067811253UL, Core_GetStatFloatFallback); @@ -3681,7 +3747,11 @@ public ClientLibrary(Dictionary funcTable) Core_GetTotalPacketsSent = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16154816553672886942UL, Core_GetTotalPacketsSentFallback); Core_GetVoiceActivationKey = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2249875648683273533UL, Core_GetVoiceActivationKeyFallback); Core_GetVoiceActivationLevel = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14311678038566163090UL, Core_GetVoiceActivationLevelFallback); + Core_GetVoiceFilter = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15381961310249968205UL, Core_GetVoiceFilterFallback); Core_GetVoiceInputMuted = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14294729290243559040UL, Core_GetVoiceInputMutedFallback); + Core_GetVoiceNonSpatialVolume = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14180673522110201914UL, Core_GetVoiceNonSpatialVolumeFallback); + Core_GetVoicePlayers = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 759879643372796676UL, Core_GetVoicePlayersFallback); + Core_GetVoiceSpatialVolume = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10827389293122297015UL, Core_GetVoiceSpatialVolumeFallback); Core_GetWeaponObjects = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18342201422886872407UL, Core_GetWeaponObjectsFallback); Core_GetWebViewCount = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5500487167100623739UL, Core_GetWebViewCountFallback); Core_GetWebViews = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8710938014357466262UL, Core_GetWebViewsFallback); @@ -3713,6 +3783,8 @@ public ClientLibrary(Dictionary funcTable) Core_RegisterFont = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 84574382701044016UL, Core_RegisterFontFallback); Core_RemoveGXTText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2950682702415179672UL, Core_RemoveGXTTextFallback); Core_RemoveIpl = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3186817815537256556UL, Core_RemoveIplFallback); + Core_RemoveVoiceFilter = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4203146524234440953UL, Core_RemoveVoiceFilterFallback); + Core_RemoveVoicePlayer = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15949102402945152498UL, Core_RemoveVoicePlayerFallback); Core_RequestIpl = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6993510006268976715UL, Core_RequestIplFallback); Core_ResetAllMapZoomData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 664982279299386907UL, Core_ResetAllMapZoomDataFallback); Core_ResetMapZoomData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12948735896839739671UL, Core_ResetMapZoomDataFallback); @@ -3739,6 +3811,8 @@ public ClientLibrary(Dictionary funcTable) Core_SetStatUInt8 = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15051718600062446893UL, Core_SetStatUInt8Fallback); Core_SetVoiceActivationLevel = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6366517826241888414UL, Core_SetVoiceActivationLevelFallback); Core_SetVoiceInputMuted = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7814638701493567231UL, Core_SetVoiceInputMutedFallback); + Core_SetVoiceNonSpatialVolume = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8870406345125653689UL, Core_SetVoiceNonSpatialVolumeFallback); + Core_SetVoiceSpatialVolume = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8791822899861925122UL, Core_SetVoiceSpatialVolumeFallback); Core_SetWatermarkPosition = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7934747004301392615UL, Core_SetWatermarkPositionFallback); Core_SetWeatherCycle = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16585286735482336540UL, Core_SetWeatherCycleFallback); Core_SetWeatherSyncActive = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13045279996168078519UL, Core_SetWeatherSyncActiveFallback); @@ -3758,10 +3832,12 @@ public ClientLibrary(Dictionary funcTable) Core_TriggerServerRPCEvent = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5920144219377072122UL, Core_TriggerServerRPCEventFallback); Core_TriggerWebViewEvent = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3268039739443301173UL, Core_TriggerWebViewEventFallback); Core_UnloadYtyp = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17753040748478874447UL, Core_UnloadYtypFallback); + Core_UpdateClipContext = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17801058509158105354UL, Core_UpdateClipContextFallback); Core_WorldToScreen = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5389506501733691988UL, Core_WorldToScreenFallback); CustomTexture_GetBaseObject = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4168880360490742954UL, CustomTexture_GetBaseObjectFallback); CustomTexture_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12755828446518747613UL, CustomTexture_GetIDFallback); Entity_GetScriptID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11915813456855488252UL, Entity_GetScriptIDFallback); + Entity_GetSyncInfo = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18237250479106097113UL, Entity_GetSyncInfoFallback); Event_SetAnyResourceErrorDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14079997901958077241UL, Event_SetAnyResourceErrorDelegateFallback); Event_SetAnyResourceStartDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18259284189737259993UL, Event_SetAnyResourceStartDelegateFallback); Event_SetAnyResourceStopDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13707820718504089625UL, Event_SetAnyResourceStopDelegateFallback); diff --git a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs index 488d29842f..40111dcaab 100644 --- a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs @@ -1,5 +1,6 @@ // ReSharper disable InconsistentNaming using AltV.Net.Data; +using AltV.Net.CApi.Data; using System.Numerics; using System.Runtime.InteropServices; using AltV.Net.Elements.Args; @@ -30,7 +31,6 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetAuthToken { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetBaseObject { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetBranch { get; } - public delegate* unmanaged[Cdecl] ConnectionInfo_GetBuild { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCdnUrl { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudAuthResult { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudID { get; } @@ -45,6 +45,8 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetSocialId { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetSocialName { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetText { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetVersionMajor { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetVersionMinor { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_IsAccepted { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_SetText { get; } public delegate* unmanaged[Cdecl] Core_AddClientConfigKey { get; } @@ -155,14 +157,15 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] Ped_SetCurrentWeapon { get; } public delegate* unmanaged[Cdecl] Ped_SetHealth { get; } public delegate* unmanaged[Cdecl] Ped_SetMaxHealth { get; } - public delegate* unmanaged[Cdecl] Player_AddDecoration { get; } + public delegate* unmanaged[Cdecl] Player_AddDecoration { get; } public delegate* unmanaged[Cdecl] Player_AddWeaponComponent { get; } public delegate* unmanaged[Cdecl] Player_ClearBloodDamage { get; } + public delegate* unmanaged[Cdecl] Player_ClearClothes { get; } public delegate* unmanaged[Cdecl] Player_ClearDecorations { get; } public delegate* unmanaged[Cdecl] Player_ClearProps { get; } public delegate* unmanaged[Cdecl] Player_ClearTasks { get; } public delegate* unmanaged[Cdecl] Player_DeallocAmmoFlags { get; } - public delegate* unmanaged[Cdecl] Player_DeallocVehicleModelInfo { get; } + public delegate* unmanaged[Cdecl] Player_DeallocDecoration { get; } public delegate* unmanaged[Cdecl] Player_DeleteLocalMetaData { get; } public delegate* unmanaged[Cdecl] Player_Despawn { get; } public delegate* unmanaged[Cdecl] Player_GetAmmo { get; } @@ -222,6 +225,7 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] Player_RemoveDecoration { get; } public delegate* unmanaged[Cdecl] Player_RemoveFaceFeature { get; } public delegate* unmanaged[Cdecl] Player_RemoveHeadBlendData { get; } + public delegate* unmanaged[Cdecl] Player_RemoveHeadBlendPaletteColor { get; } public delegate* unmanaged[Cdecl] Player_RemoveHeadOverlay { get; } public delegate* unmanaged[Cdecl] Player_RemoveWeapon { get; } public delegate* unmanaged[Cdecl] Player_RemoveWeaponComponent { get; } @@ -379,6 +383,7 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] Vehicle_Repair { get; } public delegate* unmanaged[Cdecl] Vehicle_SetArmoredWindowHealth { get; } public delegate* unmanaged[Cdecl] Vehicle_SetArmoredWindowShootCount { get; } + public delegate* unmanaged[Cdecl] Vehicle_SetBadge { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBoatAnchor { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBodyAdditionalHealth { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBodyHealth { get; } @@ -480,7 +485,7 @@ public unsafe interface IServerLibrary public unsafe class ServerLibrary : IServerLibrary { - public readonly uint Methods = 1738; + public readonly uint Methods = 1770; public delegate* unmanaged[Cdecl] BaseObject_DeleteSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetMultipleSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetSyncedMetaData { get; } @@ -501,7 +506,6 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetAuthToken { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetBaseObject { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetBranch { get; } - public delegate* unmanaged[Cdecl] ConnectionInfo_GetBuild { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCdnUrl { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudAuthResult { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudID { get; } @@ -516,6 +520,8 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetSocialId { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetSocialName { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetText { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetVersionMajor { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetVersionMinor { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_IsAccepted { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_SetText { get; } public delegate* unmanaged[Cdecl] Core_AddClientConfigKey { get; } @@ -626,14 +632,15 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] Ped_SetCurrentWeapon { get; } public delegate* unmanaged[Cdecl] Ped_SetHealth { get; } public delegate* unmanaged[Cdecl] Ped_SetMaxHealth { get; } - public delegate* unmanaged[Cdecl] Player_AddDecoration { get; } + public delegate* unmanaged[Cdecl] Player_AddDecoration { get; } public delegate* unmanaged[Cdecl] Player_AddWeaponComponent { get; } public delegate* unmanaged[Cdecl] Player_ClearBloodDamage { get; } + public delegate* unmanaged[Cdecl] Player_ClearClothes { get; } public delegate* unmanaged[Cdecl] Player_ClearDecorations { get; } public delegate* unmanaged[Cdecl] Player_ClearProps { get; } public delegate* unmanaged[Cdecl] Player_ClearTasks { get; } public delegate* unmanaged[Cdecl] Player_DeallocAmmoFlags { get; } - public delegate* unmanaged[Cdecl] Player_DeallocVehicleModelInfo { get; } + public delegate* unmanaged[Cdecl] Player_DeallocDecoration { get; } public delegate* unmanaged[Cdecl] Player_DeleteLocalMetaData { get; } public delegate* unmanaged[Cdecl] Player_Despawn { get; } public delegate* unmanaged[Cdecl] Player_GetAmmo { get; } @@ -693,6 +700,7 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] Player_RemoveDecoration { get; } public delegate* unmanaged[Cdecl] Player_RemoveFaceFeature { get; } public delegate* unmanaged[Cdecl] Player_RemoveHeadBlendData { get; } + public delegate* unmanaged[Cdecl] Player_RemoveHeadBlendPaletteColor { get; } public delegate* unmanaged[Cdecl] Player_RemoveHeadOverlay { get; } public delegate* unmanaged[Cdecl] Player_RemoveWeapon { get; } public delegate* unmanaged[Cdecl] Player_RemoveWeaponComponent { get; } @@ -850,6 +858,7 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] Vehicle_Repair { get; } public delegate* unmanaged[Cdecl] Vehicle_SetArmoredWindowHealth { get; } public delegate* unmanaged[Cdecl] Vehicle_SetArmoredWindowShootCount { get; } + public delegate* unmanaged[Cdecl] Vehicle_SetBadge { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBoatAnchor { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBodyAdditionalHealth { get; } public delegate* unmanaged[Cdecl] Vehicle_SetBodyHealth { get; } @@ -987,8 +996,6 @@ public unsafe class ServerLibrary : IServerLibrary private static nint ConnectionInfo_GetBaseObjectFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetBaseObject", "ConnectionInfo_GetBaseObject SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint ConnectionInfo_GetBranchDelegate(IntPtr _connectionInfo, int* _size); private static nint ConnectionInfo_GetBranchFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetBranch", "ConnectionInfo_GetBranch SDK method is outdated. Please update your module nuget"); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint ConnectionInfo_GetBuildDelegate(IntPtr _connectionInfo); - private static uint ConnectionInfo_GetBuildFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetBuild", "ConnectionInfo_GetBuild SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint ConnectionInfo_GetCdnUrlDelegate(IntPtr _connectionInfo, int* _size); private static nint ConnectionInfo_GetCdnUrlFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetCdnUrl", "ConnectionInfo_GetCdnUrl SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte ConnectionInfo_GetCloudAuthResultDelegate(IntPtr _connectionInfo); @@ -1017,6 +1024,10 @@ public unsafe class ServerLibrary : IServerLibrary private static nint ConnectionInfo_GetSocialNameFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetSocialName", "ConnectionInfo_GetSocialName SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint ConnectionInfo_GetTextDelegate(IntPtr _connectionInfo, int* _size); private static nint ConnectionInfo_GetTextFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetText", "ConnectionInfo_GetText SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort ConnectionInfo_GetVersionMajorDelegate(IntPtr _connectionInfo); + private static ushort ConnectionInfo_GetVersionMajorFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetVersionMajor", "ConnectionInfo_GetVersionMajor SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ushort ConnectionInfo_GetVersionMinorDelegate(IntPtr _connectionInfo); + private static ushort ConnectionInfo_GetVersionMinorFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetVersionMinor", "ConnectionInfo_GetVersionMinor SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte ConnectionInfo_IsAcceptedDelegate(IntPtr _connectionInfo); private static byte ConnectionInfo_IsAcceptedFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_IsAccepted", "ConnectionInfo_IsAccepted SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void ConnectionInfo_SetTextDelegate(IntPtr _connectionInfo, nint _text); @@ -1237,12 +1248,14 @@ public unsafe class ServerLibrary : IServerLibrary private static void Ped_SetHealthFallback(nint _ped, ushort _health) => throw new Exceptions.OutdatedSdkException("Ped_SetHealth", "Ped_SetHealth SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Ped_SetMaxHealthDelegate(nint _ped, ushort _maxHealth); private static void Ped_SetMaxHealthFallback(nint _ped, ushort _maxHealth) => throw new Exceptions.OutdatedSdkException("Ped_SetMaxHealth", "Ped_SetMaxHealth SDK method is outdated. Please update your module nuget"); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_AddDecorationDelegate(nint _player, uint _collection, uint _overlay); - private static void Player_AddDecorationFallback(nint _player, uint _collection, uint _overlay) => throw new Exceptions.OutdatedSdkException("Player_AddDecoration", "Player_AddDecoration SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_AddDecorationDelegate(nint _player, uint _collection, uint _overlay, byte _count); + private static void Player_AddDecorationFallback(nint _player, uint _collection, uint _overlay, byte _count) => throw new Exceptions.OutdatedSdkException("Player_AddDecoration", "Player_AddDecoration SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_AddWeaponComponentDelegate(nint _player, uint _weapon, uint _component); private static void Player_AddWeaponComponentFallback(nint _player, uint _weapon, uint _component) => throw new Exceptions.OutdatedSdkException("Player_AddWeaponComponent", "Player_AddWeaponComponent SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_ClearBloodDamageDelegate(nint _player); private static void Player_ClearBloodDamageFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_ClearBloodDamage", "Player_ClearBloodDamage SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_ClearClothesDelegate(nint _player, byte _component); + private static byte Player_ClearClothesFallback(nint _player, byte _component) => throw new Exceptions.OutdatedSdkException("Player_ClearClothes", "Player_ClearClothes SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_ClearDecorationsDelegate(nint _player); private static void Player_ClearDecorationsFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_ClearDecorations", "Player_ClearDecorations SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_ClearPropsDelegate(nint _player, byte _component); @@ -1251,8 +1264,8 @@ public unsafe class ServerLibrary : IServerLibrary private static void Player_ClearTasksFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_ClearTasks", "Player_ClearTasks SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_DeallocAmmoFlagsDelegate(nint _ammoFlags); private static void Player_DeallocAmmoFlagsFallback(nint _ammoFlags) => throw new Exceptions.OutdatedSdkException("Player_DeallocAmmoFlags", "Player_DeallocAmmoFlags SDK method is outdated. Please update your module nuget"); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_DeallocVehicleModelInfoDelegate(nint _decoInfo); - private static void Player_DeallocVehicleModelInfoFallback(nint _decoInfo) => throw new Exceptions.OutdatedSdkException("Player_DeallocVehicleModelInfo", "Player_DeallocVehicleModelInfo SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_DeallocDecorationDelegate(nint _decoInfo); + private static void Player_DeallocDecorationFallback(nint _decoInfo) => throw new Exceptions.OutdatedSdkException("Player_DeallocDecoration", "Player_DeallocDecoration SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_DeleteLocalMetaDataDelegate(nint _player, nint _key); private static void Player_DeleteLocalMetaDataFallback(nint _player, nint _key) => throw new Exceptions.OutdatedSdkException("Player_DeleteLocalMetaData", "Player_DeleteLocalMetaData SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_DespawnDelegate(nint _player); @@ -1371,6 +1384,8 @@ public unsafe class ServerLibrary : IServerLibrary private static byte Player_RemoveFaceFeatureFallback(nint _player, byte _index) => throw new Exceptions.OutdatedSdkException("Player_RemoveFaceFeature", "Player_RemoveFaceFeature SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_RemoveHeadBlendDataDelegate(nint _player); private static void Player_RemoveHeadBlendDataFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_RemoveHeadBlendData", "Player_RemoveHeadBlendData SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_RemoveHeadBlendPaletteColorDelegate(nint _player); + private static void Player_RemoveHeadBlendPaletteColorFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_RemoveHeadBlendPaletteColor", "Player_RemoveHeadBlendPaletteColor SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_RemoveHeadOverlayDelegate(nint _player, byte _overlayID); private static byte Player_RemoveHeadOverlayFallback(nint _player, byte _overlayID) => throw new Exceptions.OutdatedSdkException("Player_RemoveHeadOverlay", "Player_RemoveHeadOverlay SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_RemoveWeaponDelegate(nint _player, uint _weapon); @@ -1685,6 +1700,8 @@ public unsafe class ServerLibrary : IServerLibrary private static void Vehicle_SetArmoredWindowHealthFallback(nint _vehicle, byte _windowId, float _health) => throw new Exceptions.OutdatedSdkException("Vehicle_SetArmoredWindowHealth", "Vehicle_SetArmoredWindowHealth SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Vehicle_SetArmoredWindowShootCountDelegate(nint _vehicle, byte _windowId, byte _count); private static void Vehicle_SetArmoredWindowShootCountFallback(nint _vehicle, byte _windowId, byte _count) => throw new Exceptions.OutdatedSdkException("Vehicle_SetArmoredWindowShootCount", "Vehicle_SetArmoredWindowShootCount SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Vehicle_SetBadgeDelegate(nint _vehicle, uint _textureDictionary, uint _texture, VehicleBadgePosition[] vehicleBadgePosition, ushort _size); + private static void Vehicle_SetBadgeFallback(nint _vehicle, uint _textureDictionary, uint _texture, VehicleBadgePosition[] vehicleBadgePosition, ushort _size) => throw new Exceptions.OutdatedSdkException("Vehicle_SetBadge", "Vehicle_SetBadge SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Vehicle_SetBoatAnchorDelegate(nint _vehicle, byte _state); private static void Vehicle_SetBoatAnchorFallback(nint _vehicle, byte _state) => throw new Exceptions.OutdatedSdkException("Vehicle_SetBoatAnchor", "Vehicle_SetBoatAnchor SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Vehicle_SetBodyAdditionalHealthDelegate(nint _vehicle, uint _health); @@ -1888,7 +1905,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 != 13325244553859733034UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) 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); @@ -1909,7 +1926,6 @@ public ServerLibrary(Dictionary funcTable) ConnectionInfo_GetAuthToken = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8194004283135524333UL, ConnectionInfo_GetAuthTokenFallback); ConnectionInfo_GetBaseObject = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12397496971801767822UL, ConnectionInfo_GetBaseObjectFallback); ConnectionInfo_GetBranch = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1577439110274874884UL, ConnectionInfo_GetBranchFallback); - ConnectionInfo_GetBuild = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14204191833155309704UL, ConnectionInfo_GetBuildFallback); ConnectionInfo_GetCdnUrl = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5988681596904693572UL, ConnectionInfo_GetCdnUrlFallback); ConnectionInfo_GetCloudAuthResult = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7415605567391116903UL, ConnectionInfo_GetCloudAuthResultFallback); ConnectionInfo_GetCloudID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7998061229071288348UL, ConnectionInfo_GetCloudIDFallback); @@ -1924,6 +1940,8 @@ public ServerLibrary(Dictionary funcTable) ConnectionInfo_GetSocialId = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10464338232675126241UL, ConnectionInfo_GetSocialIdFallback); ConnectionInfo_GetSocialName = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12079559810042444284UL, ConnectionInfo_GetSocialNameFallback); ConnectionInfo_GetText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15232547943166326905UL, ConnectionInfo_GetTextFallback); + ConnectionInfo_GetVersionMajor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17632900701407653009UL, ConnectionInfo_GetVersionMajorFallback); + ConnectionInfo_GetVersionMinor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5117935778920368749UL, ConnectionInfo_GetVersionMinorFallback); ConnectionInfo_IsAccepted = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8806505177995284480UL, ConnectionInfo_IsAcceptedFallback); ConnectionInfo_SetText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13680172646316204766UL, ConnectionInfo_SetTextFallback); Core_AddClientConfigKey = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17282535440709139868UL, Core_AddClientConfigKeyFallback); @@ -2034,14 +2052,15 @@ public ServerLibrary(Dictionary funcTable) Ped_SetCurrentWeapon = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1890144317981520558UL, Ped_SetCurrentWeaponFallback); Ped_SetHealth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15651278310887155719UL, Ped_SetHealthFallback); Ped_SetMaxHealth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 487582698440451683UL, Ped_SetMaxHealthFallback); - Player_AddDecoration = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11189476182745634495UL, Player_AddDecorationFallback); + Player_AddDecoration = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4335399707847968795UL, Player_AddDecorationFallback); Player_AddWeaponComponent = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9305362021789278268UL, Player_AddWeaponComponentFallback); Player_ClearBloodDamage = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1935399752104807234UL, Player_ClearBloodDamageFallback); + Player_ClearClothes = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 992364219024894490UL, Player_ClearClothesFallback); Player_ClearDecorations = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1193224569935073604UL, Player_ClearDecorationsFallback); Player_ClearProps = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14293729102633233291UL, Player_ClearPropsFallback); Player_ClearTasks = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2394928316223850939UL, Player_ClearTasksFallback); Player_DeallocAmmoFlags = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17674808600712417948UL, Player_DeallocAmmoFlagsFallback); - Player_DeallocVehicleModelInfo = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10260708090721922895UL, Player_DeallocVehicleModelInfoFallback); + Player_DeallocDecoration = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11055092498025975234UL, Player_DeallocDecorationFallback); Player_DeleteLocalMetaData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18350138927152444768UL, Player_DeleteLocalMetaDataFallback); Player_Despawn = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10068978925729858744UL, Player_DespawnFallback); Player_GetAmmo = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6890209545812653225UL, Player_GetAmmoFallback); @@ -2101,6 +2120,7 @@ public ServerLibrary(Dictionary funcTable) Player_RemoveDecoration = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3139723963307924640UL, Player_RemoveDecorationFallback); Player_RemoveFaceFeature = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1204109734587833282UL, Player_RemoveFaceFeatureFallback); Player_RemoveHeadBlendData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8805714842908729165UL, Player_RemoveHeadBlendDataFallback); + Player_RemoveHeadBlendPaletteColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6835192118570564879UL, Player_RemoveHeadBlendPaletteColorFallback); Player_RemoveHeadOverlay = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12300710546613769705UL, Player_RemoveHeadOverlayFallback); Player_RemoveWeapon = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6739305111416325852UL, Player_RemoveWeaponFallback); Player_RemoveWeaponComponent = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 937601034617427157UL, Player_RemoveWeaponComponentFallback); @@ -2258,6 +2278,7 @@ public ServerLibrary(Dictionary funcTable) Vehicle_Repair = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 277481303661922113UL, Vehicle_RepairFallback); Vehicle_SetArmoredWindowHealth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1070345202824576095UL, Vehicle_SetArmoredWindowHealthFallback); Vehicle_SetArmoredWindowShootCount = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4149223353503655708UL, Vehicle_SetArmoredWindowShootCountFallback); + Vehicle_SetBadge = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15010482901293452804UL, Vehicle_SetBadgeFallback); Vehicle_SetBoatAnchor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16890059088943800731UL, Vehicle_SetBoatAnchorFallback); Vehicle_SetBodyAdditionalHealth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 5545167983491514394UL, Vehicle_SetBodyAdditionalHealthFallback); Vehicle_SetBodyHealth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13734895793996634557UL, Vehicle_SetBodyHealthFallback); diff --git a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs index 8e656a3119..8e8745ae99 100644 --- a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs @@ -1,5 +1,6 @@ // ReSharper disable InconsistentNaming using AltV.Net.Data; +using AltV.Net.CApi.Data; using System.Numerics; using System.Runtime.InteropServices; using AltV.Net.Elements.Args; @@ -246,6 +247,7 @@ public unsafe interface ISharedLibrary public delegate* unmanaged[Cdecl] FreeResourceArray { get; } public delegate* unmanaged[Cdecl] FreeString { get; } public delegate* unmanaged[Cdecl] FreeStringArray { get; } + public delegate* unmanaged[Cdecl] FreeSyncInfo { get; } public delegate* unmanaged[Cdecl] FreeTextLabelArray { get; } public delegate* unmanaged[Cdecl] FreeUInt32Array { get; } public delegate* unmanaged[Cdecl] FreeUInt8Array { get; } @@ -369,20 +371,32 @@ public unsafe interface ISharedLibrary public delegate* unmanaged[Cdecl] Resource_SetExport { get; } public delegate* unmanaged[Cdecl] Resource_SetExports { get; } public delegate* unmanaged[Cdecl] RmlDocument_GetID { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetAlign { get; } public delegate* unmanaged[Cdecl] TextLabel_GetColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetFont { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetFontSize { get; } public delegate* unmanaged[Cdecl] TextLabel_GetID { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetOutlineColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetOutlineWidth { get; } public delegate* unmanaged[Cdecl] TextLabel_GetRotation { get; } public delegate* unmanaged[Cdecl] TextLabel_GetScale { get; } public delegate* unmanaged[Cdecl] TextLabel_GetStreamingDistance { get; } public delegate* unmanaged[Cdecl] TextLabel_GetTarget { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetText { get; } public delegate* unmanaged[Cdecl] TextLabel_GetWorldObject { get; } public delegate* unmanaged[Cdecl] TextLabel_IsFacingCamera { get; } public delegate* unmanaged[Cdecl] TextLabel_IsGlobal { get; } public delegate* unmanaged[Cdecl] TextLabel_IsVisible { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetAlign { get; } public delegate* unmanaged[Cdecl] TextLabel_SetColor { get; } public delegate* unmanaged[Cdecl] TextLabel_SetFaceCamera { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetFont { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetFontSize { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetOutlineColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetOutlineWidth { get; } public delegate* unmanaged[Cdecl] TextLabel_SetRotation { get; } public delegate* unmanaged[Cdecl] TextLabel_SetScale { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetText { get; } public delegate* unmanaged[Cdecl] TextLabel_SetVisible { get; } public delegate* unmanaged[Cdecl] Vehicle_GetEntity { get; } public delegate* unmanaged[Cdecl] Vehicle_GetID { get; } @@ -412,7 +426,7 @@ public unsafe interface ISharedLibrary public unsafe class SharedLibrary : ISharedLibrary { - public readonly uint Methods = 1738; + public readonly uint Methods = 1770; public delegate* unmanaged[Cdecl] Audio_GetID { get; } public delegate* unmanaged[Cdecl] AudioAttachedOutput_GetID { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetID { get; } @@ -649,6 +663,7 @@ public unsafe class SharedLibrary : ISharedLibrary public delegate* unmanaged[Cdecl] FreeResourceArray { get; } public delegate* unmanaged[Cdecl] FreeString { get; } public delegate* unmanaged[Cdecl] FreeStringArray { get; } + public delegate* unmanaged[Cdecl] FreeSyncInfo { get; } public delegate* unmanaged[Cdecl] FreeTextLabelArray { get; } public delegate* unmanaged[Cdecl] FreeUInt32Array { get; } public delegate* unmanaged[Cdecl] FreeUInt8Array { get; } @@ -772,20 +787,32 @@ public unsafe class SharedLibrary : ISharedLibrary public delegate* unmanaged[Cdecl] Resource_SetExport { get; } public delegate* unmanaged[Cdecl] Resource_SetExports { get; } public delegate* unmanaged[Cdecl] RmlDocument_GetID { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetAlign { get; } public delegate* unmanaged[Cdecl] TextLabel_GetColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetFont { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetFontSize { get; } public delegate* unmanaged[Cdecl] TextLabel_GetID { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetOutlineColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetOutlineWidth { get; } public delegate* unmanaged[Cdecl] TextLabel_GetRotation { get; } public delegate* unmanaged[Cdecl] TextLabel_GetScale { get; } public delegate* unmanaged[Cdecl] TextLabel_GetStreamingDistance { get; } public delegate* unmanaged[Cdecl] TextLabel_GetTarget { get; } + public delegate* unmanaged[Cdecl] TextLabel_GetText { get; } public delegate* unmanaged[Cdecl] TextLabel_GetWorldObject { get; } public delegate* unmanaged[Cdecl] TextLabel_IsFacingCamera { get; } public delegate* unmanaged[Cdecl] TextLabel_IsGlobal { get; } public delegate* unmanaged[Cdecl] TextLabel_IsVisible { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetAlign { get; } public delegate* unmanaged[Cdecl] TextLabel_SetColor { get; } public delegate* unmanaged[Cdecl] TextLabel_SetFaceCamera { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetFont { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetFontSize { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetOutlineColor { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetOutlineWidth { get; } public delegate* unmanaged[Cdecl] TextLabel_SetRotation { get; } public delegate* unmanaged[Cdecl] TextLabel_SetScale { get; } + public delegate* unmanaged[Cdecl] TextLabel_SetText { get; } public delegate* unmanaged[Cdecl] TextLabel_SetVisible { get; } public delegate* unmanaged[Cdecl] Vehicle_GetEntity { get; } public delegate* unmanaged[Cdecl] Vehicle_GetID { get; } @@ -1283,6 +1310,8 @@ public unsafe class SharedLibrary : ISharedLibrary private static void FreeStringFallback(nint _string) => throw new Exceptions.OutdatedSdkException("FreeString", "FreeString SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void FreeStringArrayDelegate(nint _stringArray, uint _size); private static void FreeStringArrayFallback(nint _stringArray, uint _size) => throw new Exceptions.OutdatedSdkException("FreeStringArray", "FreeStringArray SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void FreeSyncInfoDelegate(nint _syncInfo); + private static void FreeSyncInfoFallback(nint _syncInfo) => throw new Exceptions.OutdatedSdkException("FreeSyncInfo", "FreeSyncInfo SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void FreeTextLabelArrayDelegate(nint _textLabelArray); private static void FreeTextLabelArrayFallback(nint _textLabelArray) => throw new Exceptions.OutdatedSdkException("FreeTextLabelArray", "FreeTextLabelArray SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void FreeUInt32ArrayDelegate(nint _uInt32Array); @@ -1529,10 +1558,20 @@ public unsafe class SharedLibrary : ISharedLibrary private static void Resource_SetExportsFallback(nint _core, nint _resource, nint[] val, nint[] keys, int _size) => throw new Exceptions.OutdatedSdkException("Resource_SetExports", "Resource_SetExports SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint RmlDocument_GetIDDelegate(nint _rmlDocument); private static uint RmlDocument_GetIDFallback(nint _rmlDocument) => throw new Exceptions.OutdatedSdkException("RmlDocument_GetID", "RmlDocument_GetID SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte TextLabel_GetAlignDelegate(nint _textLabel); + private static byte TextLabel_GetAlignFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetAlign", "TextLabel_GetAlign SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_GetColorDelegate(nint _textLabel, Rgba* _color); private static void TextLabel_GetColorFallback(nint _textLabel, Rgba* _color) => throw new Exceptions.OutdatedSdkException("TextLabel_GetColor", "TextLabel_GetColor SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint TextLabel_GetFontDelegate(nint _textLabel, int* _size); + private static nint TextLabel_GetFontFallback(nint _textLabel, int* _size) => throw new Exceptions.OutdatedSdkException("TextLabel_GetFont", "TextLabel_GetFont SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float TextLabel_GetFontSizeDelegate(nint _textLabel); + private static float TextLabel_GetFontSizeFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetFontSize", "TextLabel_GetFontSize SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint TextLabel_GetIDDelegate(nint _textLabel); private static uint TextLabel_GetIDFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetID", "TextLabel_GetID SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_GetOutlineColorDelegate(nint _textLabel, Rgba* _color); + private static void TextLabel_GetOutlineColorFallback(nint _textLabel, Rgba* _color) => throw new Exceptions.OutdatedSdkException("TextLabel_GetOutlineColor", "TextLabel_GetOutlineColor SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float TextLabel_GetOutlineWidthDelegate(nint _textLabel); + private static float TextLabel_GetOutlineWidthFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetOutlineWidth", "TextLabel_GetOutlineWidth SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_GetRotationDelegate(nint _textLabel, Rotation* _rot); private static void TextLabel_GetRotationFallback(nint _textLabel, Rotation* _rot) => throw new Exceptions.OutdatedSdkException("TextLabel_GetRotation", "TextLabel_GetRotation SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate float TextLabel_GetScaleDelegate(nint _textLabel); @@ -1541,6 +1580,8 @@ public unsafe class SharedLibrary : ISharedLibrary private static uint TextLabel_GetStreamingDistanceFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetStreamingDistance", "TextLabel_GetStreamingDistance SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint TextLabel_GetTargetDelegate(nint _textLabel); private static nint TextLabel_GetTargetFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetTarget", "TextLabel_GetTarget SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint TextLabel_GetTextDelegate(nint _textLabel, int* _size); + private static nint TextLabel_GetTextFallback(nint _textLabel, int* _size) => throw new Exceptions.OutdatedSdkException("TextLabel_GetText", "TextLabel_GetText SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint TextLabel_GetWorldObjectDelegate(nint _textLabel); private static nint TextLabel_GetWorldObjectFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_GetWorldObject", "TextLabel_GetWorldObject SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte TextLabel_IsFacingCameraDelegate(nint _textLabel); @@ -1549,14 +1590,26 @@ public unsafe class SharedLibrary : ISharedLibrary private static byte TextLabel_IsGlobalFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_IsGlobal", "TextLabel_IsGlobal SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte TextLabel_IsVisibleDelegate(nint _textLabel); private static byte TextLabel_IsVisibleFallback(nint _textLabel) => throw new Exceptions.OutdatedSdkException("TextLabel_IsVisible", "TextLabel_IsVisible SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetAlignDelegate(nint _textLabel, byte _align); + private static void TextLabel_SetAlignFallback(nint _textLabel, byte _align) => throw new Exceptions.OutdatedSdkException("TextLabel_SetAlign", "TextLabel_SetAlign SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetColorDelegate(nint _textLabel, Rgba _color); private static void TextLabel_SetColorFallback(nint _textLabel, Rgba _color) => throw new Exceptions.OutdatedSdkException("TextLabel_SetColor", "TextLabel_SetColor SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetFaceCameraDelegate(nint _textLabel, byte _faceCamera); private static void TextLabel_SetFaceCameraFallback(nint _textLabel, byte _faceCamera) => throw new Exceptions.OutdatedSdkException("TextLabel_SetFaceCamera", "TextLabel_SetFaceCamera SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetFontDelegate(nint _textLabel, nint _font); + private static void TextLabel_SetFontFallback(nint _textLabel, nint _font) => throw new Exceptions.OutdatedSdkException("TextLabel_SetFont", "TextLabel_SetFont SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetFontSizeDelegate(nint _textLabel, float _size); + private static void TextLabel_SetFontSizeFallback(nint _textLabel, float _size) => throw new Exceptions.OutdatedSdkException("TextLabel_SetFontSize", "TextLabel_SetFontSize SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetOutlineColorDelegate(nint _textLabel, Rgba _color); + private static void TextLabel_SetOutlineColorFallback(nint _textLabel, Rgba _color) => throw new Exceptions.OutdatedSdkException("TextLabel_SetOutlineColor", "TextLabel_SetOutlineColor SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetOutlineWidthDelegate(nint _textLabel, float _width); + private static void TextLabel_SetOutlineWidthFallback(nint _textLabel, float _width) => throw new Exceptions.OutdatedSdkException("TextLabel_SetOutlineWidth", "TextLabel_SetOutlineWidth SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetRotationDelegate(nint _textLabel, Rotation _rot); private static void TextLabel_SetRotationFallback(nint _textLabel, Rotation _rot) => throw new Exceptions.OutdatedSdkException("TextLabel_SetRotation", "TextLabel_SetRotation SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetScaleDelegate(nint _textLabel, float _scale); private static void TextLabel_SetScaleFallback(nint _textLabel, float _scale) => throw new Exceptions.OutdatedSdkException("TextLabel_SetScale", "TextLabel_SetScale SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetTextDelegate(nint _textLabel, nint _text); + private static void TextLabel_SetTextFallback(nint _textLabel, nint _text) => throw new Exceptions.OutdatedSdkException("TextLabel_SetText", "TextLabel_SetText SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void TextLabel_SetVisibleDelegate(nint _textLabel, byte _visible); private static void TextLabel_SetVisibleFallback(nint _textLabel, byte _visible) => throw new Exceptions.OutdatedSdkException("TextLabel_SetVisible", "TextLabel_SetVisible SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Vehicle_GetEntityDelegate(nint _vehicle); @@ -1616,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 != 13325244553859733034UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 18234026019486245283UL) 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); @@ -1853,6 +1906,7 @@ public SharedLibrary(Dictionary funcTable) FreeResourceArray = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7782187912558785270UL, FreeResourceArrayFallback); FreeString = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10646355260907021718UL, FreeStringFallback); FreeStringArray = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9817201133426969670UL, FreeStringArrayFallback); + FreeSyncInfo = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 756563802353195975UL, FreeSyncInfoFallback); FreeTextLabelArray = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 247876811202044668UL, FreeTextLabelArrayFallback); FreeUInt32Array = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2025110884526748511UL, FreeUInt32ArrayFallback); FreeUInt8Array = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15676846424137302955UL, FreeUInt8ArrayFallback); @@ -1976,20 +2030,32 @@ public SharedLibrary(Dictionary funcTable) Resource_SetExport = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15249221947393767886UL, Resource_SetExportFallback); Resource_SetExports = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14077927656531124451UL, Resource_SetExportsFallback); RmlDocument_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4296832302534320657UL, RmlDocument_GetIDFallback); + TextLabel_GetAlign = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 14816944269489448776UL, TextLabel_GetAlignFallback); TextLabel_GetColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 71661853310303691UL, TextLabel_GetColorFallback); + TextLabel_GetFont = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11844719002405795477UL, TextLabel_GetFontFallback); + TextLabel_GetFontSize = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17712816802687836464UL, TextLabel_GetFontSizeFallback); TextLabel_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17469426826709697373UL, TextLabel_GetIDFallback); + TextLabel_GetOutlineColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9286889361477653687UL, TextLabel_GetOutlineColorFallback); + TextLabel_GetOutlineWidth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15484599558868477690UL, TextLabel_GetOutlineWidthFallback); TextLabel_GetRotation = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7785535667614932812UL, TextLabel_GetRotationFallback); TextLabel_GetScale = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13329021670959257864UL, TextLabel_GetScaleFallback); TextLabel_GetStreamingDistance = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9892232591592550017UL, TextLabel_GetStreamingDistanceFallback); TextLabel_GetTarget = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6781195795327060290UL, TextLabel_GetTargetFallback); + TextLabel_GetText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10288308720161428715UL, TextLabel_GetTextFallback); TextLabel_GetWorldObject = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8297185820527489834UL, TextLabel_GetWorldObjectFallback); TextLabel_IsFacingCamera = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2012454944172259572UL, TextLabel_IsFacingCameraFallback); TextLabel_IsGlobal = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17978851917355436422UL, TextLabel_IsGlobalFallback); TextLabel_IsVisible = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15384695376179962647UL, TextLabel_IsVisibleFallback); + TextLabel_SetAlign = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4330021893145796095UL, TextLabel_SetAlignFallback); TextLabel_SetColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1694191866473087021UL, TextLabel_SetColorFallback); TextLabel_SetFaceCamera = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15820914931030469094UL, TextLabel_SetFaceCameraFallback); + TextLabel_SetFont = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12238568229862830842UL, TextLabel_SetFontFallback); + TextLabel_SetFontSize = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 270826682210756999UL, TextLabel_SetFontSizeFallback); + TextLabel_SetOutlineColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 17823771742456553825UL, TextLabel_SetOutlineColorFallback); + TextLabel_SetOutlineWidth = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12181452542389409441UL, TextLabel_SetOutlineWidthFallback); TextLabel_SetRotation = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6102843265505169340UL, TextLabel_SetRotationFallback); TextLabel_SetScale = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3918260719528326415UL, TextLabel_SetScaleFallback); + TextLabel_SetText = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18001120162521415724UL, TextLabel_SetTextFallback); TextLabel_SetVisible = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2302278843105157392UL, TextLabel_SetVisibleFallback); Vehicle_GetEntity = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8318093389193375258UL, Vehicle_GetEntityFallback); Vehicle_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 15007201997776333277UL, Vehicle_GetIDFallback); diff --git a/api/AltV.Net.CApi/Native/AltV.Resource.cs b/api/AltV.Net.CApi/Native/AltV.Resource.cs index 0726da7a3e..f3cf4dac41 100644 --- a/api/AltV.Net.CApi/Native/AltV.Resource.cs +++ b/api/AltV.Net.CApi/Native/AltV.Resource.cs @@ -27,7 +27,7 @@ internal delegate void CheckpointDelegate(IntPtr checkpointPointer, IntPtr entit internal delegate void PlayerConnectDelegate(IntPtr playerPointer, string reason); internal delegate void PlayerConnectDeniedDelegate(PlayerConnectDeniedReason reason, string name, string ip, - ulong passwordHash, byte isDebug, string branch, uint majorVersion, string cdnUrl, long discordId); + ulong passwordHash, byte isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId); internal delegate void ResourceEventDelegate(IntPtr resourcePointer); @@ -100,7 +100,7 @@ internal delegate void VehicleHornDelegate(IntPtr eventPointer, IntPtr targetPoi internal delegate void ServerStartedDelegate(); - internal delegate void PlayerRequestControlDelegate(IntPtr target, BaseObjectType targetType, IntPtr player); + internal delegate void PlayerRequestControlDelegate(IntPtr eventPtr, IntPtr target, BaseObjectType targetType, IntPtr player); internal delegate void PlayerChangeAnimationDelegate(IntPtr target, uint oldDict, uint newDict, uint oldName, uint newName); internal delegate void PlayerChangeInteriorDelegate(IntPtr target, uint oldIntLoc, uint newIntLoc); internal delegate void PlayerDimensionChangeDelegate(IntPtr player, int oldDimension, int newDimension); diff --git a/api/AltV.Net.Client/Alt.GlobalMeta.cs b/api/AltV.Net.Client/Alt.GlobalMeta.cs index 642c907998..cdf0e40c39 100644 --- a/api/AltV.Net.Client/Alt.GlobalMeta.cs +++ b/api/AltV.Net.Client/Alt.GlobalMeta.cs @@ -68,84 +68,37 @@ public static bool GetMetaData(string key, out T result) Core.GetMetaData(key, out var mValue); using (mValue) { - if (!(mValue.ToObject() is T cast)) - { - result = default; - return false; - } - - result = cast; - } - - return true; - } - public static bool GetSyncedMetaData(string key, out int result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Int) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (int) mValue.GetInt(); - } - - return true; - } - - public static bool GetSyncedMetaData(string key, out uint result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + catch { result = default; return false; } - - result = (uint) mValue.GetUint(); } - - return true; } - public static bool GetSyncedMetaData(string key, out float result) + public static bool GetSyncedMetaData(string key, out T result) { Core.GetSyncedMetaData(key, out var mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Double) + + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (float) mValue.GetDouble(); - } - - return true; - } - - public static bool GetSyncedMetaData(string key, out T result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (!(mValue.ToObject() is T cast)) + catch { result = default; return false; } - - result = cast; } - - return true; } public static bool GetLocalMetaData(string key, out T result) @@ -153,14 +106,18 @@ public static bool GetLocalMetaData(string key, out T result) Core.GetLocalMetaData(key, out var mValue); using (mValue) { - if (!(mValue.ToObject() is T cast)) + + try + { + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; + } + catch { result = default; return false; } - result = cast; } - return true; } } } \ No newline at end of file diff --git a/api/AltV.Net.Client/Alt.Globals.cs b/api/AltV.Net.Client/Alt.Globals.cs index a4cf326b9e..5da431870d 100644 --- a/api/AltV.Net.Client/Alt.Globals.cs +++ b/api/AltV.Net.Client/Alt.Globals.cs @@ -1,5 +1,6 @@ using System.Numerics; using AltV.Net.Client.Elements.Data; +using AltV.Net.Client.Elements.Interfaces; using AltV.Net.Data; namespace AltV.Net.Client @@ -76,6 +77,23 @@ public static partial class Alt public static Task TakeScreenshotGameOnly() => Core.TakeScreenshotGameOnly(); public static void RegisterFont(string path) => Core.RegisterFont(path); + public static uint GetPoolSize(string pool) => Core.GetPoolSize(pool); + public static uint GetPoolCount(string pool) => Core.GetPoolCount(pool); + public static uint[] GetPoolEntities(string pool) => Core.GetPoolEntities(pool); + + public static uint[] GetVoicePlayers() => Core.GetVoicePlayers(); + public static void RemoveVoicePlayer(uint playerRemoteId) => Core.RemoveVoicePlayer(playerRemoteId); + public static float GetVoiceSpatialVolume(uint playerRemoteId) => Core.GetVoiceSpatialVolume(playerRemoteId); + public static void SetVoiceSpatialVolume(uint playerRemoteId, float volume) => Core.SetVoiceSpatialVolume(playerRemoteId, volume); + public static float GetVoiceNonSpatialVolume(uint playerRemoteId) => Core.GetVoiceNonSpatialVolume(playerRemoteId); + public static void SetVoiceNonSpatialVolume(uint playerRemoteId, float volume) => Core.SetVoiceNonSpatialVolume(playerRemoteId, volume); + + public static void AddVoiceFilter(uint playerRemoteId, IAudioFilter filter) => Core.AddVoiceFilter(playerRemoteId, filter); + public static void RemoveVoiceFilter(uint playerRemoteId) => Core.RemoveVoiceFilter(playerRemoteId); + public static IAudioFilter GetVoiceFilter(uint playerRemoteId) => Core.GetVoiceFilter(playerRemoteId); + + public static void UpdateClipContext(Dictionary context) => Core.UpdateClipContext(context); + public static MapZoomData GetMapZoomData(uint id) => Core.GetMapZoomData(id); public static MapZoomData GetMapZoomData(string alias) => Core.GetMapZoomData(alias); public static void ResetAllMapZoomData() => Core.ResetAllMapZoomData(); @@ -100,5 +118,7 @@ public static partial class Alt public static bool RmlControlsEnabled { get => Core.RmlControlsEnabled; set => Core.RmlControlsEnabled = value; } public static bool VoiceControlsEnabled { get => Core.VoiceControlsEnabled; set => Core.VoiceControlsEnabled = value; } public static int MsPerGameMinute { get => Core.MsPerGameMinute; set => Core.MsPerGameMinute = value; } + + public static ulong ServerTime => Core.ServerTime; } } \ No newline at end of file diff --git a/api/AltV.Net.Client/Core.Events.cs b/api/AltV.Net.Client/Core.Events.cs index 6be9b255af..10583a98f4 100644 --- a/api/AltV.Net.Client/Core.Events.cs +++ b/api/AltV.Net.Client/Core.Events.cs @@ -705,9 +705,19 @@ public void OnScriptRPCAnswer(ushort answerid, IntPtr answer, string answerError public void OnScriptRPC(IntPtr eventpointer, string name, IntPtr[] args, ushort answerid) { + if (!UnansweredClientRpcRequest.Contains(answerid)) + { + UnansweredClientRpcRequest.Add(answerid); + } var mValues = MValueConst.CreateFrom(this, args); - var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer); + var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer, answerid, true); ScriptRPCHandler.GetEvents().ForEachCatching(fn => fn(clientScriptRPCEvent, name, mValues.Select(x => x.ToObject()).ToArray(), answerid), $"event {nameof(OnScriptRPC)}"); + + if (UnansweredClientRpcRequest.Contains(answerid)) + { + clientScriptRPCEvent.AnswerWithError("Answer not handled"); + UnansweredClientRpcRequest.Remove(answerid); + } } } } \ No newline at end of file diff --git a/api/AltV.Net.Client/Core.Globals.cs b/api/AltV.Net.Client/Core.Globals.cs index b29180e463..bf50b5b795 100644 --- a/api/AltV.Net.Client/Core.Globals.cs +++ b/api/AltV.Net.Client/Core.Globals.cs @@ -539,6 +539,140 @@ public IFont RegisterFont(string path) } } + public uint GetPoolSize(string pool) + { + unsafe + { + var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool); + var result = Library.Client.Core_GetPoolSize(NativePointer, pathPtr); + Marshal.FreeHGlobal(pathPtr); + return result; + } + } + + public uint GetPoolCount(string pool) + { + unsafe + { + var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool); + var result = Library.Client.Core_GetPoolCount(NativePointer, pathPtr); + Marshal.FreeHGlobal(pathPtr); + return result; + } + } + + public uint[] GetPoolEntities(string pool) + { + unsafe + { + uint size = 0; + var entitiesPtr = IntPtr.Zero; + var pathPtr = MemoryUtils.StringToHGlobalUtf8(pool); + Library.Client.Core_GetPoolEntities(NativePointer, pathPtr, &entitiesPtr, &size); + + var uintArray = new UIntArray + { + data = entitiesPtr, + size = size, + capacity = size + }; + + var result = uintArray.ToArray(); + + Library.Shared.FreeUInt32Array(entitiesPtr); + Marshal.FreeHGlobal(pathPtr); + return result; + } + } + + public uint[] GetVoicePlayers() + { + unsafe + { + uint size = 0; + var voicePlayersPtr = IntPtr.Zero; + Library.Client.Core_GetVoicePlayers(NativePointer, &voicePlayersPtr, &size); + + var uintArray = new UIntArray + { + data = voicePlayersPtr, + size = size, + capacity = size + }; + + var result = uintArray.ToArray(); + + Library.Shared.FreeUInt32Array(voicePlayersPtr); + return result; + } + } + + public void RemoveVoicePlayer(uint playerRemoteId) + { + unsafe + { + Library.Client.Core_RemoveVoicePlayer(NativePointer, playerRemoteId); + } + } + + public float GetVoiceSpatialVolume(uint playerRemoteId) + { + unsafe + { + return Library.Client.Core_GetVoiceSpatialVolume(NativePointer, playerRemoteId); + } + } + + public void SetVoiceSpatialVolume(uint playerRemoteId, float volume) + { + unsafe + { + Library.Client.Core_SetVoiceSpatialVolume(NativePointer, playerRemoteId, volume); + } + } + + public float GetVoiceNonSpatialVolume(uint playerRemoteId) + { + unsafe + { + return Library.Client.Core_GetVoiceNonSpatialVolume(NativePointer, playerRemoteId); + } + } + + public void SetVoiceNonSpatialVolume(uint playerRemoteId, float volume) + { + unsafe + { + Library.Client.Core_SetVoiceNonSpatialVolume(NativePointer, playerRemoteId, volume); + } + } + + public void AddVoiceFilter(uint playerRemoteId, IAudioFilter filter) + { + unsafe + { + Library.Client.Core_AddVoiceFilter(NativePointer, playerRemoteId, filter.AudioFilterNativePointer); + } + } + + public void RemoveVoiceFilter(uint playerRemoteId) + { + unsafe + { + Library.Client.Core_RemoveVoiceFilter(NativePointer, playerRemoteId); + } + } + + public IAudioFilter GetVoiceFilter(uint playerRemoteId) + { + unsafe + { + uint pId = default; + var ptr = Library.Client.Core_GetVoiceFilter(NativePointer, playerRemoteId); + return PoolManager.AudioFilter.GetOrCreate(this, ptr, pId); + } + } + public int MsPerGameMinute { get diff --git a/api/AltV.Net.Client/Core.cs b/api/AltV.Net.Client/Core.cs index 08fd28a78d..7e25e6737e 100644 --- a/api/AltV.Net.Client/Core.cs +++ b/api/AltV.Net.Client/Core.cs @@ -704,6 +704,45 @@ public IColShape CreateColShapeSphere(Vector3 position, float radius) return PoolManager.ColShape.Create(this, ptr, id); } + public void UpdateClipContext(Dictionary context) + { + unsafe + { + var data = new Dictionary(); + + var keys = new IntPtr[context.Count]; + var values = new IntPtr[context.Count]; + + for (var i = 0; i < context.Count; i++) + { + var keyptr = MemoryUtils.StringToHGlobalUtf8(context.ElementAt(i).Key); + var valueptr = MemoryUtils.StringToHGlobalUtf8(context.ElementAt(i).Value); + keys[i] = keyptr; + values[i] = valueptr; + data.Add(keyptr, valueptr); + } + + Library.Client.Core_UpdateClipContext(NativePointer, keys, values,(uint)data.Count); + + foreach (var dataValue in data) + { + Marshal.FreeHGlobal(dataValue.Key); + Marshal.FreeHGlobal(dataValue.Value); + } + } + } + + public ulong ServerTime + { + get + { + unsafe + { + return this.Library.Client.Core_GetServerTime(NativePointer); + } + } + } + #endregion #region TriggerServerEvent @@ -828,6 +867,11 @@ public void TriggerServerRPCAnswer(ushort answerId, MValueConst answer, string e Library.Client.Core_TriggerServerRPCAnswer(NativePointer, answerId, answer.nativePointer, errorPtr); Marshal.FreeHGlobal(errorPtr); } + + if (UnansweredClientRpcRequest.Contains(answerId)) + { + UnansweredClientRpcRequest.Remove(answerId); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/api/AltV.Net.Client/Elements/Data/LocalStorage.cs b/api/AltV.Net.Client/Elements/Data/LocalStorage.cs index aac55c7c49..cc3a0bbf78 100644 --- a/api/AltV.Net.Client/Elements/Data/LocalStorage.cs +++ b/api/AltV.Net.Client/Elements/Data/LocalStorage.cs @@ -162,16 +162,18 @@ public bool Get(string key, out T result) Get(key, out MValueConst mValue); using (mValue) { - if (!(mValue.ToObject() is T cast)) + + try + { + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; + } + catch { result = default; return false; } - - result = cast; } - - return true; } } diff --git a/api/AltV.Net.Client/Elements/Data/SyncInfo.cs b/api/AltV.Net.Client/Elements/Data/SyncInfo.cs new file mode 100644 index 0000000000..04cd69063d --- /dev/null +++ b/api/AltV.Net.Client/Elements/Data/SyncInfo.cs @@ -0,0 +1,124 @@ +using System.Runtime.InteropServices; +using AltV.Net.Data; + +namespace AltV.Net.Client.Elements.Data; + + +[StructLayout(LayoutKind.Sequential)] +internal struct SyncInfoInternal +{ + public byte Active; + public uint ReceivedTick; + public uint FullyReceivedTick; + public uint SendTick; + public uint AckedSendTick; + public ushort PropertyCount; + public byte ComponentCount; + public IntPtr PropertyUpdateCount; + public IntPtr PropertyUpdateTicks; + + private uint[] GetCompPropertySize() + { + var value = PropertyUpdateCount; + var values = new uint[ComponentCount]; + var buffer = new byte[4]; + + for (var i = 0; i < values.Length; i++) + { + values[i] = UIntArray.ReadUInt32(buffer, value); + value += UIntArray.UInt32Size; + } + + return values; + } + + private uint[][] GetPropertyUpdateTicks() + { + if (ComponentCount == 0) + { + return default; + } + + var compPropertySize = GetCompPropertySize(); + + uint[][] result = new uint[ComponentCount][]; + + for (var i = 0; i < ComponentCount; i++) + { + result[i] = new uint[compPropertySize[i]]; + + for (var j = 0; j < compPropertySize[i]; j++) + { + // Calculate the index in the one-dimensional array + var index = i * (int)compPropertySize[i] + j; + + // Use Marshal to read the value at the specified index + result[i][j] = (uint)Marshal.PtrToStructure(PropertyUpdateTicks + index * sizeof(uint), typeof(uint)); + } + } + + return result; + } + + public SyncInfo ToPublic() + { + return new SyncInfo( + Active, + ReceivedTick, + FullyReceivedTick, + SendTick, + AckedSendTick, + PropertyCount, + ComponentCount, + GetPropertyUpdateTicks()); + } +} + +[StructLayout(LayoutKind.Sequential)] +public struct SyncInfo : IEquatable +{ + public byte Active; + public uint ReceivedTick; + public uint FullyReceivedTick; + public uint SendTick; + public uint AckedSendTick; + public ushort PropertyCount; + public byte ComponentCount; + public uint[][] PropertyUpdateTicks; + + public SyncInfo(byte active, uint receivedTick, uint fullyReceivedTick, uint sendTick, uint ackedSendTick, ushort propertyCount, byte componentCount, uint[][] propertyUpdateTicks) + { + Active = active; + ReceivedTick = receivedTick; + FullyReceivedTick = fullyReceivedTick; + SendTick = sendTick; + AckedSendTick = ackedSendTick; + PropertyCount = propertyCount; + ComponentCount = componentCount; + PropertyUpdateTicks = propertyUpdateTicks; + } + + public bool Equals(SyncInfo other) + { + return Active == other.Active && ReceivedTick == other.ReceivedTick && FullyReceivedTick == other.FullyReceivedTick && SendTick == other.SendTick && AckedSendTick == other.AckedSendTick && PropertyCount == other.PropertyCount && ComponentCount == other.ComponentCount && PropertyUpdateTicks.Equals(other.PropertyUpdateTicks); + } + + public override bool Equals(object obj) + { + return obj is SyncInfo other && Equals(other); + } + + public override int GetHashCode() + { + var hashCode = new HashCode(); + hashCode.Add(Active); + hashCode.Add(ReceivedTick); + hashCode.Add(FullyReceivedTick); + hashCode.Add(SendTick); + hashCode.Add(AckedSendTick); + hashCode.Add(PropertyCount); + hashCode.Add(ComponentCount); + hashCode.Add(PropertyUpdateTicks); + return hashCode.ToHashCode(); + } +} \ No newline at end of file diff --git a/api/AltV.Net.Client/Elements/Data/TextLabelAlignment.cs b/api/AltV.Net.Client/Elements/Data/TextLabelAlignment.cs new file mode 100644 index 0000000000..ec7852b90d --- /dev/null +++ b/api/AltV.Net.Client/Elements/Data/TextLabelAlignment.cs @@ -0,0 +1,9 @@ +namespace AltV.Net.Client.Elements.Data; + +public enum TextLabelAlignment : byte +{ + AlignLeft, + AlignRight, + AlignCenter, + AlignJustify +} \ No newline at end of file diff --git a/api/AltV.Net.Client/Elements/Entities/Audio.cs b/api/AltV.Net.Client/Elements/Entities/Audio.cs index 524e0570b7..7b04af869b 100644 --- a/api/AltV.Net.Client/Elements/Entities/Audio.cs +++ b/api/AltV.Net.Client/Elements/Entities/Audio.cs @@ -30,12 +30,6 @@ public Audio(ICore core, IntPtr audioNativePointer, uint id) : base(core, GetBas AudioNativePointer = audioNativePointer; } - [Obsolete("Use Alt.CreateAudio instead")] - public Audio(ICore core, string source, float volume) : this(core, core.CreateAudioPtr(out var id,source, volume), id) - { - core.PoolManager.Audio.Add(this); - } - public bool Looped { get diff --git a/api/AltV.Net.Client/Elements/Entities/AudioFilter.cs b/api/AltV.Net.Client/Elements/Entities/AudioFilter.cs index f9375322d1..d206d8b783 100644 --- a/api/AltV.Net.Client/Elements/Entities/AudioFilter.cs +++ b/api/AltV.Net.Client/Elements/Entities/AudioFilter.cs @@ -62,12 +62,12 @@ public uint AddRotateEffect(float fRate, int priority) } } - public uint AddVolumeEffect(float fVolume, int priority) + public uint AddVolumeEffect(float fVolume, int priority, int channel = -1) { unsafe { CheckIfEntityExists(); - return Core.Library.Client.AudioFilter_AddVolumeEffect(AudioFilterNativePointer, fVolume, priority); + return Core.Library.Client.AudioFilter_AddVolumeEffect(AudioFilterNativePointer, fVolume, priority, channel); } } diff --git a/api/AltV.Net.Client/Elements/Entities/Blip.cs b/api/AltV.Net.Client/Elements/Entities/Blip.cs index be33b37b58..73cc8a3eb6 100644 --- a/api/AltV.Net.Client/Elements/Entities/Blip.cs +++ b/api/AltV.Net.Client/Elements/Entities/Blip.cs @@ -706,24 +706,6 @@ public Blip(ICore core, IntPtr nativePointer, uint id) : base(core, GetWorldObje BlipNativePointer = nativePointer; } - [Obsolete("Use Alt.CreatePointBlip instead")] - public Blip(ICore core, Position position) : this(core, core.CreatePointBlipPtr(out var id, position), id) - { - core.PoolManager.Blip.Add(this); - } - - [Obsolete("Use Alt.CreateRadiusBlip instead")] - public Blip(ICore core, Position position, float radius) : this(core, core.CreateRadiusBlipPtr(out var id, position, radius), id) - { - core.PoolManager.Blip.Add(this); - } - - [Obsolete("Use Alt.CreateAreaBlip instead")] - public Blip(ICore core, Position position, int width, int height) : this(core, core.CreateAreaBlipPtr(out var id, position, width, height), id) - { - core.PoolManager.Blip.Add(this); - } - public void Fade(uint opacity, uint duration) { unsafe diff --git a/api/AltV.Net.Client/Elements/Entities/Entity.cs b/api/AltV.Net.Client/Elements/Entities/Entity.cs index 11bfc79f15..1914158d77 100644 --- a/api/AltV.Net.Client/Elements/Entities/Entity.cs +++ b/api/AltV.Net.Client/Elements/Entities/Entity.cs @@ -1,5 +1,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using AltV.Net.Client.Elements.Data; using AltV.Net.Client.Elements.Interfaces; using AltV.Net.Data; using AltV.Net.Elements.Args; @@ -67,6 +68,26 @@ public uint ScriptId } } + public SyncInfo SyncInfo + { + get + { + unsafe + { + CheckIfEntityExistsOrCached(); + + var syncInfoPtr = IntPtr.Zero; + Core.Library.Client.Entity_GetSyncInfo(EntityNativePointer, &syncInfoPtr); + + var syncInfo = Marshal.PtrToStructure(syncInfoPtr).ToPublic(); + + Core.Library.Shared.FreeSyncInfo(syncInfoPtr); + + return syncInfo; + } + } + } + public bool Spawned => ScriptId != 0; public Position Position @@ -146,16 +167,20 @@ public bool GetStreamSyncedMetaData(string key, out T result) { CheckIfEntityExists(); GetStreamSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) + using (mValue) { - result = default; - return false; - } - result = cast; - return true; + try + { + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; + } + catch + { + result = default; + return false; + } + } } public bool Frozen @@ -178,60 +203,6 @@ public bool Frozen } } - public bool GetStreamSyncedMetaData(string key, out int result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - - result = (int) mValue.GetInt(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) - { - result = default; - return false; - } - - result = (uint) mValue.GetUint(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) - { - result = default; - return false; - } - - result = (float) mValue.GetDouble(); - } - - return true; - } - public override void CheckIfEntityExists() { CheckIfCallIsValid(); diff --git a/api/AltV.Net.Client/Elements/Entities/TextLabel.cs b/api/AltV.Net.Client/Elements/Entities/TextLabel.cs index 641149b465..c20371a3e9 100644 --- a/api/AltV.Net.Client/Elements/Entities/TextLabel.cs +++ b/api/AltV.Net.Client/Elements/Entities/TextLabel.cs @@ -1,6 +1,9 @@ -using AltV.Net.Client.Elements.Interfaces; +using System.Runtime.InteropServices; +using AltV.Net.Client.Elements.Data; +using AltV.Net.Client.Elements.Interfaces; using AltV.Net.Data; using AltV.Net.Elements.Entities; +using AltV.Net.Shared.Utils; namespace AltV.Net.Client.Elements.Entities; @@ -71,6 +74,131 @@ public Rgba Color } } + public Rgba OutlineColor + { + get + { + unsafe + { + CheckIfEntityExists(); + var color = Rgba.Zero; + Core.Library.Shared.TextLabel_GetOutlineColor(TextLabelNativePointer, &color); + return color; + } + } + set + { + unsafe + { + CheckIfEntityExists(); + Core.Library.Shared.TextLabel_SetOutlineColor(TextLabelNativePointer, value); + } + } + } + + public float OutlineWidth + { + get + { + unsafe + { + return Core.Library.Shared.TextLabel_GetOutlineWidth(TextLabelNativePointer); + } + } + set + { + unsafe + { + Core.Library.Shared.TextLabel_SetOutlineWidth(TextLabelNativePointer, value); + } + } + } + + public float FontSize + { + get + { + unsafe + { + return Core.Library.Shared.TextLabel_GetFontSize(TextLabelNativePointer); + } + } + set + { + unsafe + { + Core.Library.Shared.TextLabel_SetFontSize(TextLabelNativePointer, value); + } + } + } + + public TextLabelAlignment Align + { + get + { + unsafe + { + return (TextLabelAlignment)Core.Library.Shared.TextLabel_GetAlign(TextLabelNativePointer); + } + } + set + { + unsafe + { + Core.Library.Shared.TextLabel_SetAlign(TextLabelNativePointer, (byte)value); + } + } + } + + + public string Text + { + get + { + unsafe + { + CheckIfEntityExistsOrCached(); + var size = 0; + return Core.PtrToStringUtf8AndFree( + Core.Library.Shared.TextLabel_GetText(TextLabelNativePointer, &size), size); + } + } + set + { + unsafe + { + CheckIfEntityExists(); + var valuePtr = MemoryUtils.StringToHGlobalUtf8(value); + Core.Library.Shared.TextLabel_SetText(TextLabelNativePointer, valuePtr); + Marshal.FreeHGlobal(valuePtr); + } + } + } + + public string Font + { + get + { + unsafe + { + CheckIfEntityExistsOrCached(); + var size = 0; + return Core.PtrToStringUtf8AndFree( + Core.Library.Shared.TextLabel_GetFont(TextLabelNativePointer, &size), size); + } + } + set + { + unsafe + { + CheckIfEntityExists(); + var valuePtr = MemoryUtils.StringToHGlobalUtf8(value); + Core.Library.Shared.TextLabel_SetFont(TextLabelNativePointer, valuePtr); + Marshal.FreeHGlobal(valuePtr); + } + } + } + public bool Visible { get @@ -86,7 +214,7 @@ public bool Visible unsafe { CheckIfEntityExists(); - Core.Library.Shared.TextLabel_SetVisible(TextLabelNativePointer, (byte) (value ? 1 : 0)); + Core.Library.Shared.TextLabel_SetVisible(TextLabelNativePointer, (byte)(value ? 1 : 0)); } } } @@ -170,7 +298,7 @@ public bool IsFacingCamera unsafe { CheckIfEntityExists(); - Core.Library.Shared.TextLabel_SetFaceCamera(TextLabelNativePointer, value ? (byte) 1 : (byte) 0); + Core.Library.Shared.TextLabel_SetFaceCamera(TextLabelNativePointer, value ? (byte)1 : (byte)0); } } } diff --git a/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs b/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs index 02e1290628..ecc28df661 100644 --- a/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs +++ b/api/AltV.Net.Client/Elements/Entities/VirtualEntity.cs @@ -64,74 +64,24 @@ public bool HasStreamSyncedMetaData(string key) } } - public bool GetStreamSyncedMetaData(string key, out int result) + public bool GetStreamSyncedMetaData(string key, out T result) { CheckIfEntityExists(); GetStreamSyncedMetaData(key, out MValueConst mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - result = (int) mValue.GetInt(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (uint) mValue.GetUint(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + catch { result = default; return false; } - - result = (float) mValue.GetDouble(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out T result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) - { - result = default; - return false; } - - result = cast; - return true; } public void GetStreamSyncedMetaData(string key, out MValueConst value) diff --git a/api/AltV.Net.Client/Elements/Entities/WebView.cs b/api/AltV.Net.Client/Elements/Entities/WebView.cs index 28b39fe7de..99803fc877 100644 --- a/api/AltV.Net.Client/Elements/Entities/WebView.cs +++ b/api/AltV.Net.Client/Elements/Entities/WebView.cs @@ -27,20 +27,6 @@ public WebView(ICore core, IntPtr webViewNativePointer, uint id) : base(core, Ge WebViewNativePointer = webViewNativePointer; } - [Obsolete("Use Alt.CreateWebView instead")] - public WebView(ICore core, string url, bool isOverlay = false, Vector2? pos = null, Vector2? size = null) - : this(core, core.CreateWebViewPtr(out var id, url, isOverlay, pos, size), id) - { - core.PoolManager.WebView.Add(this); - } - - [Obsolete("Use Alt.CreateWebView instead")] - public WebView(ICore core, string url, uint propHash, string targetTexture) - : this(core, core.CreateWebViewPtr(out var id,url, propHash, targetTexture), id) - { - core.PoolManager.WebView.Add(this); - } - public bool Focused { get diff --git a/api/AltV.Net.Client/Elements/Interfaces/IAudioFilter.cs b/api/AltV.Net.Client/Elements/Interfaces/IAudioFilter.cs index 358cda1460..66e5b78328 100644 --- a/api/AltV.Net.Client/Elements/Interfaces/IAudioFilter.cs +++ b/api/AltV.Net.Client/Elements/Interfaces/IAudioFilter.cs @@ -7,7 +7,7 @@ public interface IAudioFilter : IBaseObject uint AudCategory { get; set; } uint AddRotateEffect(float fRate, int priority); - uint AddVolumeEffect(float fVolume, int priority); + uint AddVolumeEffect(float fVolume, int priority, int channel = -1); uint AddPeakeqEffect(int lBand, float fBandwidth, float fQ, float fCenter, float fGain, int priority); uint AddDampEffect(float fTarget, float fQuiet, float fRate, float fGain, float fDelay, int priority); uint AddAutowahEffect(float fDryMix, float fWetMix, float fFeedback, float fRate, float fRange, float fFreq, int priority); diff --git a/api/AltV.Net.Client/Elements/Interfaces/IEntity.cs b/api/AltV.Net.Client/Elements/Interfaces/IEntity.cs index f6ad0e989a..9a6f099765 100644 --- a/api/AltV.Net.Client/Elements/Interfaces/IEntity.cs +++ b/api/AltV.Net.Client/Elements/Interfaces/IEntity.cs @@ -1,4 +1,5 @@ -using AltV.Net.Data; +using AltV.Net.Client.Elements.Data; +using AltV.Net.Data; using AltV.Net.Shared.Elements.Entities; namespace AltV.Net.Client.Elements.Interfaces @@ -7,6 +8,7 @@ public interface IEntity : ISharedEntity, IWorldObject { new IPlayer? NetworkOwner { get; } uint ScriptId { get; } + SyncInfo SyncInfo { get; } bool Spawned { get; } new Position Position { get; set; } diff --git a/api/AltV.Net.Client/Elements/Interfaces/ITextLabel.cs b/api/AltV.Net.Client/Elements/Interfaces/ITextLabel.cs index fb74998094..a05dbf989f 100644 --- a/api/AltV.Net.Client/Elements/Interfaces/ITextLabel.cs +++ b/api/AltV.Net.Client/Elements/Interfaces/ITextLabel.cs @@ -1,4 +1,5 @@ -using AltV.Net.Data; +using AltV.Net.Client.Elements.Data; +using AltV.Net.Data; namespace AltV.Net.Client.Elements.Interfaces; @@ -9,6 +10,12 @@ public interface ITextLabel : IWorldObject bool IsGlobal { get; } IPlayer? Target { get; } Rgba Color { get; set; } + Rgba OutlineColor { get; set; } + float OutlineWidth { get; set; } + float FontSize { get; set; } + TextLabelAlignment Align { get; set; } + string Text { get; set; } + string Font { get; set; } bool Visible { get; set; } float Scale { get; set; } Rotation Rotation { get; set; } diff --git a/api/AltV.Net.Client/ICore.cs b/api/AltV.Net.Client/ICore.cs index 27478da0d3..277a2303f4 100644 --- a/api/AltV.Net.Client/ICore.cs +++ b/api/AltV.Net.Client/ICore.cs @@ -212,5 +212,24 @@ ILocalObject CreateLocalObject(uint modelHash, Position position, Rotation rotat IntPtr CreateColShapeSpherePtr(out uint id, Vector3 position, float radius); IColShape CreateColShapeSphere(Vector3 position, float radius); IFont RegisterFont(string path); + + uint GetPoolSize(string pool); + uint GetPoolCount(string pool); + uint[] GetPoolEntities(string pool); + uint[] GetVoicePlayers(); + void RemoveVoicePlayer(uint playerRemoteId); + + float GetVoiceSpatialVolume(uint playerRemoteId); + void SetVoiceSpatialVolume(uint playerRemoteId, float volume); + float GetVoiceNonSpatialVolume(uint playerRemoteId); + void SetVoiceNonSpatialVolume(uint playerRemoteId, float volume); + + void AddVoiceFilter(uint playerRemoteId, IAudioFilter filter); + void RemoveVoiceFilter(uint playerRemoteId); + IAudioFilter GetVoiceFilter(uint playerRemoteId); + + void UpdateClipContext(Dictionary context); + + ulong ServerTime { get; } } } \ No newline at end of file diff --git a/api/AltV.Net.Client/Interfaces/IClient.cs b/api/AltV.Net.Client/Interfaces/IClient.cs deleted file mode 100644 index 7b52fc5e1c..0000000000 --- a/api/AltV.Net.Client/Interfaces/IClient.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace AltV.Net.Client.Interfaces -{ - public interface IClient - { - - #region Shared - - bool IsDebug { get; } - string Version { get; } - string Branch { get; } - - //MValueNone CreaeMValueNone(); - //MValueNil CreateMValueNil(); - //MValueBool CreateMValueBool(bool val); - //MValueInt CreateMValueInt(int val); - //MValueUInt CreateMValueUInt(uint64_t val); - //MValueDouble CreateMValueDouble(double val); - //MValueString CreateMValueString(String val); - //MValueList CreateMValueList(Size size = 0); - //MValueDict CreateMValueDict(); - //MValueFunction CreateMValueFunction(IntPtr impl); - //MValueVector2 CreateMValueVector2(Vector2 val); - //MValueVector3 CreateMValueVector3(Vector3 val); - //MValueRGBA CreateMValueRGBA(RGBA val); - //MValueByteArray CreateMValueByteArray(byte[] val); - //IResource GetResource(string name); - //IResource GetResource(IntPtr resourcePointer); - //IEntity GetEntityById(int id); - //IEntity[] GetEntities(); - //IPlayer[] GetPlayers(); - //IVehicle[] GetVehicles(); - //IBlip[] GetBlips(); - //MValueConst GetMetaData(string key); - void SetMetaData(string key, object value); - void DeleteMetaData(string key); - bool HasSyncedMetaData(string key); - //MValueConst GetSyncedMetaData(string key); - //IPermission[] GetRequiredPermissions(); - //IPermission[] GetOptionalPermissions(); - void LogInfo(string message); - void LogDebug(string message); - void LogWarning(string message); - void LogError(string message); - void LogColored(string message); - uint Hash(string value); - bool FileExists(string path); - string ReadFile(string path); - void TriggerLocalEvent(string eventName, params object[] args); - bool HasMetaData(string key); - - #endregion - - } -} \ No newline at end of file diff --git a/api/AltV.Net.EntitySync/Entity.cs b/api/AltV.Net.EntitySync/Entity.cs index 829af46ac2..9758d09cc1 100644 --- a/api/AltV.Net.EntitySync/Entity.cs +++ b/api/AltV.Net.EntitySync/Entity.cs @@ -21,7 +21,7 @@ public Vector3 Position } private bool exists = false; - + public bool Exists => exists; private bool positionState = false; @@ -65,13 +65,13 @@ public uint Range public float TempNetOwnerRange { get; set; } = float.MaxValue; public float LastStreamInRange { get; set; } = -1; - + public int StartingXIndex { get; set; } - + public int StoppingXIndex { get; set; } - + public int StartingYIndex { get; set; } - + public int StoppingYIndex { get; set; } private readonly object propertiesMutex = new object(); @@ -168,7 +168,7 @@ public bool TryGetData(string key, out object value) return data.TryGetValue(key, out value); } } - + public ICollection GetDataKeys() { lock (data) @@ -187,14 +187,22 @@ public bool TryGetData(string key, out T value) return false; } - if (!(currValue is T correctValue)) + try + { + value = (T)Convert.ChangeType(currValue, typeof(T)); + return true; + } + catch { + if (currValue is T cast) + { + value = cast; + return true; + } + value = default; return false; } - - value = correctValue; - return true; } } diff --git a/api/AltV.Net.Example/MyVehicle.cs b/api/AltV.Net.Example/MyVehicle.cs index a4198075f1..c41490a127 100644 --- a/api/AltV.Net.Example/MyVehicle.cs +++ b/api/AltV.Net.Example/MyVehicle.cs @@ -8,12 +8,6 @@ public class MyVehicle : Vehicle, IMyVehicle { public int MyData { get; set; } - // This constructor is used for creation via constructor - public MyVehicle(uint model, Position position, Rotation rotation) : base(Alt.Core, model, position, rotation) - { - MyData = 7; - } - // This constructor is used for creation via entity factory public MyVehicle(ICore core, IntPtr nativePointer, uint id) : base(core, nativePointer, id) { diff --git a/api/AltV.Net.Example/SampleResource.cs b/api/AltV.Net.Example/SampleResource.cs index ba916b3949..96f4645959 100644 --- a/api/AltV.Net.Example/SampleResource.cs +++ b/api/AltV.Net.Example/SampleResource.cs @@ -183,16 +183,6 @@ public override void OnStart() var tuple = vehicle.GetPosition(); vehicle.SetPosition(tuple); - - Task.Factory.StartNew(() => - AltAsync.CreateVehicleBuilder(VehicleModel.Apc, new Position(1, 2, 3), new Rotation(1, 2, 3)) - .PrimaryColorRgb(Color.GreenYellow) - .SecondaryColor(24) - .NumberplateText("C#") - .LockState(VehicleLockState.Locked) - .Build() - ); - Alt.Log("ptr:" + vehicle.NativePointer); Alt.Log("number-plate:" + vehicle.NumberplateText + " " + vehicle.NumberplateIndex); @@ -345,18 +335,6 @@ async delegate(string s, string s1, long i1, string[] arg3, object[] arg4, IMyVe Alt.Emit("none-existing-event", new ConvertibleObject()); - // You need to catch this with a exception because its not possible to construct a invalid entity - // Remember not all vehicles you receive from events has to be constructed by this constructor when there got created from different resources ect. - // But when you don't use a entity factory you can validate that by checking if the ivehicle is a imyvehicle - try - { - IMyVehicle unused = - new MyVehicle((uint)VehicleModel.Apc, new Position(1, 1, 1), new Rotation(1, 1, 1)); - } - catch (BaseObjectRemovedException) - { - } - Alt.RegisterEvents(this); Alt.Emit("bla2", "bla"); diff --git a/api/AltV.Net.Mock/MockBlip.cs b/api/AltV.Net.Mock/MockBlip.cs index e991eaf09f..2754ffef69 100644 --- a/api/AltV.Net.Mock/MockBlip.cs +++ b/api/AltV.Net.Mock/MockBlip.cs @@ -71,7 +71,7 @@ public void Fade(uint opacity, uint duration) public void Destroy() { - Alt.Core.RemoveBlip(this); + throw new NotImplementedException(); } public bool Visible { get; set; } diff --git a/api/AltV.Net.Mock/MockCheckpoint.cs b/api/AltV.Net.Mock/MockCheckpoint.cs index da30338fd1..61adb4ec29 100644 --- a/api/AltV.Net.Mock/MockCheckpoint.cs +++ b/api/AltV.Net.Mock/MockCheckpoint.cs @@ -47,21 +47,6 @@ public bool HasStreamSyncedMetaData(string key) throw new NotImplementedException(); } - public bool GetStreamSyncedMetaData(string key, out int result) - { - throw new NotImplementedException(); - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - throw new NotImplementedException(); - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - throw new NotImplementedException(); - } - public void GetStreamSyncedMetaData(string key, out MValueConst value) { throw new NotImplementedException(); diff --git a/api/AltV.Net.Mock/MockColShape.cs b/api/AltV.Net.Mock/MockColShape.cs index 8ef4268d97..fddb889dc2 100644 --- a/api/AltV.Net.Mock/MockColShape.cs +++ b/api/AltV.Net.Mock/MockColShape.cs @@ -25,7 +25,7 @@ public bool IsEntityIn(IEntity entity) public void Destroy() { - Alt.Core.RemoveColShape(this); + throw new NotImplementedException(); } public bool IsEntityIn(ISharedEntity entity) diff --git a/api/AltV.Net.Mock/MockConnectionInfo.cs b/api/AltV.Net.Mock/MockConnectionInfo.cs index 4113ce9fc6..b3769f7c58 100644 --- a/api/AltV.Net.Mock/MockConnectionInfo.cs +++ b/api/AltV.Net.Mock/MockConnectionInfo.cs @@ -22,7 +22,8 @@ public MockConnectionInfo(ICore core, IntPtr nativePointer, uint id) : base(core public string AuthToken { get; } public bool IsDebug { get; } public string Branch { get; } - public uint Build { get; } + public ushort VersionMajor { get; } + public ushort VersionMinor { get; } public string CdnUrl { get; } public ulong PasswordHash { get; } public string Ip { get; } diff --git a/api/AltV.Net.Mock/MockCore.cs b/api/AltV.Net.Mock/MockCore.cs index 102248ff4e..dfbd7f32ae 100644 --- a/api/AltV.Net.Mock/MockCore.cs +++ b/api/AltV.Net.Mock/MockCore.cs @@ -17,6 +17,8 @@ namespace AltV.Net.Mock { public class MockCore : ICore { + public IList UnansweredServerRpcRequest { get; } + public IList UnansweredClientRpcRequest { get; } ISharedPoolManager ISharedCore.PoolManager => PoolManager; public Dictionary> VehiclePassengers { get; } public IPoolManager PoolManager { get; } diff --git a/api/AltV.Net.Mock/MockEntity.cs b/api/AltV.Net.Mock/MockEntity.cs index 6e01dc9d45..9bc34a4bad 100644 --- a/api/AltV.Net.Mock/MockEntity.cs +++ b/api/AltV.Net.Mock/MockEntity.cs @@ -59,14 +59,16 @@ public bool GetMetaData(string key, out T result) return false; } - if (!(value.ToObject() is T cast)) + try + { + result = (T)Convert.ChangeType(value.ToObject(), typeof(T)); + return true; + } + catch { result = default; return false; } - - result = cast; - return true; } public void SetData(string key, object value) diff --git a/api/AltV.Net.Mock/MockVirtualEntity.cs b/api/AltV.Net.Mock/MockVirtualEntity.cs index 8fa9781528..e44907dc31 100644 --- a/api/AltV.Net.Mock/MockVirtualEntity.cs +++ b/api/AltV.Net.Mock/MockVirtualEntity.cs @@ -21,21 +21,6 @@ public bool HasStreamSyncedMetaData(string key) throw new NotImplementedException(); } - public bool GetStreamSyncedMetaData(string key, out int result) - { - throw new NotImplementedException(); - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - throw new NotImplementedException(); - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - throw new NotImplementedException(); - } - public bool GetStreamSyncedMetaData(string key, out T result) { throw new NotImplementedException(); diff --git a/api/AltV.Net.Mock/MockVoiceChannel.cs b/api/AltV.Net.Mock/MockVoiceChannel.cs index 5227f30772..502dda91c0 100644 --- a/api/AltV.Net.Mock/MockVoiceChannel.cs +++ b/api/AltV.Net.Mock/MockVoiceChannel.cs @@ -46,7 +46,7 @@ public bool IsPlayerMuted(IPlayer player) public void Destroy() { - Alt.Core.RemoveVoiceChannel(this); + throw new NotImplementedException(); } public uint Filter { get; set; } diff --git a/api/AltV.Net.Sdk.Generator/ImplicitUsingsGenerator.cs b/api/AltV.Net.Sdk.Generator/ImplicitUsingsGenerator.cs index b2af87441b..44c8f2b4d1 100644 --- a/api/AltV.Net.Sdk.Generator/ImplicitUsingsGenerator.cs +++ b/api/AltV.Net.Sdk.Generator/ImplicitUsingsGenerator.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; using System.Text.RegularExpressions; namespace AltV.Net.Sdk.Generator diff --git a/api/AltV.Net.Sdk.Generator/Program.cs b/api/AltV.Net.Sdk.Generator/Program.cs index 84bb663e40..52134ff7dc 100644 --- a/api/AltV.Net.Sdk.Generator/Program.cs +++ b/api/AltV.Net.Sdk.Generator/Program.cs @@ -1,4 +1,7 @@ -using System.Reflection; +using System; +using System.IO; +using System.Linq; +using System.Reflection; using System.Text.RegularExpressions; using AltV.Net.Sdk.Generator; diff --git a/api/AltV.Net.Shared/Elements/Args/MValueObjectReader.cs b/api/AltV.Net.Shared/Elements/Args/MValueObjectReader.cs index 82178f30da..2ec7d64966 100644 --- a/api/AltV.Net.Shared/Elements/Args/MValueObjectReader.cs +++ b/api/AltV.Net.Shared/Elements/Args/MValueObjectReader.cs @@ -19,7 +19,7 @@ private interface IReadableMValue object Peek(); } - private struct MValueArrayReader : IReadableMValue + private class MValueArrayReader : IReadableMValue { private readonly object[] values; @@ -53,7 +53,7 @@ public object Peek() } } - private struct MValueDictionaryReader : IReadableMValue + private class MValueDictionaryReader : IReadableMValue { private readonly object[] values; @@ -102,14 +102,14 @@ public int GetNameSize() { return names.Length - nameIndex; } - + public object Peek() { return values[index]; } } - private struct MValueStartReader : IReadableMValue + private class MValueStartReader : IReadableMValue { private object obj; @@ -136,7 +136,7 @@ public void SkipValue() obj = null; size = 0; } - + public object Peek() { return obj; @@ -207,7 +207,7 @@ private void CheckObject() throw new InvalidDataException("Not inside a object or array"); } } - + private void CheckArray() { if (!insideObject && readableMValue.Peek().GetType() != typeof(object[])) @@ -352,7 +352,7 @@ public ulong NextULong() return value; } - + public Position NextPosition() { CheckObjectOrArray(); @@ -366,7 +366,7 @@ public Position NextPosition() return value; } - + public Rgba NextRgba() { CheckObjectOrArray(); diff --git a/api/AltV.Net.Shared/Elements/Entities/IScriptRPCEvent.cs b/api/AltV.Net.Shared/Elements/Entities/IScriptRPCEvent.cs index 0c8b71d1f3..090e08051f 100644 --- a/api/AltV.Net.Shared/Elements/Entities/IScriptRPCEvent.cs +++ b/api/AltV.Net.Shared/Elements/Entities/IScriptRPCEvent.cs @@ -3,7 +3,6 @@ public interface IScriptRPCEvent { IntPtr ScriptRPCNativePointer { get; } - ISharedCore Core { get; } bool WillAnswer(); bool Answer(object answer); bool AnswerWithError(string error); diff --git a/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs b/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs index 53e1e65ad8..e9036f662d 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ISharedBaseObject.cs @@ -68,12 +68,6 @@ public interface ISharedBaseObject : INative /// void DeleteMetaData(string key); - bool GetMetaData(string key, out int result); - - bool GetMetaData(string key, out uint result); - - bool GetMetaData(string key, out float result); - /// /// Sets a value with a given on an entity. /// @@ -124,9 +118,6 @@ public interface ISharedBaseObject : INative void CheckIfEntityExists(); void CheckIfEntityExistsOrCached(); - [Obsolete("Use Destroy() instead")] - void Remove(); - /// /// Destroy the baseobject /// @@ -138,38 +129,16 @@ public interface ISharedBaseObject : INative /// Synced meta data is accessible across different serverside resources and across all clients. /// /// + [Obsolete] bool HasSyncedMetaData(string key); - /// - /// Gets the synced meta data of an entity. - /// - /// Synced meta data is accessible across different serverside resources and across all clients. - /// - /// - bool GetSyncedMetaData(string key, out int result); - - /// - /// Gets the synced meta data of an entity. - /// - /// Synced meta data is accessible across different serverside resources and across all clients. - /// - /// - bool GetSyncedMetaData(string key, out uint result); - - /// - /// Gets the synced meta data of an entity. - /// - /// Synced meta data is accessible across different serverside resources and across all clients. - /// - /// - bool GetSyncedMetaData(string key, out float result); - /// /// Gets the synced meta data of an entity. /// /// Synced meta data is accessible across different serverside resources and across all clients. /// /// + [Obsolete] void GetSyncedMetaData(string key, out MValueConst value); /// @@ -181,6 +150,7 @@ public interface ISharedBaseObject : INative /// /// /// This entity was removed + [Obsolete] bool GetSyncedMetaData(string key, out T result); } } \ No newline at end of file diff --git a/api/AltV.Net.Shared/Elements/Entities/ISharedEntity.cs b/api/AltV.Net.Shared/Elements/Entities/ISharedEntity.cs index 1ce5aa7186..916ef7a53f 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ISharedEntity.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ISharedEntity.cs @@ -38,36 +38,6 @@ public interface ISharedEntity : ISharedWorldObject /// bool HasStreamSyncedMetaData(string key); - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out int result); - - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out uint result); - - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out float result); - /// /// Get synced meta data of the entity. /// diff --git a/api/AltV.Net.Shared/Elements/Entities/ISharedVirtualEntity.cs b/api/AltV.Net.Shared/Elements/Entities/ISharedVirtualEntity.cs index 91b7a0a49c..00f9d24c00 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ISharedVirtualEntity.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ISharedVirtualEntity.cs @@ -13,37 +13,6 @@ public interface ISharedVirtualEntity : ISharedWorldObject bool HasStreamSyncedMetaData(string key); - - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out int result); - - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out uint result); - - /// - /// Get synced meta data of the entity. - /// - /// Stream synced meta data is accessible across different serverside resources and across all clients within the streaming range of the clients. - /// - /// - /// - /// This entity was removed - bool GetStreamSyncedMetaData(string key, out float result); - /// /// Get synced meta data of the entity. /// diff --git a/api/AltV.Net.Shared/Elements/Entities/ScriptRpcEvent.cs b/api/AltV.Net.Shared/Elements/Entities/ScriptRpcEvent.cs index a66792dffb..d46079fc93 100644 --- a/api/AltV.Net.Shared/Elements/Entities/ScriptRpcEvent.cs +++ b/api/AltV.Net.Shared/Elements/Entities/ScriptRpcEvent.cs @@ -6,8 +6,13 @@ namespace AltV.Net.Shared.Elements.Entities; public class ScriptRpcEvent : IScriptRPCEvent { - public ScriptRpcEvent(ISharedCore core, IntPtr clientScriptRPCNativePointer) + private readonly ushort _answerId; + private readonly bool _clientSide; + + public ScriptRpcEvent(ISharedCore core, IntPtr clientScriptRPCNativePointer, ushort answerId, bool clientSide) { + _answerId = answerId; + _clientSide = clientSide; ScriptRPCNativePointer = clientScriptRPCNativePointer; Core = core; } @@ -33,6 +38,21 @@ public bool Answer(object answer) } mValue.Dispose(); + if (_clientSide) + { + if (Core.UnansweredClientRpcRequest.Contains(_answerId)) + { + Core.UnansweredClientRpcRequest.Remove(_answerId); + } + } + else + { + if (Core.UnansweredServerRpcRequest.Contains(_answerId)) + { + Core.UnansweredServerRpcRequest.Remove(_answerId); + } + } + return result; } @@ -47,6 +67,21 @@ public bool AnswerWithError(string error) } Marshal.FreeHGlobal(errorPtr); + if (_clientSide) + { + if (Core.UnansweredClientRpcRequest.Contains(_answerId)) + { + Core.UnansweredClientRpcRequest.Remove(_answerId); + } + } + else + { + if (Core.UnansweredServerRpcRequest.Contains(_answerId)) + { + Core.UnansweredServerRpcRequest.Remove(_answerId); + } + } + return result; } } \ No newline at end of file diff --git a/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs b/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs index b88fe3b718..17e3053211 100644 --- a/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs +++ b/api/AltV.Net.Shared/Elements/Entities/SharedBaseObject.cs @@ -41,14 +41,22 @@ public bool GetData(string key, out T result) return false; } - if (!(value is T cast)) + try { + result = (T)Convert.ChangeType(value, typeof(T)); + return true; + } + catch + { + if (value is T cast) + { + result = cast; + return true; + } + result = default; return false; } - - result = cast; - return true; } @@ -212,16 +220,18 @@ public bool GetMetaData(string key, out T result) GetMetaData(key, out MValueConst mValue); using (mValue) { - if (!(mValue.ToObject() is T cast)) + + try + { + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; + } + catch { result = default; return false; } - - result = cast; } - - return true; } @@ -255,9 +265,6 @@ public override int GetHashCode() return NativePointer.GetHashCode(); } - [Obsolete("Use Destroy() instead")] - public void Remove() => Destroy(); - public void Destroy() { if (!Exists) return; @@ -273,6 +280,7 @@ public virtual void SetCached(IntPtr cachedBaseObject) this.Cached = true; } + [Obsolete] public void GetSyncedMetaData(string key, out MValueConst value) { CheckIfEntityExists(); @@ -284,86 +292,38 @@ public void GetSyncedMetaData(string key, out MValueConst value) } } + [Obsolete] public bool GetSyncedMetaData(string key, out T result) - { - CheckIfEntityExists(); - GetSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) - { - result = default; - return false; - } - - result = cast; - return true; - } - - public bool HasSyncedMetaData(string key) - { - CheckIfEntityExists(); - unsafe - { - var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); - var result = Core.Library.Shared.BaseObject_HasSyncedMetaData(BaseObjectNativePointer, stringPtr); - Marshal.FreeHGlobal(stringPtr); - return result == 1; - } - } - - public bool GetSyncedMetaData(string key, out int result) { CheckIfEntityExists(); GetSyncedMetaData(key, out MValueConst mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Int) + + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (int) mValue.GetInt(); - } - - return true; - } - - public bool GetSyncedMetaData(string key, out uint result) - { - CheckIfEntityExists(); - GetSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + catch { result = default; return false; } - - result = (uint) mValue.GetUint(); } - - return true; } - public bool GetSyncedMetaData(string key, out float result) + [Obsolete] + public bool HasSyncedMetaData(string key) { CheckIfEntityExists(); - GetSyncedMetaData(key, out MValueConst mValue); - using (mValue) + unsafe { - if (mValue.type != MValueConst.Type.Double) - { - result = default; - return false; - } - - result = (float) mValue.GetDouble(); + var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); + var result = Core.Library.Shared.BaseObject_HasSyncedMetaData(BaseObjectNativePointer, stringPtr); + Marshal.FreeHGlobal(stringPtr); + return result == 1; } - - return true; } } } \ No newline at end of file diff --git a/api/AltV.Net.Shared/ISharedCore.cs b/api/AltV.Net.Shared/ISharedCore.cs index d33b176b83..72ef6d0e85 100644 --- a/api/AltV.Net.Shared/ISharedCore.cs +++ b/api/AltV.Net.Shared/ISharedCore.cs @@ -10,6 +10,8 @@ namespace AltV.Net.Shared { public interface ISharedCore : ICApiCore { + IList UnansweredServerRpcRequest { get; } + IList UnansweredClientRpcRequest { get; } ISharedPoolManager PoolManager { get; } EventStateManager EventStateManager { get; } diff --git a/api/AltV.Net.Shared/SharedCore.cs b/api/AltV.Net.Shared/SharedCore.cs index afc3df13a2..f364713477 100644 --- a/api/AltV.Net.Shared/SharedCore.cs +++ b/api/AltV.Net.Shared/SharedCore.cs @@ -29,9 +29,13 @@ public SharedCore(IntPtr nativePointer, ILibrary library) Library = library; MainThread = Thread.CurrentThread; EventStateManager = new EventStateManager(this); + UnansweredServerRpcRequest = new List(); + UnansweredClientRpcRequest = new List(); } public abstract ISharedNativeResource Resource { get; } + public IList UnansweredServerRpcRequest { get; } + public IList UnansweredClientRpcRequest { get; } public abstract ISharedPoolManager PoolManager { get; } public EventStateManager EventStateManager { get; } @@ -459,6 +463,15 @@ public void CreateMValue(out MValueConst mValue, object obj) MValueConst[] dictValues; MValueWriter2 writer; + if (obj.GetType() is bool) + { + CreateMValueBool(out mValue, (bool)obj); + } + else if(obj.GetType() is int) + { + + } + switch (obj) { case ISharedBaseObject baseObject: diff --git a/api/AltV.Net/Alt.Entity.cs b/api/AltV.Net/Alt.Entity.cs deleted file mode 100644 index b835b516c8..0000000000 --- a/api/AltV.Net/Alt.Entity.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using AltV.Net.Elements.Entities; - -namespace AltV.Net -{ - public static partial class Alt - { - [Obsolete("Use vehicle.Destroy() instead")] - public static void RemoveVehicle(IVehicle vehicle) => vehicle.Destroy(); - - [Obsolete("Use blip.Destroy() instead")] - public static void RemoveBlip(IBlip blip) => blip.Destroy(); - - [Obsolete("Use checkpoint.Destroy() instead")] - public static void RemoveCheckpoint(ICheckpoint checkpoint) => checkpoint.Destroy(); - - [Obsolete("Use colShape.Destroy() instead")] - public static void RemoveColShape(IColShape colShape) => colShape.Destroy(); - } -} \ No newline at end of file diff --git a/api/AltV.Net/Alt.GlobalMeta.cs b/api/AltV.Net/Alt.GlobalMeta.cs index 96f62ce5d8..b485b6a709 100644 --- a/api/AltV.Net/Alt.GlobalMeta.cs +++ b/api/AltV.Net/Alt.GlobalMeta.cs @@ -1,3 +1,4 @@ +using System; using AltV.Net.Elements.Args; namespace AltV.Net @@ -5,151 +6,53 @@ namespace AltV.Net public static partial class Alt { public static void SetMetaData(string key, object value) => Core.SetMetaData(key, value); - + public static bool HasMetaData(string key) => Core.HasMetaData(key); public static void DeleteMetaData(string key) => Core.DeleteMetaData(key); - - public static bool GetMetaData(string key, out int result) - { - Core.GetMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - - result = (int) mValue.GetInt(); - } - return true; - } - - public static bool GetMetaData(string key, out uint result) + public static bool GetMetaData(string key, out T result) { Core.GetMetaData(key, out var mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Uint) - { - result = default; - return false; - } - result = (uint) mValue.GetUint(); - } - - return true; - } - - public static bool GetMetaData(string key, out float result) - { - Core.GetMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (float) mValue.GetDouble(); - } - - return true; - } - - public static bool GetMetaData(string key, out T result) - { - Core.GetMetaData(key, out var mValue); - using (mValue) - { - if (!(mValue.ToObject() is T cast)) + catch { result = default; return false; } - - result = cast; } - - return true; } - + public static void SetSyncedMetaData(string key, object value) => Core.SetSyncedMetaData(key, value); - + public static bool HasSyncedMetaData(string key) => Core.HasSyncedMetaData(key); public static void DeleteSyncedMetaData(string key) => Core.DeleteSyncedMetaData(key); - - public static bool GetSyncedMetaData(string key, out int result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - - result = (int) mValue.GetInt(); - } - - return true; - } - public static bool GetSyncedMetaData(string key, out uint result) + public static bool GetSyncedMetaData(string key, out T result) { Core.GetSyncedMetaData(key, out var mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Uint) - { - result = default; - return false; - } - - result = (uint) mValue.GetUint(); - } - return true; - } - - public static bool GetSyncedMetaData(string key, out float result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (float) mValue.GetDouble(); - } - - return true; - } - - public static bool GetSyncedMetaData(string key, out T result) - { - Core.GetSyncedMetaData(key, out var mValue); - using (mValue) - { - if (!(mValue.ToObject() is T cast)) + catch { result = default; return false; } - - result = cast; } - - return true; } } } \ No newline at end of file diff --git a/api/AltV.Net/Alt.RegisterEvents.cs b/api/AltV.Net/Alt.RegisterEvents.cs index 2a3244e9b7..e38127c8eb 100644 --- a/api/AltV.Net/Alt.RegisterEvents.cs +++ b/api/AltV.Net/Alt.RegisterEvents.cs @@ -338,14 +338,9 @@ public static void RegisterEvents(object target) scriptFunction.Set(damage); scriptFunction.Set(shotOffset); scriptFunction.Set(damageOffset); - if (scriptFunction.Call() is uint uintValue) + if (scriptFunction.Call() is WeaponDamageResponse response) { - return uintValue; - } - - if (scriptFunction.Call() is bool boolValue) - { - return boolValue; + return response; } return 0; @@ -621,7 +616,12 @@ public static void RegisterEvents(object target) { scriptFunction.Set(entity); scriptFunction.Set(player); - scriptFunction.Call(); + if (scriptFunction.Call() is bool value) + { + return value; + } + + return true; }; break; } diff --git a/api/AltV.Net/Alt.VoiceChannel.cs b/api/AltV.Net/Alt.VoiceChannel.cs index 30afa929a8..0dbdce07cc 100644 --- a/api/AltV.Net/Alt.VoiceChannel.cs +++ b/api/AltV.Net/Alt.VoiceChannel.cs @@ -7,8 +7,5 @@ public partial class Alt { public static IVoiceChannel CreateVoiceChannel(bool spatial, float maxDistance) => Core.CreateVoiceChannel(spatial, maxDistance); - - [Obsolete("Use channel.Destroy() instead")] - public static void RemoveVoiceChannel(IVoiceChannel channel) => Core.RemoveVoiceChannel(channel); } } \ No newline at end of file diff --git a/api/AltV.Net/Core.Events.cs b/api/AltV.Net/Core.Events.cs index d2895cd0cb..b55ce03b6a 100644 --- a/api/AltV.Net/Core.Events.cs +++ b/api/AltV.Net/Core.Events.cs @@ -255,21 +255,21 @@ public virtual void OnPlayerConnectEvent(IPlayer player, string reason) } public void OnPlayerConnectDenied(PlayerConnectDeniedReason reason, string name, string ip, ulong passwordHash, - bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId) + bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId) { - OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, + OnPlayerConnectDeniedEvent(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId); } public virtual void OnPlayerConnectDeniedEvent(PlayerConnectDeniedReason reason, string name, string ip, - ulong passwordHash, bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId) + ulong passwordHash, bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId) { foreach (var @delegate in PlayerConnectDeniedEventHandler.GetEvents()) { try { - @delegate(reason, name, ip, passwordHash, isDebug, branch, majorVersion, cdnUrl, discordId); + @delegate(reason, name, ip, passwordHash, isDebug, branch, versionMajor, versionMinor, cdnUrl, discordId); } catch (TargetInvocationException exception) { @@ -1433,7 +1433,7 @@ public virtual void OnServerStartedEvent() } } - public virtual void OnPlayerRequestControl(IntPtr targetPtr, BaseObjectType targetType, IntPtr playerPtr) + public virtual void OnPlayerRequestControl(IntPtr eventPtr, IntPtr targetPtr, BaseObjectType targetType, IntPtr playerPtr) { var target = (IEntity)PoolManager.Get(targetPtr, targetType); if (target is null) @@ -1449,16 +1449,20 @@ public virtual void OnPlayerRequestControl(IntPtr targetPtr, BaseObjectType targ return; } - OnPlayerRequestControlEvent(target, player); + OnPlayerRequestControlEvent(eventPtr, target, player); } - public virtual void OnPlayerRequestControlEvent(IEntity target, IPlayer player) + public virtual void OnPlayerRequestControlEvent(IntPtr eventPtr, IEntity target, IPlayer player) { + var cancel = false; foreach (var @delegate in PlayerRequestControlHandler.GetEvents()) { try { - @delegate(target, player); + if (!@delegate(target, player)) + { + cancel = true; + } } catch (TargetInvocationException exception) { @@ -1469,6 +1473,14 @@ public virtual void OnPlayerRequestControlEvent(IEntity target, IPlayer player) Alt.Log("exception at event:" + "OnPlayerRequestControlEvent" + ":" + exception); } } + + if (cancel) + { + unsafe + { + Alt.Core.Library.Shared.Event_Cancel(eventPtr); + } + } } public virtual void OnPlayerChangeAnimation(IntPtr playerPtr, uint oldDict, uint newDict, uint oldName, @@ -2636,13 +2648,17 @@ public void OnScriptRPC(IntPtr eventpointer, IntPtr targetpointer, string name, Marshal.Copy(pointer, args, 0, (int) size); } - OnScriptRPCEvent(eventpointer, target, name, args, answerId); + OnScriptRPCEvent(eventpointer, target, name, args, answerId, false); } - public virtual void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId) + public virtual void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string name, IntPtr[] args, ushort answerId, bool async) { + if (!UnansweredServerRpcRequest.Contains(answerId)) + { + UnansweredServerRpcRequest.Add(answerId); + } var mValues = MValueConst.CreateFrom(this, args); - var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer); + var clientScriptRPCEvent = new ScriptRpcEvent(this, eventpointer, answerId, false); foreach (var @delegate in ScriptRpcHandler.GetEvents()) { try @@ -2658,6 +2674,12 @@ public virtual void OnScriptRPCEvent(IntPtr eventpointer, IPlayer target, string Alt.Log("exception at event:" + "OnScriptRPCEvent" + ":" + exception); } } + + if (!async && UnansweredServerRpcRequest.Contains(answerId)) + { + clientScriptRPCEvent.AnswerWithError("Answer not handled"); + UnansweredServerRpcRequest.Remove(answerId); + } } public void OnScriptAnswerRPC(IntPtr targetpointer, ushort answerid, IntPtr answer, string answererror) diff --git a/api/AltV.Net/Core.cs b/api/AltV.Net/Core.cs index a255aa575b..06af67ee4c 100644 --- a/api/AltV.Net/Core.cs +++ b/api/AltV.Net/Core.cs @@ -565,9 +565,14 @@ public void TriggerClientRPCAnswer(IPlayer target, ushort answerId, MValueConst { unsafe { - Library.Server.Core_TriggerClientRPCAnswer(NativePointer, target.NativePointer, answerId, + Library.Server.Core_TriggerClientRPCAnswer(NativePointer, target.PlayerNativePointer, answerId, answer.nativePointer, errorPtr); } + + if (UnansweredServerRpcRequest.Contains(answerId)) + { + UnansweredServerRpcRequest.Remove(answerId); + } } public void TriggerClientRPCAnswer(IPlayer target, ushort answerId, MValueConst answer, string error) @@ -796,70 +801,6 @@ public IColShape CreateColShapePolygon(float minZ, float maxZ, Vector2[] points) return PoolManager.ColShape.GetOrCreate(this, ptr, id); } } - - [Obsolete("Use blip.Destroy() instead")] - public void RemoveBlip(IBlip blip) - { - CheckIfCallIsValid(); - if (blip.Exists) - { - unsafe - { - Library.Shared.Core_DestroyBaseObject(NativePointer, blip.BaseObjectNativePointer); - } - } - } - - [Obsolete("Use checkpoint.Destroy() instead")] - public void RemoveCheckpoint(ICheckpoint checkpoint) - { - CheckIfCallIsValid(); - if (checkpoint.Exists) - { - unsafe - { - Library.Server.Core_DestroyCheckpoint(NativePointer, checkpoint.CheckpointNativePointer); - } - } - } - - [Obsolete("Use vehicle.Destroy() instead")] - public void RemoveVehicle(IVehicle vehicle) - { - CheckIfCallIsValid(); - if (vehicle.Exists) - { - unsafe - { - Library.Server.Core_DestroyVehicle(NativePointer, vehicle.VehicleNativePointer); - } - } - } - - [Obsolete("Use channel.Destroy() instead")] - public void RemoveVoiceChannel(IVoiceChannel channel) - { - if (channel.Exists) - { - unsafe - { - Library.Server.Core_DestroyVoiceChannel(NativePointer, channel.VoiceChannelNativePointer); - } - } - } - - [Obsolete("Use colShape.Destroy() instead")] - public void RemoveColShape(IColShape colShape) - { - CheckIfCallIsValid(); - if (colShape.Exists) - { - unsafe - { - Library.Server.Core_DestroyColShape(NativePointer, colShape.ColShapeNativePointer); - } - } - } #endregion public INativeResource GetResource(string name) diff --git a/api/AltV.Net/Data/Decoration.cs b/api/AltV.Net/Data/Decoration.cs index 78f700ef08..15ef7935cc 100644 --- a/api/AltV.Net/Data/Decoration.cs +++ b/api/AltV.Net/Data/Decoration.cs @@ -7,13 +7,15 @@ internal readonly struct DecorationInternal { private readonly uint Collection; private readonly uint Overlay; + private readonly byte Count; public Decoration ToPublic() { return new Decoration { Collection = Collection, - Overlay = Overlay + Overlay = Overlay, + Count = Count }; } } @@ -22,4 +24,5 @@ public struct Decoration { public uint Collection; public uint Overlay; + public byte Count; } \ No newline at end of file diff --git a/api/AltV.Net/Data/VehicleModelInfo.cs b/api/AltV.Net/Data/VehicleModelInfo.cs index 0743c518d5..b1e6c6fa26 100644 --- a/api/AltV.Net/Data/VehicleModelInfo.cs +++ b/api/AltV.Net/Data/VehicleModelInfo.cs @@ -30,6 +30,7 @@ public enum VehicleModelType : byte [StructLayout(LayoutKind.Sequential)] internal readonly struct VehicleModelInfoInternal { + private readonly uint ModelHash; [MarshalAs(UnmanagedType.LPStr)] private readonly string Title; @@ -72,6 +73,7 @@ public VehicleModelInfo ToPublic() return new VehicleModelInfo { + ModelHash = ModelHash, Title = Title, Type = Type, WheelsCount = WheelsCount, @@ -95,6 +97,7 @@ public VehicleModelInfo ToPublic() public struct VehicleModelInfo { + public uint ModelHash; public string Title; public VehicleModelType Type; diff --git a/api/AltV.Net/Elements/Entities/BaseObject.cs b/api/AltV.Net/Elements/Entities/BaseObject.cs index 515723bb1e..8f5caf1b9f 100644 --- a/api/AltV.Net/Elements/Entities/BaseObject.cs +++ b/api/AltV.Net/Elements/Entities/BaseObject.cs @@ -57,6 +57,7 @@ public override void CheckIfCallIsValid() { } + [Obsolete] public void SetSyncedMetaData(string key, object value) { CheckIfEntityExists(); @@ -65,6 +66,7 @@ public void SetSyncedMetaData(string key, object value) mValue.Dispose(); } + [Obsolete] public void SetSyncedMetaData(Dictionary metaData) { unsafe @@ -93,6 +95,7 @@ public void SetSyncedMetaData(Dictionary metaData) } } + [Obsolete] public void SetSyncedMetaData(string key, in MValueConst value) { unsafe @@ -103,6 +106,7 @@ public void SetSyncedMetaData(string key, in MValueConst value) } } + [Obsolete] public void DeleteSyncedMetaData(string key) { unsafe diff --git a/api/AltV.Net/Elements/Entities/Checkpoint.cs b/api/AltV.Net/Elements/Entities/Checkpoint.cs index 89ef57071f..72462469ea 100644 --- a/api/AltV.Net/Elements/Entities/Checkpoint.cs +++ b/api/AltV.Net/Elements/Entities/Checkpoint.cs @@ -242,74 +242,24 @@ public bool HasStreamSyncedMetaData(string key) } } - public bool GetStreamSyncedMetaData(string key, out int result) + public bool GetStreamSyncedMetaData(string key, out T result) { CheckIfEntityExists(); GetStreamSyncedMetaData(key, out MValueConst mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - result = (int)mValue.GetInt(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (uint)mValue.GetUint(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + catch { result = default; return false; } - - result = (float)mValue.GetDouble(); } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out T result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) - { - result = default; - return false; - } - - result = cast; - return true; } public void GetStreamSyncedMetaData(string key, out MValueConst value) diff --git a/api/AltV.Net/Elements/Entities/ConnectionInfo.cs b/api/AltV.Net/Elements/Entities/ConnectionInfo.cs index df2598e474..701ceb8907 100644 --- a/api/AltV.Net/Elements/Entities/ConnectionInfo.cs +++ b/api/AltV.Net/Elements/Entities/ConnectionInfo.cs @@ -120,13 +120,24 @@ public string Branch } } - public uint Build + public ushort VersionMajor { get { unsafe { - return Core.Library.Server.ConnectionInfo_GetBuild(ConnectionInfoNativePointer); + return Core.Library.Server.ConnectionInfo_GetVersionMajor(ConnectionInfoNativePointer); + } + } + } + + public ushort VersionMinor + { + get + { + unsafe + { + return Core.Library.Server.ConnectionInfo_GetVersionMinor(ConnectionInfoNativePointer); } } } diff --git a/api/AltV.Net/Elements/Entities/Entity.cs b/api/AltV.Net/Elements/Entities/Entity.cs index 0355bcca57..db06c7f0f2 100644 --- a/api/AltV.Net/Elements/Entities/Entity.cs +++ b/api/AltV.Net/Elements/Entities/Entity.cs @@ -145,6 +145,7 @@ public void SetStreamSyncedMetaData(Dictionary metaData) public void SetStreamSyncedMetaData(string key, in MValueConst value) { + CheckIfEntityExists(); unsafe { var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); @@ -155,6 +156,7 @@ public void SetStreamSyncedMetaData(string key, in MValueConst value) public void GetStreamSyncedMetaData(string key, out MValueConst value) { + CheckIfEntityExistsOrCached(); unsafe { var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); @@ -196,73 +198,23 @@ public void SetStreamSyncedMetaData(string key, object value) } public bool GetStreamSyncedMetaData(string key, out T result) - { - CheckIfEntityExistsOrCached(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) - { - result = default; - return false; - } - - result = cast; - return true; - } - - public bool GetStreamSyncedMetaData(string key, out int result) { CheckIfEntityExistsOrCached(); GetStreamSyncedMetaData(key, out MValueConst mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - - result = (int)mValue.GetInt(); - } - - return true; - } - public bool GetStreamSyncedMetaData(string key, out uint result) - { - CheckIfEntityExistsOrCached(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (uint)mValue.GetUint(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - CheckIfEntityExistsOrCached(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + catch { result = default; return false; } - - result = (float)mValue.GetDouble(); } - - return true; } public void ResetNetworkOwner() diff --git a/api/AltV.Net/Elements/Entities/IBaseObject.cs b/api/AltV.Net/Elements/Entities/IBaseObject.cs index eaf75828fa..67a56826c0 100644 --- a/api/AltV.Net/Elements/Entities/IBaseObject.cs +++ b/api/AltV.Net/Elements/Entities/IBaseObject.cs @@ -17,8 +17,10 @@ public interface IBaseObject : ISharedBaseObject /// /// /// This entity was removed + [Obsolete] void SetSyncedMetaData(string key, object value); + [Obsolete] void SetSyncedMetaData(Dictionary metaData); /// @@ -27,6 +29,7 @@ public interface IBaseObject : ISharedBaseObject /// Synced meta data is accessible across different serverside resources and across all clients. /// /// + [Obsolete] void SetSyncedMetaData(string key, in MValueConst value); /// @@ -34,6 +37,7 @@ public interface IBaseObject : ISharedBaseObject /// /// Synced meta data is accessible across different serverside resources and across all clients. /// + [Obsolete] void DeleteSyncedMetaData(string key); } } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/ICheckpoint.cs b/api/AltV.Net/Elements/Entities/ICheckpoint.cs index 124429ec19..e4f14f9693 100644 --- a/api/AltV.Net/Elements/Entities/ICheckpoint.cs +++ b/api/AltV.Net/Elements/Entities/ICheckpoint.cs @@ -13,9 +13,6 @@ public interface ICheckpoint : ISharedCheckpoint, IColShape void SetStreamSyncedMetaData(string key, in MValueConst value); void DeleteStreamSyncedMetaData(string key); bool HasStreamSyncedMetaData(string key); - bool GetStreamSyncedMetaData(string key, out int result); - bool GetStreamSyncedMetaData(string key, out uint result); - bool GetStreamSyncedMetaData(string key, out float result); void GetStreamSyncedMetaData(string key, out MValueConst value); bool GetStreamSyncedMetaData(string key, out T result); } diff --git a/api/AltV.Net/Elements/Entities/IConnectionInfo.cs b/api/AltV.Net/Elements/Entities/IConnectionInfo.cs index c539f37c2c..bceb3b01ad 100644 --- a/api/AltV.Net/Elements/Entities/IConnectionInfo.cs +++ b/api/AltV.Net/Elements/Entities/IConnectionInfo.cs @@ -15,7 +15,8 @@ public interface IConnectionInfo : IBaseObject string AuthToken { get; } bool IsDebug { get; } string Branch { get; } - uint Build { get; } + ushort VersionMajor { get; } + ushort VersionMinor { get; } string CdnUrl { get; } ulong PasswordHash { get; } string Ip { get; } diff --git a/api/AltV.Net/Elements/Entities/IPlayer.cs b/api/AltV.Net/Elements/Entities/IPlayer.cs index 2764f87dfd..4d460ada8e 100644 --- a/api/AltV.Net/Elements/Entities/IPlayer.cs +++ b/api/AltV.Net/Elements/Entities/IPlayer.cs @@ -1,6 +1,5 @@ using System; using System.Numerics; -using System.Threading.Tasks; using AltV.Net.Data; using AltV.Net.Elements.Args; using AltV.Net.Enums; @@ -118,12 +117,16 @@ public interface IPlayer : ISharedPlayer, IEntity void SetDateTime(int day, int month, int year, int hour, int minute, int second); + void SetDateTime(DateTime dateTime); + /// /// Sets the current weather for the player /// /// void SetWeather(uint weather); + void SetWeather(WeatherType weatherType); + /// /// Gives the player a weapon, ammo and if it is active /// @@ -132,18 +135,24 @@ void SetDateTime(int day, int month, int year, int hour, /// True - Places into hand void GiveWeapon(uint weapon, int ammo, bool selectWeapon); + void GiveWeapon(WeaponModel weaponModel, int ammo, bool selectWeapon); + + /// /// Removes the weapon by hash /// /// bool RemoveWeapon(uint weapon); + bool RemoveWeapon(WeaponModel weaponModel); + /// /// Removes all player weapons /// void RemoveAllWeapons(bool removeAllAmmo); bool HasWeapon(uint weapon); + bool HasWeapon(WeaponModel weapon); /// /// Kicks the player with reason @@ -176,6 +185,8 @@ void SetDateTime(int day, int month, int year, int hour, /// Weapon Component hash void AddWeaponComponent(uint weapon, uint weaponComponent); + void AddWeaponComponent(WeaponModel weaponModel, uint weaponComponent); + /// /// Removes a weapon component from a weapon /// @@ -183,6 +194,8 @@ void SetDateTime(int day, int month, int year, int hour, /// Weapon Component hash void RemoveWeaponComponent(uint weapon, uint weaponComponent); + void RemoveWeaponComponent(WeaponModel weaponModel, uint weaponComponent); + /// /// Checks if a weapon has a component /// @@ -190,6 +203,7 @@ void SetDateTime(int day, int month, int year, int hour, /// Weapon Component hash /// bool HasWeaponComponent(uint weapon, uint weaponComponent); + bool HasWeaponComponent(WeaponModel weapon, uint weaponComponent); /// /// Sets the weapon tint to a weapon @@ -198,11 +212,14 @@ void SetDateTime(int day, int month, int year, int hour, /// tintIndex void SetWeaponTintIndex(uint weapon, byte tintIndex); + void SetWeaponTintIndex(WeaponModel weaponModel, byte tintIndex); + /// /// Gets the weapon tint of a weapon /// /// Weapon hash byte GetWeaponTintIndex(uint weapon); + byte GetWeaponTintIndex(WeaponModel weapon); /// /// Returns weapon tint of current weapon @@ -257,6 +274,8 @@ void SetDateTime(int day, int month, int year, int hour, /// Thrown if drawable id is higher then 127 bool SetDlcClothes(byte component, ushort drawable, byte texture, byte palette, uint dlc); + bool ClearClothes(byte component); + /// /// Gets the player props /// @@ -409,6 +428,7 @@ void SetDateTime(int day, int month, int year, int hour, /// This entity was removed Rgba GetHeadBlendPaletteColor(byte id); + void RemoveHeadBlendPaletteColor(); /// /// Set Head Blend Data @@ -425,7 +445,8 @@ void SetDateTime(int day, int month, int year, int hour, bool SetEyeColor(ushort eyeColor); void GetLocalMetaData(string key, out MValueConst value); - + bool GetLocalMetaData(string key, out T result); + void SetLocalMetaData(string key, object value); void SetLocalMetaData(string key, in MValueConst value); bool HasLocalMetaData(string key); @@ -459,7 +480,7 @@ void PlayAnimation(string animDict, string animName, float blendInSpeed, float b void SetAmmoMax100(uint ammoHash, int ammoMax); int GetAmmoMax100(uint ammoHash); - void AddDecoration(uint collection, uint overlay); + void AddDecoration(uint collection, uint overlay, byte count = 1); void RemoveDecoration(uint collection, uint overlay); void ClearDecorations(); Decoration[] GetDecorations(); @@ -469,167 +490,7 @@ void PlayAnimation(string animDict, string animName, float blendInSpeed, float b CloudAuthResult CloudAuthResult { get; } string BloodDamage { get; set; } - } - - public static class PlayerExtensions - { - /// - /// Sets the players current Date and Time - /// - /// The player - /// The DateTime object - public static void SetDateTime(this IPlayer player, DateTime dateTime) => player.SetDateTime(dateTime.Day - 1, - dateTime.Month - 1, dateTime.Year, dateTime.Hour, dateTime.Minute, dateTime.Second); - /// - /// Sets the players current weather - /// - /// The Player - /// The weather type - public static void SetWeather(this IPlayer player, WeatherType weatherType) => - player.SetWeather((uint) weatherType); - - /// - /// Adds a weapon component to model - /// - /// The Player - /// The Weapon - /// The Component - public static void AddWeaponComponent(this IPlayer player, WeaponModel weaponModel, uint weaponComponent) => - player.AddWeaponComponent((uint) weaponModel, weaponComponent); - - /// - /// Removes a weapon component from model - /// - /// The player - /// The weapon - /// The component to be removed - public static void RemoveWeaponComponent(this IPlayer player, WeaponModel weaponModel, uint weaponComponent) => - player.RemoveWeaponComponent((uint) weaponModel, weaponComponent); - - /// - /// Sets the weapon tint to a weapon - /// - /// The player - /// The weapon - /// The tint index - public static void SetWeaponTintIndex(this IPlayer player, WeaponModel weaponModel, byte tintIndex) => - player.SetWeaponTintIndex((uint) weaponModel, tintIndex); - - /// - /// Gives player a weapon - /// - /// The player - /// The weapon - /// The amount of ammo - /// If the weapon is selected automatically - public static void GiveWeapon(this IPlayer player, WeaponModel weaponModel, int ammo, bool selectWeapon) => - player.GiveWeapon((uint) weaponModel, ammo, selectWeapon); - - /// - /// Removes the specific weapon from the player - /// - /// The player - /// The weapon to remove - public static void RemoveWeapon(this IPlayer player, WeaponModel weaponModel) => - player.RemoveWeapon((uint) weaponModel); - - /// - /// Returns the forward vector of the player. - /// - /// - /// - public static Vector3 GetForwardVector(this IPlayer player) - { - var z = player.Rotation.Yaw * (Math.PI / 180.0); - var x = player.Rotation.Roll * (Math.PI / 180.0); - var num = Math.Abs(Math.Cos(x)); - - return new Vector3( - (float) (-Math.Sin(z) * num), - (float) (Math.Cos(z) * num), - (float) Math.Sin(x) - ); - } - - public static void SetLocalMetaData(this IPlayer player, string key, object value) - { - player.CheckIfEntityExists(); - Alt.Core.CreateMValue(out var mValue, value); - player.SetLocalMetaData(key, in mValue); - mValue.Dispose(); - } - - public static bool GetLocalMetaData(this IPlayer player, string key, out int result) - { - player.CheckIfEntityExistsOrCached(); - player.GetLocalMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - - result = (int) mValue.GetInt(); - } - - return true; - } - - public static bool GetLocalMetaData(this IPlayer player, string key, out uint result) - { - player.CheckIfEntityExistsOrCached(); - player.GetLocalMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) - { - result = default; - return false; - } - - result = (uint) mValue.GetUint(); - } - - return true; - } - - public static bool GetLocalMetaData(this IPlayer player, string key, out float result) - { - player.CheckIfEntityExistsOrCached(); - player.GetLocalMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) - { - result = default; - return false; - } - - result = (float) mValue.GetDouble(); - } - - return true; - } - - public static bool GetLocalMetaData(this IPlayer player, string key, out T result) - { - player.CheckIfEntityExistsOrCached(); - player.GetLocalMetaData(key, out MValueConst mValue); - using (mValue) - { - if (!(mValue.ToObject() is T cast)) - { - result = default; - return false; - } - - result = cast; - } - - return true; - } + Vector3 GetForwardVector(); } } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/IVehicle.cs b/api/AltV.Net/Elements/Entities/IVehicle.cs index b0f721704b..3a215a3ea8 100644 --- a/api/AltV.Net/Elements/Entities/IVehicle.cs +++ b/api/AltV.Net/Elements/Entities/IVehicle.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Numerics; +using AltV.Net.CApi.Data; using AltV.Net.Data; using AltV.Net.Enums; using AltV.Net.Shared.Elements.Entities; @@ -854,5 +855,23 @@ NumberPlateStyle GetNumberPlateStyleExt() => float BrakeLevel { get; } List Passengers { get; } + + /// + /// Set badges to vehicle + /// + /// The hash of textureDictionary + /// The hash of texture + /// The array of badge position. Maximum is 4 + /// When badge postion is more the 4 + void SetBage(string textureDictionary, string texture, VehicleBadgePosition[] vehicleBadgePosition); + + /// + /// Set badges to vehicle + /// + /// The hash of textureDictionary + /// The hash of texture + /// The array of badge position. Maximum is 4 + /// When badge postion is more the 4 + void SetBage(uint textureDictionary, uint texture, VehicleBadgePosition[] vehicleBadgePosition); } } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/IWorldObject.cs b/api/AltV.Net/Elements/Entities/IWorldObject.cs index d56cb55622..3b70165eb6 100644 --- a/api/AltV.Net/Elements/Entities/IWorldObject.cs +++ b/api/AltV.Net/Elements/Entities/IWorldObject.cs @@ -1,25 +1,13 @@ -using System; -using AltV.Net.Data; using AltV.Net.Shared.Elements.Entities; namespace AltV.Net.Elements.Entities { public interface IWorldObject : ISharedWorldObject, IBaseObject { - } - - public static class WorldObjectExtensions - { - public static void SetPosition(this IWorldObject worldObject, (float X, float Y, float Z) position) => - worldObject.Position = new Position(position.X, position.Y, position.Z); + void SetPosition((float X, float Y, float Z) position); - public static void SetPosition(this IWorldObject worldObject, float x, float y, float z) => - worldObject.Position = new Position(x, y, z); + void SetPosition(float x, float y, float z); - public static (float X, float Y, float Z) GetPosition(this IWorldObject worldObject) - { - var position = worldObject.Position; - return (position.X, position.Y, position.Z); - } + (float X, float Y, float Z) GetPosition(); } } \ No newline at end of file diff --git a/api/AltV.Net/Elements/Entities/Player.cs b/api/AltV.Net/Elements/Entities/Player.cs index ce450d7830..dee69418de 100644 --- a/api/AltV.Net/Elements/Entities/Player.cs +++ b/api/AltV.Net/Elements/Entities/Player.cs @@ -1,13 +1,9 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -using System.Threading; -using System.Threading.Tasks; -using AltV.Net.CApi.ClientEvents; -using AltV.Net.CApi.ServerEvents; using AltV.Net.Data; using AltV.Net.Elements.Args; -using AltV.Net.Native; +using AltV.Net.Enums; using AltV.Net.Shared.Elements.Entities; using AltV.Net.Shared.Utils; @@ -80,8 +76,29 @@ public string Ip } } + public bool GetLocalMetaData(string key, out T result) + { + CheckIfEntityExistsOrCached(); + GetLocalMetaData(key, out MValueConst mValue); + using (mValue) + { + + try + { + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; + } + catch + { + result = default; + return false; + } + } + } + public void GetLocalMetaData(string key, out MValueConst value) { + CheckIfEntityExistsOrCached(); unsafe { var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); @@ -90,8 +107,16 @@ public void GetLocalMetaData(string key, out MValueConst value) } } + public void SetLocalMetaData(string key, object value) + { + Alt.Core.CreateMValue(out var mValue, value); + SetLocalMetaData(key, in mValue); + mValue.Dispose(); + } + public void SetLocalMetaData(string key, in MValueConst value) { + CheckIfEntityExistsOrCached(); unsafe { var stringPtr = MemoryUtils.StringToHGlobalUtf8(key); @@ -328,12 +353,12 @@ public int GetAmmoMax100(uint ammoHash) } } - public void AddDecoration(uint collection, uint overlay) + public void AddDecoration(uint collection, uint overlay, byte count = 1) { unsafe { CheckIfEntityExists(); - Core.Library.Server.Player_AddDecoration(PlayerNativePointer, collection, overlay); + Core.Library.Server.Player_AddDecoration(PlayerNativePointer, collection, overlay, count); } } @@ -365,13 +390,12 @@ public Decoration[] GetDecorations() var decorations = new Decoration[size]; var data = new IntPtr[size]; Marshal.Copy(ptr, data, 0, (int) size); - for (ulong i = 0; i < size; i++) { - var structure = Marshal.PtrToStructure(ptr); + var structure = Marshal.PtrToStructure(data[i]); decorations[i] = structure.ToPublic(); } - Core.Library.Shared.FreePlayerArray(ptr); + Core.Library.Server.Player_DeallocDecoration(ptr); return decorations; } } @@ -437,6 +461,19 @@ public string BloodDamage } } + public Vector3 GetForwardVector() + { + var z = Rotation.Yaw * (Math.PI / 180.0); + var x = Rotation.Roll * (Math.PI / 180.0); + var num = Math.Abs(Math.Cos(x)); + + return new Vector3( + (float) (-Math.Sin(z) * num), + (float) (Math.Cos(z) * num), + (float) Math.Sin(x) + ); + } + public bool IsConnected { get @@ -985,6 +1022,12 @@ public void SetDateTime(int day, int month, int year, int hour, int minute, int } } + public void SetDateTime(DateTime dateTime) + { + SetDateTime(dateTime.Day - 1, dateTime.Month - 1, dateTime.Year, dateTime.Hour, dateTime.Minute, + dateTime.Second); + } + public void SetWeather(uint weather) { unsafe @@ -994,6 +1037,11 @@ public void SetWeather(uint weather) } } + public void SetWeather(WeatherType weatherType) + { + SetWeather((uint)weatherType); + } + public void GiveWeapon(uint weapon, int ammo, bool selectWeapon) { unsafe @@ -1003,6 +1051,11 @@ public void GiveWeapon(uint weapon, int ammo, bool selectWeapon) } } + public void GiveWeapon(WeaponModel weaponModel, int ammo, bool selectWeapon) + { + GiveWeapon((uint)weaponModel, ammo, selectWeapon); + } + public bool RemoveWeapon(uint weapon) { unsafe @@ -1012,6 +1065,11 @@ public bool RemoveWeapon(uint weapon) } } + public bool RemoveWeapon(WeaponModel weaponModel) + { + return RemoveWeapon((uint)weaponModel); + } + public void RemoveAllWeapons(bool removeAllAmmo) { unsafe @@ -1030,6 +1088,11 @@ public bool HasWeapon(uint weapon) } } + public bool HasWeapon(WeaponModel weapon) + { + return HasWeapon((uint)weapon); + } + public void AddWeaponComponent(uint weapon, uint weaponComponent) { unsafe @@ -1039,6 +1102,11 @@ public void AddWeaponComponent(uint weapon, uint weaponComponent) } } + public void AddWeaponComponent(WeaponModel weaponModel, uint weaponComponent) + { + AddWeaponComponent((uint)weaponModel, weaponComponent); + } + public void RemoveWeaponComponent(uint weapon, uint weaponComponent) { unsafe @@ -1048,6 +1116,11 @@ public void RemoveWeaponComponent(uint weapon, uint weaponComponent) } } + public void RemoveWeaponComponent(WeaponModel weaponModel, uint weaponComponent) + { + RemoveWeaponComponent((uint)weaponModel, weaponComponent); + } + public bool HasWeaponComponent(uint weapon, uint weaponComponent) { unsafe @@ -1057,6 +1130,11 @@ public bool HasWeaponComponent(uint weapon, uint weaponComponent) } } + public bool HasWeaponComponent(WeaponModel weapon, uint weaponComponent) + { + return HasWeaponComponent((uint)weapon, weaponComponent); + } + public void GetCurrentWeaponComponents(out uint[] weaponComponents) { unsafe @@ -1091,6 +1169,11 @@ public void SetWeaponTintIndex(uint weapon, byte tintIndex) } } + public void SetWeaponTintIndex(WeaponModel weaponModel, byte tintIndex) + { + SetWeaponTintIndex((uint)weaponModel, tintIndex); + } + public byte GetWeaponTintIndex(uint weapon) { unsafe @@ -1100,6 +1183,11 @@ public byte GetWeaponTintIndex(uint weapon) } } + public byte GetWeaponTintIndex(WeaponModel weapon) + { + return GetWeaponTintIndex((uint)weapon); + } + public byte GetCurrentWeaponTintIndex() { unsafe @@ -1239,6 +1327,15 @@ public bool SetDlcClothes(byte component, ushort drawable, byte texture, byte pa } } + public bool ClearClothes(byte component) + { + unsafe + { + CheckIfEntityExists(); + return Core.Library.Server.Player_ClearClothes(PlayerNativePointer, component) == 1; + } + } + public Prop GetProps(byte component) { unsafe @@ -1558,6 +1655,15 @@ public Rgba GetHeadBlendPaletteColor(byte id) } } + public void RemoveHeadBlendPaletteColor() + { + unsafe + { + CheckIfEntityExists(); + Core.Library.Server.Player_RemoveHeadBlendPaletteColor(PlayerNativePointer); + } + } + public void SetHeadBlendData(uint shapeFirstID, uint shapeSecondID, uint shapeThirdID, uint skinFirstID, uint skinSecondID, uint skinThirdID, float shapeMix, float skinMix, float thirdMix) { unsafe diff --git a/api/AltV.Net/Elements/Entities/Vehicle.cs b/api/AltV.Net/Elements/Entities/Vehicle.cs index 99f0a5ec83..4a931c54e2 100644 --- a/api/AltV.Net/Elements/Entities/Vehicle.cs +++ b/api/AltV.Net/Elements/Entities/Vehicle.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Numerics; using System.Runtime.InteropServices; +using AltV.Net.CApi.Data; using AltV.Net.Data; using AltV.Net.Enums; using AltV.Net.Native; @@ -1378,13 +1379,6 @@ public IVehicle AttachedTo } } - [Obsolete("Use Alt.CreateVehicle instead")] - public Vehicle(ICore core, uint model, Position position, Rotation rotation, uint streamingDistance = 0) : this( - core, core.CreateVehicleEntity(out var id, model, position, rotation, streamingDistance), id) - { - core.PoolManager.Vehicle.Add(this); - } - public Vehicle(ICore core, IntPtr nativePointer, uint id) : base(core, GetEntityPointer(core, nativePointer), BaseObjectType.Vehicle, id) { this.VehicleNativePointer = nativePointer; @@ -2092,6 +2086,24 @@ public List Passengers } } + public void SetBage(string textureDictionary, string texture, VehicleBadgePosition[] vehicleBadgePosition) + { + SetBage(Alt.Hash(textureDictionary), Alt.Hash(texture), vehicleBadgePosition); + } + + public void SetBage(uint textureDictionary, uint texture, VehicleBadgePosition[] vehicleBadgePosition) + { + if (vehicleBadgePosition.Length > 4) + { + throw new ArgumentOutOfRangeException( + $"{nameof(vehicleBadgePosition)} should be have maximum 4 badge positions"); + } + unsafe + { + Core.Library.Server.Vehicle_SetBadge(VehicleNativePointer, textureDictionary, texture, vehicleBadgePosition, (ushort)vehicleBadgePosition.Length); + } + } + public override void SetCached(IntPtr cachedVehicle) { this.VehicleNativePointer = cachedVehicle; diff --git a/api/AltV.Net/Elements/Entities/VirtualEntity.cs b/api/AltV.Net/Elements/Entities/VirtualEntity.cs index 7030f0a665..816f2c6c3d 100644 --- a/api/AltV.Net/Elements/Entities/VirtualEntity.cs +++ b/api/AltV.Net/Elements/Entities/VirtualEntity.cs @@ -62,74 +62,24 @@ public bool HasStreamSyncedMetaData(string key) } } - public bool GetStreamSyncedMetaData(string key, out int result) + public bool GetStreamSyncedMetaData(string key, out T result) { CheckIfEntityExists(); GetStreamSyncedMetaData(key, out MValueConst mValue); using (mValue) { - if (mValue.type != MValueConst.Type.Int) - { - result = default; - return false; - } - result = (int) mValue.GetInt(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out uint result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Uint) + try { - result = default; - return false; + result = (T)Convert.ChangeType(mValue.ToObject(), typeof(T)); + return true; } - - result = (uint) mValue.GetUint(); - } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out float result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - using (mValue) - { - if (mValue.type != MValueConst.Type.Double) + catch { result = default; return false; } - - result = (float) mValue.GetDouble(); } - - return true; - } - - public bool GetStreamSyncedMetaData(string key, out T result) - { - CheckIfEntityExists(); - GetStreamSyncedMetaData(key, out MValueConst mValue); - var obj = mValue.ToObject(); - mValue.Dispose(); - if (!(obj is T cast)) - { - result = default; - return false; - } - - result = cast; - return true; } public void GetStreamSyncedMetaData(string key, out MValueConst value) diff --git a/api/AltV.Net/Elements/Entities/WorldObject.cs b/api/AltV.Net/Elements/Entities/WorldObject.cs index b336604572..f4ff2f1349 100644 --- a/api/AltV.Net/Elements/Entities/WorldObject.cs +++ b/api/AltV.Net/Elements/Entities/WorldObject.cs @@ -81,5 +81,20 @@ public override void SetCached(IntPtr cachedWorldObject) this.WorldObjectNativePointer = cachedWorldObject; base.SetCached(GetBaseObjectPointer(Core, cachedWorldObject)); } + + public void SetPosition((float X, float Y, float Z) position) + { + Position = new Position(position.X, position.Y, position.Z); + } + + public void SetPosition(float x, float y, float z) + { + Position = new Position(x, y, z); + } + + public (float X, float Y, float Z) GetPosition() + { + return (Position.X, Position.Y, Position.Z); + } } } \ No newline at end of file diff --git a/api/AltV.Net/Events/Events.cs b/api/AltV.Net/Events/Events.cs index a04a2766ed..85e0245cef 100644 --- a/api/AltV.Net/Events/Events.cs +++ b/api/AltV.Net/Events/Events.cs @@ -14,7 +14,7 @@ namespace AltV.Net.Events public delegate void PlayerConnectDelegate(IPlayer player, string reason); public delegate void PlayerConnectDeniedDelegate(PlayerConnectDeniedReason reason, string name, string ip, - ulong passwordHash, bool isDebug, string branch, uint majorVersion, string cdnUrl, long discordId); + ulong passwordHash, bool isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId); public delegate void ResourceEventDelegate(INativeResource resource); @@ -87,7 +87,7 @@ public delegate WeaponDamageResponse WeaponDamageDelegate(IPlayer player, IEntit public delegate void ServerStartedDelegate(); - public delegate void PlayerRequestControlDelegate(IEntity target, IPlayer player); + public delegate bool PlayerRequestControlDelegate(IEntity target, IPlayer player); public delegate void PlayerChangeAnimationDelegate(IPlayer player, uint oldDict, uint newDict, uint oldName, uint newName); diff --git a/api/AltV.Net/ICore.cs b/api/AltV.Net/ICore.cs index 088a190c68..1bc36b60f8 100644 --- a/api/AltV.Net/ICore.cs +++ b/api/AltV.Net/ICore.cs @@ -138,21 +138,6 @@ public interface ICore : ISharedCore IColShape CreateColShapePolygon(float minZ, float maxZ, Vector2[] points); - [Obsolete("Use blip.Destroy() instead")] - void RemoveBlip(IBlip blip); - - [Obsolete("Use checkpoint.Destroy() instead")] - void RemoveCheckpoint(ICheckpoint checkpoint); - - [Obsolete("Use vehicle.Destroy() instead")] - void RemoveVehicle(IVehicle vehicle); - - [Obsolete("Use channel.Destroy() instead")] - void RemoveVoiceChannel(IVoiceChannel channel); - - [Obsolete("Use colShape.Destroy() instead")] - void RemoveColShape(IColShape colShape); - INativeResource GetResource(string name); INativeResource GetResource(IntPtr resourcePointer); diff --git a/api/AltV.Net/ModuleWrapper.cs b/api/AltV.Net/ModuleWrapper.cs index 7dd916927e..014d9db00e 100644 --- a/api/AltV.Net/ModuleWrapper.cs +++ b/api/AltV.Net/ModuleWrapper.cs @@ -399,9 +399,9 @@ public static void OnServerStarted() _core.OnServerStarted(); } - public static void OnPlayerRequestControl(IntPtr target, BaseObjectType targetType, IntPtr player) + public static void OnPlayerRequestControl(IntPtr eventPtr, IntPtr target, BaseObjectType targetType, IntPtr player) { - _core.OnPlayerRequestControl(target, targetType, player); + _core.OnPlayerRequestControl(eventPtr, target, targetType, player); } public static void OnPlayerChangeAnimation(IntPtr player, uint oldDict, uint newDict, uint oldName, uint newName) @@ -419,9 +419,9 @@ public static void OnPlayerDimensionChange(IntPtr player, int oldDimension, int _core.OnPlayerDimensionChange(player, oldDimension, newDimension); } - public static void OnPlayerConnectDenied(PlayerConnectDeniedReason reason, string name, string ip, ulong passwordHash, byte isDebug, string branch, uint majorVersion, string cdnUrl, long discordId) + public static void OnPlayerConnectDenied(PlayerConnectDeniedReason reason, string name, string ip, ulong passwordHash, byte isDebug, string branch, ushort versionMajor, ushort versionMinor, string cdnUrl, long discordId) { - _core.OnPlayerConnectDenied(reason, name, ip, passwordHash, isDebug == 1, branch, majorVersion, cdnUrl, + _core.OnPlayerConnectDenied(reason, name, ip, passwordHash, isDebug == 1, branch, versionMajor, versionMinor, cdnUrl, discordId); } diff --git a/docs/articles/getting-started/vehicle-create.md b/docs/articles/getting-started/vehicle-create.md index 0a9f3a27bb..3711442eda 100644 --- a/docs/articles/getting-started/vehicle-create.md +++ b/docs/articles/getting-started/vehicle-create.md @@ -1,5 +1,6 @@ # CreateVehicle This is a little example how to create Vehicles Serverside in C#. +**You need to add the reference to the NuGet Package __AltV.Net.Resources.Chat.Api__** # First Example This example will spawn a Adder near you after you died! diff --git a/runtime b/runtime index 0705b9202f..7289177e89 160000 --- a/runtime +++ b/runtime @@ -1 +1 @@ -Subproject commit 0705b9202fdf53554b13e8ad39db4d8efc17f4ab +Subproject commit 7289177e8921efc5135c3fc337fa1c41e995c7aa