From 3c4b8eafc9883594211cb2dc806e2ee7ae8d90f2 Mon Sep 17 00:00:00 2001 From: Alexander Schmid Date: Wed, 11 Dec 2024 09:20:14 +0100 Subject: [PATCH 01/10] Add mp2024_02 / Agents of Sabotage content (#38) Provided by Pleb Masters: Forge --- api/AltV.Net.Shared/Enums/PedModel.cs | 12 +++++++++++- api/AltV.Net.Shared/Enums/VehicleModel.cs | 20 +++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/api/AltV.Net.Shared/Enums/PedModel.cs b/api/AltV.Net.Shared/Enums/PedModel.cs index 8a1e46bb..efbcdda1 100644 --- a/api/AltV.Net.Shared/Enums/PedModel.cs +++ b/api/AltV.Net.Shared/Enums/PedModel.cs @@ -917,6 +917,16 @@ public enum PedModel : uint Zombie01GMM = 3323689041, // 0xC61B7851 BountyTarget05IG = 3690927337, // 0xDBFF14E9 JenetteECSB = 4095622650, // 0xF41E3DFA - Maude02CSB = 1928962749 // 0x72F9A2BD + Maude02CSB = 1928962749, // 0x72F9A2BD + JodiMarshallIG = 1043886488, // 0x3E387198 + GuadalopeIG = 2630588041, // 0x9CCB9689 + HelmsmanPavel02IG = 2162565007, // 0x80E61F8F + HelmsmanPavel02CSB = 1591881099, // 0x5EE22D8B + CarClub02AFY = 238774192, // 0xE3B67B0 + CarClub02AMY = 2790225070, // 0xA64F74AE + ArmsManufac01IG = 999842350, // 0x3B98622E + Oscar02IG = 1042644412, // 0x3E257DBC + Oscar02CSB = 3265229602, // 0xC29F7322 + JodiMarshallCSB = 2447125353 // 0x91DC2B69 } } diff --git a/api/AltV.Net.Shared/Enums/VehicleModel.cs b/api/AltV.Net.Shared/Enums/VehicleModel.cs index bad96869..b2d152c7 100644 --- a/api/AltV.Net.Shared/Enums/VehicleModel.cs +++ b/api/AltV.Net.Shared/Enums/VehicleModel.cs @@ -863,6 +863,24 @@ public enum VehicleModel : uint eurosX32 = 3295372994, // [0xC46B66C2] Euros X32 (CAR) pipistrello = 4071505793, // [0xF2AE3F81] Pipistrello (CAR) driftvorschlag = 4151380270, // [0xF771092E] Vorschlaghammer (CAR) - dominator10 = 1579902654 // [0x5E2B66BE] Dominator FX (CAR) + dominator10 = 1579902654, // [0x5E2B66BE] Dominator FX (CAR) + driftjester3 = 3932276298, // [0xEA61C64A] Jester Classic (CAR) + driftcheburek = 2828274931, // [0xA8940CF3] Cheburek (CAR) + youga5 = 2266063097, // [0x871160F9] Youga Custom (CAR) + freightcar3 = 2420957787, // [0x904CE25B] Freight Train (TRAIN) + uranus = 1534326199, // [0x5B73F5B7] Uranus LozSpeed (CAR) + banshee3 = 3634959571, // [0xD8A914D3] Banshee GTS (CAR) + duster2 = 84351789, // [0x5071B2D] Duster 300-H (PLANE) + titan2 = 858355070, // [0x3329757E] Titan 250 D (PLANE) + driftfuto2 = 3005741670, // [0xB327FA66] Futo (CAR) + chavosv6 = 1992041063, // [0x76BC2267] Chavos V6 (CAR) + jester5 = 1484920335, // [0x5882160F] Jester RR Widebody (CAR) + polcaracara = 2346018232, // [0x8BD565B8] Caracara Pursuit (CAR) + polfaction2 = 1891140410, // [0x70B8833A] Outreach Faction (CAR) + polterminus = 2973836112, // [0xB1412350] Terminus Patrol (CAR) + firebolt = 3321950518, // [0xC600F136] Firebolt ASP (CAR) + polcoquette4 = 2042703219, // [0x79C12D73] Coquette D10 Pursuit (CAR) + coquette6 = 127317925, // [0x796B7A5] Coquette D5 (CAR) + cargobob5 = 3942284983 // [0xEAFA7EB7] DH-7 Iron Mule (HELI) } } From 3332afcf16adc132e21d3ffd9a1486f21afd83e9 Mon Sep 17 00:00:00 2001 From: Tuk1s <40861802+TuK4z@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:19:23 +0200 Subject: [PATCH 02/10] Update setup.md (#39) .NET version changed --- docs/articles/getting-started/setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/articles/getting-started/setup.md b/docs/articles/getting-started/setup.md index 8037f39d..46bd5802 100644 --- a/docs/articles/getting-started/setup.md +++ b/docs/articles/getting-started/setup.md @@ -1,7 +1,7 @@ # Setup You need the following requirements to use the c# module. -* Latest [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0). +* Latest [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0). ## Step 1 From b02a1d9a85798cab9cae8533529cbbbc1399d35a Mon Sep 17 00:00:00 2001 From: Avepy <54192195+Avepy@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:52:18 +0100 Subject: [PATCH 03/10] refactor(server): OnWeaponDamageEvent and WeaponDamageResponse (#40) * refactor(server): OnWeaponDamageEvent and WeaponDamageResponse * refactor(server): OnWeaponDamageEvent and WeaponDamageResponse * refactor(server): OnWeaponDamageEvent and WeaponDamageResponse --- api/AltV.Net/Core.Events.cs | 82 ++++++++++++++++------- api/AltV.Net/Data/WeaponDamageResponse.cs | 23 +++++-- 2 files changed, 77 insertions(+), 28 deletions(-) diff --git a/api/AltV.Net/Core.Events.cs b/api/AltV.Net/Core.Events.cs index bce46bd8..7aa37724 100644 --- a/api/AltV.Net/Core.Events.cs +++ b/api/AltV.Net/Core.Events.cs @@ -538,21 +538,69 @@ public void OnWeaponDamage(IntPtr eventPointer, IntPtr playerPointer, IntPtr ent OnWeaponDamageEvent(eventPointer, sourcePlayer, targetEntity, weapon, damage, shotOffset, bodyPart); } + /// + /// Handles the weapon damage event triggered in the game. + /// + /// + /// This method iterates through all registered event handlers for weapon damage events, + /// determines whether the event should be canceled, and updates the damage value if modified + /// by any handler. + /// + /// If any handler indicates cancellation, the event is marked as canceled. + /// If a damage override is provided, it updates the damage value. + /// public virtual void OnWeaponDamageEvent(IntPtr eventPointer, IPlayer sourcePlayer, IEntity targetEntity, - uint weapon, ushort damage, - Position shotOffset, BodyPart bodyPart) + uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart) { + try + { + var (shouldCancel, weaponDamage) = + ProcessWeaponDamageEvents(sourcePlayer, targetEntity, weapon, damage, shotOffset, bodyPart); + + if (weaponDamage.HasValue) + { + unsafe + { + Alt.CoreImpl.Library.Server.Event_WeaponDamageEvent_SetDamageValue(eventPointer, + weaponDamage.Value); + } + } + + if (shouldCancel) + { + unsafe + { + Alt.CoreImpl.Library.Shared.Event_Cancel(eventPointer); + } + } + } + catch (Exception ex) + { + Alt.Log($"Unhandled exception in {nameof(OnWeaponDamageEvent)}: {ex}"); + } + } + + /// + /// Processes weapon damage events by invoking all registered event handlers and aggregating results. + /// + /// + /// A tuple containing a flag indicating if the event should be canceled and the aggregated weapon damage value. + /// + private (bool shouldCancel, uint? weaponDamage) ProcessWeaponDamageEvents(IPlayer sourcePlayer, + IEntity targetEntity, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart) + { + var shouldCancel = false; uint? weaponDamage = null; - var cancel = false; + foreach (var @delegate in WeaponDamageEventHandler.GetEvents()) { try { var result = @delegate(sourcePlayer, targetEntity, weapon, damage, shotOffset, bodyPart); - if (!result.notCancel) + if (result.Cancel) { - cancel = true; + shouldCancel = true; } if (result.Damage.HasValue) @@ -560,31 +608,17 @@ public virtual void OnWeaponDamageEvent(IntPtr eventPointer, IPlayer sourcePlaye weaponDamage ??= result.Damage.Value; } } - catch (TargetInvocationException exception) + catch (TargetInvocationException tex) { - Alt.Log("exception at event:" + "OnWeaponDamageEvent" + ":" + exception.InnerException); + Alt.Log($"TargetInvocationException in {nameof(ProcessWeaponDamageEvents)} handler: {tex.InnerException}"); } - catch (Exception exception) + catch (Exception ex) { - Alt.Log("exception at event:" + "OnWeaponDamageEvent" + ":" + exception); + Alt.Log($"Exception in {nameof(ProcessWeaponDamageEvents)} handler: {ex}"); } } - if (weaponDamage is not null) - { - unsafe - { - Alt.CoreImpl.Library.Server.Event_WeaponDamageEvent_SetDamageValue(eventPointer, weaponDamage.Value); - } - } - - if (cancel) - { - unsafe - { - Alt.CoreImpl.Library.Shared.Event_Cancel(eventPointer); - } - } + return (shouldCancel, weaponDamage); } public void OnPlayerChangeVehicleSeat(IntPtr vehiclePointer, IntPtr playerPointer, byte oldSeat, diff --git a/api/AltV.Net/Data/WeaponDamageResponse.cs b/api/AltV.Net/Data/WeaponDamageResponse.cs index 43bf4f69..840661a2 100644 --- a/api/AltV.Net/Data/WeaponDamageResponse.cs +++ b/api/AltV.Net/Data/WeaponDamageResponse.cs @@ -1,6 +1,21 @@ namespace AltV.Net.Data; -public record WeaponDamageResponse(bool notCancel, uint? Damage) { - public static implicit operator WeaponDamageResponse(bool val) => new WeaponDamageResponse(val, null); - public static implicit operator WeaponDamageResponse(uint val) => new WeaponDamageResponse(true, val); -}; \ No newline at end of file +/// +/// Represents the response to a weapon damage event, indicating whether the damage is processed and the amount of damage. +/// +public record WeaponDamageResponse(bool Cancel, uint? Damage) +{ + /// + /// Implicit conversion from a boolean value to . + /// Sets to the specified value and to null. + /// + /// Indicates whether the damage is processed. + public static implicit operator WeaponDamageResponse(bool cancel) => new(cancel, null); + + /// + /// Implicit conversion from an uint value to . + /// Sets to true and to the specified value. + /// + /// The amount of damage. + public static implicit operator WeaponDamageResponse(uint damage) => new(false, damage); +} From 4e913c311a149a97893802a070756c641b9537e9 Mon Sep 17 00:00:00 2001 From: deluvas Date: Fri, 20 Dec 2024 11:29:20 +0100 Subject: [PATCH 04/10] Update runtime --- runtime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime b/runtime index 8d63f72c..edb6ab0a 160000 --- a/runtime +++ b/runtime @@ -1 +1 @@ -Subproject commit 8d63f72c93983599baa262fb1af0337277873763 +Subproject commit edb6ab0a60f0115831492147b9621f7cebd1e2eb From 201bfd3a12c5bdd43d5a440196127c96e94665e4 Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Sun, 22 Dec 2024 15:17:13 +0100 Subject: [PATCH 05/10] add CONTRIBUTE.md --- CONTRIBUTE.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 CONTRIBUTE.md diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md new file mode 100644 index 00000000..8c8920c6 --- /dev/null +++ b/CONTRIBUTE.md @@ -0,0 +1,40 @@ +# How to Contribute + +## Implementing [cpp-sdk](https://github.com/altmp/cpp-sdk) Changes + +To implement a new `cpp-sdk` change or add a missing implementation, follow these steps: + +1. **Create a New Branch** + - Start by creating a new branch based on the [dev](https://github.com/altmp/coreclr-module/tree/dev) branch. + - In the submodule `runtime`, create another branch also based on the [dev](https://github.com/altmp/coreclr-module-runtime/tree/dev) branch. + +2. **Update the cpp-sdk Version** + - If required, update the `cpp-sdk` version in the `runtime` branch. + +3. **Add the cpp-sdk Method** + - Add the new `cpp-sdk` method to the appropriate classes. + For example, to implement [IPlayer.GetSocialClubId()](https://github.com/altmp/cpp-sdk/blob/30b5e35ab7081f7e8ff7ac2bc0568aa7cf38e6be/objects/IPlayer.h#L90C20-L90C31), update the following runtime classes: + - [player.h](https://github.com/altmp/coreclr-module-runtime/blob/dev/c-api/entities/player.h) + - [player.cpp](https://github.com/altmp/coreclr-module-runtime/blob/dev/c-api/entities/player.cpp) + +4. **Run the CApi Generator** + - Run the [CApi Generator](https://github.com/altmp/coreclr-module/blob/dev/api/AltV.Net.CApi.Generator/Program.cs) with the `runtime/c-api` folder as the working directory. + +5. **Push Changes** + - Push all changes to the `runtime` branch. + +6. **Implement the Method in the C# Module** + - Use the `runtime` branch to implement the method within the C# module. + For the example above, add the `SocialClubId` as a getter to the `IPlayer` interface. + +7. **Add the Getter Implementation** + - Implement the getter in the `Player` class to invoke the unsafe runtime call `Core.Library.*`. + +8. **Extend the AsyncPlayer Class** + - Add the method to the `AsyncPlayer` class, ensuring it calls the parent method from the `Player` class. + +9. **Push Changes** + - Push all changes to the `module` branch. + +10. **Submit Pull Requests** + - Create separate pull requests for both the `module` branch and the `runtime` branch. From e4e1f02bd0acc49c4a2fb7ed045d690b4badd9ec Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Sun, 22 Dec 2024 15:34:29 +0100 Subject: [PATCH 06/10] add testing part --- CONTRIBUTE.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 8c8920c6..ae7dc024 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -36,5 +36,28 @@ To implement a new `cpp-sdk` change or add a missing implementation, follow thes 9. **Push Changes** - Push all changes to the `module` branch. -10. **Submit Pull Requests** +10. **Testing** + - To test the changes, use the `build.bat` file in the `runtime/server` folder to generate a `coreclr-module.dll`. + - Place the generated DLL in the server's `modules` folder. + - Build the module project and copy the new module DLLs to the C# resource folder and the project directory of the resource. + ``` + + + lib\AltV.Net.dll + + + lib\AltV.Net.Async.dll + + + lib\AltV.Net.Interactions.dll + + + PreserveNewest + + + ``` + - Test your changes thoroughly. + - **Clientside cannot be tested yet** + +11. **Submit Pull Requests** - Create separate pull requests for both the `module` branch and the `runtime` branch. From 6394eef654aabc4f6872d96e996156931f09c958 Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 26 Dec 2024 10:03:59 +0100 Subject: [PATCH 07/10] add gen script for nethost --- CONTRIBUTE.md | 3 +- download_dotnet.ps1 | 67 ++++++++++++++++++++++++------------------- gen_local_win_env.ps1 | 28 ++++++++++++++++++ 3 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 gen_local_win_env.ps1 diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index ae7dc024..1ef184b0 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -37,7 +37,8 @@ To implement a new `cpp-sdk` change or add a missing implementation, follow thes - Push all changes to the `module` branch. 10. **Testing** - - To test the changes, use the `build.bat` file in the `runtime/server` folder to generate a `coreclr-module.dll`. + - Open powershell window, change directory to root module folder. Run `gen_local_win_env.ps1` and wait everything downloaded. + - To test the changes, use the `windows-build.bat` file in the `runtime/server` folder to generate a `coreclr-module.dll`. - Place the generated DLL in the server's `modules` folder. - Build the module project and copy the new module DLLs to the C# resource folder and the project directory of the resource. ``` diff --git a/download_dotnet.ps1 b/download_dotnet.ps1 index 88f9d2f1..fc2137fc 100644 --- a/download_dotnet.ps1 +++ b/download_dotnet.ps1 @@ -1,63 +1,72 @@ param( $path, - $os + $os, + $pack = $true ) +Write-Host "Downloading latest dotnet" Write-Host $path Write-Host $os +Write-Host $pack $start = $pwd -cd $path +Set-Location $path $dotnetRelease = Invoke-WebRequest 'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/8.0/releases.json' | ConvertFrom-Json $dotnetVersion = $dotnetRelease."latest-release" -if($os -eq "win"){ +if ($os -eq "win") { $file = "dotnet-sdk-win-x64.zip" -}else{ +} +else { $file = "dotnet-sdk-linux-x64.tar.gz" } -$dotnetSdkZipUrl = $dotnetRelease.releases[0].sdk.files | where { $_.name -eq $file } | Select -ExpandProperty "url" | Out-String +$dotnetSdkZipUrl = $dotnetRelease.releases[0].sdk.files | Where-Object { $_.name -eq $file } | Select-Object -ExpandProperty "url" | Out-String Write-Host "Download dotnet version: $dotnetVersion" Write-Host "Download from cdn: $dotnetSdkZipUrl" -if($os -eq "win"){ - $dfile = "dontet_version_$dotnetVersion.zip" -}else{ - $dfile = "dontet_version_$dotnetVersion.tar.gz" +if ($os -eq "win") { + $dfile = "dotnet_version_$dotnetVersion.zip" +} +else { + $dfile = "dotnet_version_$dotnetVersion.tar.gz" } -Invoke-RestMethod -Uri $dotnetSdkZipUrl -OutFile "$path\$dfile" +Invoke-RestMethod -Uri $dotnetSdkZipUrl -OutFile "$dfile" -Write-Host "Download successfully to $path\$dfile" +Write-Host "Download successfully to $dfile" -if($os -eq "win"){ - Expand-Archive -LiteralPath "$path\\$dfile" -DestinationPath "$path\dontet_version_$dotnetVersion_$os" -}else{ - mkdir "$path/dontet_version_$dotnetVersion_$os" - tar -zxvf "$path/$dfile" -C "$path/dontet_version_$dotnetVersion_$os" +if ($os -eq "win") { + Expand-Archive -LiteralPath "$dfile" -DestinationPath "dotnet_version_$dotnetVersion_$os" +} +else { + mkdir "dotnet_version_$dotnetVersion_$os" + tar -zxvf "$dfile" -C "dotnet_version_$dotnetVersion_$os" } Write-Host "Extraxt successfully" -if($os -eq "win"){ - cd "$path\dontet_version_$dotnetVersion_$os\packs\Microsoft.NETCore.App.Host.win-x64\$dotnetVersion\runtimes\win-x64\native" -}else{ - cd "$path\dontet_version_$dotnetVersion_$os\packs\Microsoft.NETCore.App.Host.linux-x64\$dotnetVersion\runtimes\linux-x64\native" +if ($os -eq "win") { + Set-Location "dotnet_version_$dotnetVersion_$os\packs\Microsoft.NETCore.App.Host.win-x64\$dotnetVersion\runtimes\win-x64\native" } - -Write-Host "Pack libnethost" - -if($os -eq "win"){ - tar -cvzf $path\libnethost.tar * -}else{ - tar -cvzf "$path/libnethost.tar" * +else { + Set-Location "dotnet_version_$dotnetVersion_$os\packs\Microsoft.NETCore.App.Host.linux-x64\$dotnetVersion\runtimes\linux-x64\native" } -Write-Host "Pack successfully" +if ($pack) { + Write-Host "Pack libnethost" + + if ($os -eq "win") { + tar -cvzf $path\libnethost.tar * + } + else { + tar -cvzf "$path/libnethost.tar" * + } -cd $start \ No newline at end of file + Write-Host "Pack successfully" + Set-Location $start +} \ No newline at end of file diff --git a/gen_local_win_env.ps1 b/gen_local_win_env.ps1 new file mode 100644 index 00000000..c10e9fe7 --- /dev/null +++ b/gen_local_win_env.ps1 @@ -0,0 +1,28 @@ +$start = $pwd + +$nethostPath = "runtime/nethost" +$tmpPath = "runtime/tmp" + +if (Test-Path -Path $nethostPath) { + # Delete folder + Remove-Item -Path $nethostPath -Recurse -Force + Write-Host "Folder '$nethostPath' deleted" +} + +New-Item -ItemType Directory -Path $nethostPath | Out-Null +Write-Host "Folder '$nethostPath' created" + +if (Test-Path -Path $tmpPath) { + # Delete folder + Remove-Item -Path $tmpPath -Recurse -Force +} + +New-Item -ItemType Directory -Path $tmpPath | Out-Null + +& "./download_dotnet.ps1" $tmpPath "win" $false + +$currentDir = Get-Location +Copy-Item -Path "$currentDir\*" -Destination "$start/$nethostPath" -Recurse -Force +Remove-Item -Path $tmpPath -Recurse -Force + +Set-Location $start \ No newline at end of file From 945a4eaec68befadf55755fb1f1336d42112d7dc Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 26 Dec 2024 14:02:48 +0100 Subject: [PATCH 08/10] ALTV-469 - add new hwid (#33) --- .../Elements/Entities/AsyncConnectionInfo.cs | 14 +++++++++++++ .../Elements/Entities/AsyncPlayer.cs | 12 +++++++++++ api/AltV.Net.CApi/Libraries/ClientLibrary.cs | 4 ++-- api/AltV.Net.CApi/Libraries/ServerLibrary.cs | 14 +++++++++++-- api/AltV.Net.CApi/Libraries/SharedLibrary.cs | 4 ++-- .../Elements/Entities/ConnectionInfo.cs | 20 ++++++++++++++++--- .../Elements/Entities/IConnectionInfo.cs | 1 + api/AltV.Net/Elements/Entities/IPlayer.cs | 2 ++ api/AltV.Net/Elements/Entities/Player.cs | 14 +++++++++++++ runtime | 2 +- 10 files changed, 77 insertions(+), 10 deletions(-) diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs b/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs index b5e732b6..a10907eb 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncConnectionInfo.cs @@ -63,6 +63,19 @@ public ulong HardwareIdExHash } } } + + public string HardwareId3 + { + get + { + lock (ConnectionInfo) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(ConnectionInfo)) return default; + return ConnectionInfo.HardwareId3; + } + } + } + public string AuthToken { get @@ -74,6 +87,7 @@ public string AuthToken } } } + public bool IsDebug { get diff --git a/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs b/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs index 1ef1cef3..c5ef7985 100644 --- a/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs +++ b/api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs @@ -100,6 +100,18 @@ public ulong HardwareIdExHash } } + public string HardwareId3 + { + get + { + lock (Player) + { + if (!AsyncContext.CheckIfExistsOrCachedNullable(Player)) return default; + return Player.HardwareId3; + } + } + } + public string AuthToken { get diff --git a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs index a01ac036..643568c6 100644 --- a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs @@ -938,7 +938,7 @@ public unsafe interface IClientLibrary public unsafe class ClientLibrary : IClientLibrary { - public readonly uint Methods = 1809; + public readonly uint Methods = 1811; public delegate* unmanaged[Cdecl] Audio_AddOutput { get; } public delegate* unmanaged[Cdecl] Audio_GetBaseObject { get; } public delegate* unmanaged[Cdecl] Audio_GetCurrentTime { get; } @@ -3717,7 +3717,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 != 10075699596264467259UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 2737407539021183714UL) 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); diff --git a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs index d58cebb1..40c34383 100644 --- a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs @@ -35,6 +35,7 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudAuthResult { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudID { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetDiscordUserID { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwid3 { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwIdExHash { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwIdHash { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetID { get; } @@ -194,6 +195,7 @@ public unsafe interface IServerLibrary public delegate* unmanaged[Cdecl] Player_GetHeadBlendData { get; } public delegate* unmanaged[Cdecl] Player_GetHeadBlendPaletteColor { get; } public delegate* unmanaged[Cdecl] Player_GetHeadOverlay { get; } + public delegate* unmanaged[Cdecl] Player_GetHwid3 { get; } public delegate* unmanaged[Cdecl] Player_GetHwidExHash { get; } public delegate* unmanaged[Cdecl] Player_GetHwidHash { get; } public delegate* unmanaged[Cdecl] Player_GetInteriorLocation { get; } @@ -488,7 +490,7 @@ public unsafe interface IServerLibrary public unsafe class ServerLibrary : IServerLibrary { - public readonly uint Methods = 1809; + public readonly uint Methods = 1811; public delegate* unmanaged[Cdecl] BaseObject_DeleteSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetMultipleSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetSyncedMetaData { get; } @@ -513,6 +515,7 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudAuthResult { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetCloudID { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetDiscordUserID { get; } + public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwid3 { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwIdExHash { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetHwIdHash { get; } public delegate* unmanaged[Cdecl] ConnectionInfo_GetID { get; } @@ -672,6 +675,7 @@ public unsafe class ServerLibrary : IServerLibrary public delegate* unmanaged[Cdecl] Player_GetHeadBlendData { get; } public delegate* unmanaged[Cdecl] Player_GetHeadBlendPaletteColor { get; } public delegate* unmanaged[Cdecl] Player_GetHeadOverlay { get; } + public delegate* unmanaged[Cdecl] Player_GetHwid3 { get; } public delegate* unmanaged[Cdecl] Player_GetHwidExHash { get; } public delegate* unmanaged[Cdecl] Player_GetHwidHash { get; } public delegate* unmanaged[Cdecl] Player_GetInteriorLocation { get; } @@ -1010,6 +1014,8 @@ public unsafe class ServerLibrary : IServerLibrary private static nint ConnectionInfo_GetCloudIDFallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetCloudID", "ConnectionInfo_GetCloudID SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate long ConnectionInfo_GetDiscordUserIDDelegate(IntPtr _connectionInfo); private static long ConnectionInfo_GetDiscordUserIDFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetDiscordUserID", "ConnectionInfo_GetDiscordUserID SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint ConnectionInfo_GetHwid3Delegate(IntPtr _connectionInfo, int* _size); + private static nint ConnectionInfo_GetHwid3Fallback(IntPtr _connectionInfo, int* _size) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetHwid3", "ConnectionInfo_GetHwid3 SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong ConnectionInfo_GetHwIdExHashDelegate(IntPtr _connectionInfo); private static ulong ConnectionInfo_GetHwIdExHashFallback(IntPtr _connectionInfo) => throw new Exceptions.OutdatedSdkException("ConnectionInfo_GetHwIdExHash", "ConnectionInfo_GetHwIdExHash SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong ConnectionInfo_GetHwIdHashDelegate(IntPtr _connectionInfo); @@ -1328,6 +1334,8 @@ public unsafe class ServerLibrary : IServerLibrary private static void Player_GetHeadBlendPaletteColorFallback(nint _player, byte _id, Rgba* _headBlendPaletteColor) => throw new Exceptions.OutdatedSdkException("Player_GetHeadBlendPaletteColor", "Player_GetHeadBlendPaletteColor SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Player_GetHeadOverlayDelegate(nint _player, byte _overlayID, HeadOverlay* _headOverlay); private static void Player_GetHeadOverlayFallback(nint _player, byte _overlayID, HeadOverlay* _headOverlay) => throw new Exceptions.OutdatedSdkException("Player_GetHeadOverlay", "Player_GetHeadOverlay SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate nint Player_GetHwid3Delegate(nint _player, int* _size); + private static nint Player_GetHwid3Fallback(nint _player, int* _size) => throw new Exceptions.OutdatedSdkException("Player_GetHwid3", "Player_GetHwid3 SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Player_GetHwidExHashDelegate(nint _player); private static ulong Player_GetHwidExHashFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_GetHwidExHash", "Player_GetHwidExHash SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate ulong Player_GetHwidHashDelegate(nint _player); @@ -1917,7 +1925,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 != 10075699596264467259UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 2737407539021183714UL) 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); @@ -1942,6 +1950,7 @@ public ServerLibrary(Dictionary funcTable) ConnectionInfo_GetCloudAuthResult = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7415605567391116903UL, ConnectionInfo_GetCloudAuthResultFallback); ConnectionInfo_GetCloudID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 7998061229071288348UL, ConnectionInfo_GetCloudIDFallback); ConnectionInfo_GetDiscordUserID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 4175744399917476392UL, ConnectionInfo_GetDiscordUserIDFallback); + ConnectionInfo_GetHwid3 = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3230557606089997547UL, ConnectionInfo_GetHwid3Fallback); ConnectionInfo_GetHwIdExHash = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 3151831504154255688UL, ConnectionInfo_GetHwIdExHashFallback); ConnectionInfo_GetHwIdHash = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11409383581668438027UL, ConnectionInfo_GetHwIdHashFallback); ConnectionInfo_GetID = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 8080268107975854795UL, ConnectionInfo_GetIDFallback); @@ -2101,6 +2110,7 @@ public ServerLibrary(Dictionary funcTable) Player_GetHeadBlendData = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12996031514192232278UL, Player_GetHeadBlendDataFallback); Player_GetHeadBlendPaletteColor = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 6875264309357036667UL, Player_GetHeadBlendPaletteColorFallback); Player_GetHeadOverlay = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 18242810182906526031UL, Player_GetHeadOverlayFallback); + Player_GetHwid3 = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 13686597780873033455UL, Player_GetHwid3Fallback); Player_GetHwidExHash = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 424368865670330442UL, Player_GetHwidExHashFallback); Player_GetHwidHash = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 9546723288515311389UL, Player_GetHwidHashFallback); Player_GetInteriorLocation = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16961931856292652951UL, Player_GetInteriorLocationFallback); diff --git a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs index 40a28e93..c503b112 100644 --- a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs @@ -426,7 +426,7 @@ public unsafe interface ISharedLibrary public unsafe class SharedLibrary : ISharedLibrary { - public readonly uint Methods = 1809; + public readonly uint Methods = 1811; public delegate* unmanaged[Cdecl] Audio_GetID { get; } public delegate* unmanaged[Cdecl] AudioAttachedOutput_GetID { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetID { get; } @@ -1669,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 != 10075699596264467259UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 2737407539021183714UL) 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); diff --git a/api/AltV.Net/Elements/Entities/ConnectionInfo.cs b/api/AltV.Net/Elements/Entities/ConnectionInfo.cs index caffd25c..72b89d7e 100644 --- a/api/AltV.Net/Elements/Entities/ConnectionInfo.cs +++ b/api/AltV.Net/Elements/Entities/ConnectionInfo.cs @@ -11,7 +11,6 @@ namespace AltV.Net.Elements.Entities; public class ConnectionInfo : BaseObject, IConnectionInfo { - public IntPtr ConnectionInfoNativePointer { get; } public override IntPtr NativePointer => ConnectionInfoNativePointer; @@ -32,7 +31,8 @@ public static uint GetId(IntPtr pointer) } - public ConnectionInfo(ICore core, IntPtr nativePointer, uint id) : base(core, GetBaseObjectPointer(core, nativePointer), BaseObjectType.ConnectionInfo, id) + public ConnectionInfo(ICore core, IntPtr nativePointer, uint id) : base(core, + GetBaseObjectPointer(core, nativePointer), BaseObjectType.ConnectionInfo, id) { ConnectionInfoNativePointer = nativePointer; } @@ -83,6 +83,19 @@ public ulong HardwareIdExHash } } + public string HardwareId3 + { + get + { + unsafe + { + var size = 0; + return Core.PtrToStringUtf8AndFree( + Core.Library.Server.ConnectionInfo_GetHwid3(ConnectionInfoNativePointer, &size), size); + } + } + } + public string AuthToken { get @@ -274,7 +287,8 @@ public CloudAuthResult CloudAuthResult { unsafe { - return (CloudAuthResult)Core.Library.Server.ConnectionInfo_GetCloudAuthResult(ConnectionInfoNativePointer); + return (CloudAuthResult)Core.Library.Server.ConnectionInfo_GetCloudAuthResult( + ConnectionInfoNativePointer); } } } diff --git a/api/AltV.Net/Elements/Entities/IConnectionInfo.cs b/api/AltV.Net/Elements/Entities/IConnectionInfo.cs index bceb3b01..1ca0d477 100644 --- a/api/AltV.Net/Elements/Entities/IConnectionInfo.cs +++ b/api/AltV.Net/Elements/Entities/IConnectionInfo.cs @@ -12,6 +12,7 @@ public interface IConnectionInfo : IBaseObject ulong SocialId { get; } ulong HardwareIdHash { get; } ulong HardwareIdExHash { get; } + string HardwareId3 { get; } string AuthToken { get; } bool IsDebug { get; } string Branch { get; } diff --git a/api/AltV.Net/Elements/Entities/IPlayer.cs b/api/AltV.Net/Elements/Entities/IPlayer.cs index d3eff7a7..43c374e9 100644 --- a/api/AltV.Net/Elements/Entities/IPlayer.cs +++ b/api/AltV.Net/Elements/Entities/IPlayer.cs @@ -36,6 +36,8 @@ public interface IPlayer : ISharedPlayer, IEntity ulong HardwareIdExHash { get; } + string HardwareId3 { get; } + string AuthToken { get; } long DiscordId { get; } diff --git a/api/AltV.Net/Elements/Entities/Player.cs b/api/AltV.Net/Elements/Entities/Player.cs index ba8fd745..df148ff2 100644 --- a/api/AltV.Net/Elements/Entities/Player.cs +++ b/api/AltV.Net/Elements/Entities/Player.cs @@ -536,6 +536,20 @@ public ulong HardwareIdExHash } } + public string HardwareId3 + { + get + { + unsafe + { + CheckIfEntityExistsOrCached(); + var size = 0; + return Core.PtrToStringUtf8AndFree( + Core.Library.Server.Player_GetHwid3(PlayerNativePointer, &size), size); + } + } + } + public string AuthToken { get diff --git a/runtime b/runtime index edb6ab0a..96c808e0 160000 --- a/runtime +++ b/runtime @@ -1 +1 @@ -Subproject commit edb6ab0a60f0115831492147b9621f7cebd1e2eb +Subproject commit 96c808e0adc34c5bdf8b17f36aa26f1592022bc8 From 972d0c737e659cedac9b37751583960d117a49ad Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 26 Dec 2024 14:04:37 +0100 Subject: [PATCH 09/10] fix gen local env --- gen_local_win_env.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen_local_win_env.ps1 b/gen_local_win_env.ps1 index c10e9fe7..c92105ab 100644 --- a/gen_local_win_env.ps1 +++ b/gen_local_win_env.ps1 @@ -23,6 +23,6 @@ New-Item -ItemType Directory -Path $tmpPath | Out-Null $currentDir = Get-Location Copy-Item -Path "$currentDir\*" -Destination "$start/$nethostPath" -Recurse -Force -Remove-Item -Path $tmpPath -Recurse -Force -Set-Location $start \ No newline at end of file +Set-Location $start +Remove-Item -Path $tmpPath -Recurse -Force \ No newline at end of file From 51cdf54a28eeec8140482133ec16a207d08660a9 Mon Sep 17 00:00:00 2001 From: Till Schreiber Date: Thu, 9 Jan 2025 13:53:22 +0100 Subject: [PATCH 10/10] Altv 626 (#46) * ALTV-626 - add PlayerDimensionChangeModuleDelegate to client * ALTV-626 - update runtime --- api/AltV.Net.CApi/Events/ClientEvents.cs | 84 +++++++++++++++---- api/AltV.Net.CApi/Libraries/ClientLibrary.cs | 9 +- api/AltV.Net.CApi/Libraries/ServerLibrary.cs | 4 +- api/AltV.Net.CApi/Libraries/SharedLibrary.cs | 4 +- api/AltV.Net.Client/Alt.Events.cs | 6 ++ api/AltV.Net.Client/Core.Events.cs | 15 ++++ api/AltV.Net.Client/Events/Events.cs | 1 + api/AltV.Net.Client/ModuleWrapper.cs | 5 ++ .../Runtime/CSharpResourceImpl.cs | 5 ++ runtime | 2 +- 10 files changed, 110 insertions(+), 25 deletions(-) diff --git a/api/AltV.Net.CApi/Events/ClientEvents.cs b/api/AltV.Net.CApi/Events/ClientEvents.cs index e4c8822a..5dd416e2 100644 --- a/api/AltV.Net.CApi/Events/ClientEvents.cs +++ b/api/AltV.Net.CApi/Events/ClientEvents.cs @@ -8,86 +8,134 @@ namespace AltV.Net.CApi.ClientEvents public delegate void TickModuleDelegate(); public delegate void ClientEventModuleDelegate(string name, IntPtr args, ulong size); + public delegate void ServerEventModuleDelegate(string name, IntPtr args, ulong size); + public delegate void WebViewEventModuleDelegate(IntPtr webView, string name, IntPtr args, ulong size); + public delegate void RmlEventModuleDelegate(IntPtr rmlElement, string name, IntPtr args); + public delegate void WebSocketEventModuleDelegate(IntPtr webSocket, string name, IntPtr args, ulong size); + public delegate void AudioEventModuleDelegate(IntPtr audio, string name, IntPtr args, ulong size); - public delegate void ConsoleCommandModuleDelegate(string name, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize); + + public delegate void ConsoleCommandModuleDelegate(string name, + [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] string[] args, int argsSize); public delegate void PlayerSpawnModuleDelegate(); + public delegate void PlayerDisconnectModuleDelegate(); + public delegate void PlayerEnterVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat); + public delegate void PlayerLeaveVehicleModuleDelegate(IntPtr baseObject, BaseObjectType type, byte seat); - public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat, byte newSeat); - public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict, uint newDict, uint oldName, uint newName); - public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc, uint newIntLoc); + + public delegate void PlayerChangeVehicleSeatModuleDelegate(IntPtr pointer, BaseObjectType type, byte oldSeat, + byte newSeat); + + public delegate void PlayerChangeAnimationModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldDict, + uint newDict, uint oldName, uint newName); + + public delegate void PlayerChangeInteriorModuleDelegate(IntPtr pointer, BaseObjectType type, uint oldIntLoc, + uint newIntLoc); + + public delegate void PlayerDimensionChangeModuleDelegate(IntPtr pointer, BaseObjectType type, int oldDim, + int newDim); + public delegate void PlayerWeaponShootModuleDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip); + public delegate void PlayerWeaponChangeModuleDelegate(uint oldWeapon, uint newWeapon); public delegate void GameEntityCreateModuleDelegate(IntPtr pointer, BaseObjectType type); + public delegate void GameEntityDestroyModuleDelegate(IntPtr pointer, BaseObjectType type); public delegate void AnyResourceErrorModuleDelegate(string name); + public delegate void AnyResourceStartModuleDelegate(string name); + public delegate void AnyResourceStopModuleDelegate(string name); public delegate void KeyDownModuleDelegate(uint key); + public delegate void KeyUpModuleDelegate(uint key); public delegate void ScreenshotResultModuleDelegate(IntPtr strPtr); - public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues, int headerSize); + + public delegate void HttpResponseModuleDelegate(int statusCode, string body, IntPtr headerKeys, IntPtr headerValues, + int headerSize); public delegate void ConnectionCompleteModuleDelegate(); public delegate void GlobalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); + public delegate void GlobalSyncedMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); public delegate void LocalMetaChangeModuleDelegate(string key, IntPtr value, IntPtr oldValue); - public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); - public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); - public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, IntPtr oldValue); + + public delegate void StreamSyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, + IntPtr value, IntPtr oldValue); + + public delegate void SyncedMetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, + IntPtr oldValue); + + public delegate void MetaChangeModuleDelegate(IntPtr target, BaseObjectType type, string key, IntPtr value, + IntPtr oldValue); public delegate void TaskChangeModuleDelegate(int oldTask, int newTask); public delegate void WindowFocusChangeModuleDelegate(byte state); + public delegate void WindowResolutionChangeModuleDelegate(Vector2 oldResolution, Vector2 newResolution); - public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type, Position oldPosition); + public delegate void WorldObjectPositionChangeModuleDelegate(IntPtr target, BaseObjectType type, + Position oldPosition); + public delegate void WorldObjectStreamInModuleDelegate(IntPtr target, BaseObjectType type); + public delegate void WorldObjectStreamOutModuleDelegate(IntPtr target, BaseObjectType type); - public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner, IntPtr oldOwner); + public delegate void NetOwnerChangeModuleDelegate(IntPtr target, BaseObjectType type, IntPtr newOwner, + IntPtr oldOwner); public delegate void DiscordOAuth2TokenResultModuleDelegate(byte success, string token); public delegate void WeaponDamageModuleDelegate(IntPtr eventPointer, IntPtr entityPointer, - BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart, IntPtr sourceEntityPointer, + BaseObjectType entityType, uint weapon, ushort damage, Position shotOffset, BodyPart bodyPart, + IntPtr sourceEntityPointer, BaseObjectType sourceEntityType); public delegate void CreateBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type, uint id); public delegate void RemoveBaseObjectModuleDelegate(IntPtr baseObject, BaseObjectType type); - public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType, + public delegate void ColShapeModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, + BaseObjectType entityType, byte state); - public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, BaseObjectType entityType, + + public delegate void CheckpointModuleDelegate(IntPtr colShapePointer, IntPtr targetEntityPointer, + BaseObjectType entityType, byte state); - public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, IntPtr damagerPointer, + public delegate void EntityHitEntityModuleDelegate(IntPtr targetPointer, BaseObjectType targetType, + IntPtr damagerPointer, BaseObjectType damagerType, uint weaponHash); - public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat); - public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, BaseObjectType playerType, byte seat); + public delegate void PlayerStartEnterVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, + BaseObjectType playerType, byte seat); + + public delegate void PlayerStartLeaveVehicleModuleDelegate(IntPtr targetPointer, BaseObjectType type, IntPtr player, + BaseObjectType playerType, byte seat); public delegate void PlayerBulletHitModuleDelegate(uint weapon, IntPtr victimPointer, BaseObjectType victimType, Position pos); public delegate void VoiceConnectionModuleDelegate(VoiceConnectionState state); - public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size, ushort answerId); + public delegate void ScriptRPCModuleDelegate(IntPtr eventPointer, string name, IntPtr args, ulong size, + ushort answerId); public delegate void ScriptRPCAnswerModuleDelegate(ushort answerId, IntPtr answer, string answerError); -} \ 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 643568c6..46b6978a 100644 --- a/api/AltV.Net.CApi/Libraries/ClientLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ClientLibrary.cs @@ -300,6 +300,7 @@ public unsafe interface IClientLibrary public delegate* unmanaged[Cdecl] Event_SetPlayerChangeAnimationDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeInteriorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeVehicleSeatDelegate { get; } + public delegate* unmanaged[Cdecl] Event_SetPlayerDimensionChangeDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerDisconnectDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerEnterVehicleDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerLeaveVehicleDelegate { get; } @@ -938,7 +939,7 @@ public unsafe interface IClientLibrary public unsafe class ClientLibrary : IClientLibrary { - public readonly uint Methods = 1811; + public readonly uint Methods = 1812; public delegate* unmanaged[Cdecl] Audio_AddOutput { get; } public delegate* unmanaged[Cdecl] Audio_GetBaseObject { get; } public delegate* unmanaged[Cdecl] Audio_GetCurrentTime { get; } @@ -1228,6 +1229,7 @@ public unsafe class ClientLibrary : IClientLibrary public delegate* unmanaged[Cdecl] Event_SetPlayerChangeAnimationDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeInteriorDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerChangeVehicleSeatDelegate { get; } + public delegate* unmanaged[Cdecl] Event_SetPlayerDimensionChangeDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerDisconnectDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerEnterVehicleDelegate { get; } public delegate* unmanaged[Cdecl] Event_SetPlayerLeaveVehicleDelegate { get; } @@ -2440,6 +2442,8 @@ public unsafe class ClientLibrary : IClientLibrary private static void Event_SetPlayerChangeInteriorDelegateFallback(nint _resource, ClientEvents.PlayerChangeInteriorModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerChangeInteriorDelegate", "Event_SetPlayerChangeInteriorDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerChangeVehicleSeatDelegateDelegate(nint _resource, ClientEvents.PlayerChangeVehicleSeatModuleDelegate _delegate); private static void Event_SetPlayerChangeVehicleSeatDelegateFallback(nint _resource, ClientEvents.PlayerChangeVehicleSeatModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerChangeVehicleSeatDelegate", "Event_SetPlayerChangeVehicleSeatDelegate SDK method is outdated. Please update your module nuget"); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerDimensionChangeDelegateDelegate(nint _resource, ClientEvents.PlayerDimensionChangeModuleDelegate _delegate); + private static void Event_SetPlayerDimensionChangeDelegateFallback(nint _resource, ClientEvents.PlayerDimensionChangeModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerDimensionChangeDelegate", "Event_SetPlayerDimensionChangeDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerDisconnectDelegateDelegate(nint _resource, ClientEvents.PlayerDisconnectModuleDelegate _delegate); private static void Event_SetPlayerDisconnectDelegateFallback(nint _resource, ClientEvents.PlayerDisconnectModuleDelegate _delegate) => throw new Exceptions.OutdatedSdkException("Event_SetPlayerDisconnectDelegate", "Event_SetPlayerDisconnectDelegate SDK method is outdated. Please update your module nuget"); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Event_SetPlayerEnterVehicleDelegateDelegate(nint _resource, ClientEvents.PlayerEnterVehicleModuleDelegate _delegate); @@ -3717,7 +3721,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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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); @@ -4007,6 +4011,7 @@ public ClientLibrary(Dictionary funcTable) Event_SetPlayerChangeAnimationDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 1013031841840963141UL, Event_SetPlayerChangeAnimationDelegateFallback); Event_SetPlayerChangeInteriorDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10641081887455190199UL, Event_SetPlayerChangeInteriorDelegateFallback); Event_SetPlayerChangeVehicleSeatDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 2849447755791784577UL, Event_SetPlayerChangeVehicleSeatDelegateFallback); + Event_SetPlayerDimensionChangeDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 12559962844846581925UL, Event_SetPlayerDimensionChangeDelegateFallback); Event_SetPlayerDisconnectDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 11526105887646755055UL, Event_SetPlayerDisconnectDelegateFallback); Event_SetPlayerEnterVehicleDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 16259534399403863387UL, Event_SetPlayerEnterVehicleDelegateFallback); Event_SetPlayerLeaveVehicleDelegate = (delegate* unmanaged[Cdecl]) GetUnmanagedPtr(funcTable, 10354256863799375649UL, Event_SetPlayerLeaveVehicleDelegateFallback); diff --git a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs index 40c34383..1a55c66a 100644 --- a/api/AltV.Net.CApi/Libraries/ServerLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/ServerLibrary.cs @@ -490,7 +490,7 @@ public unsafe interface IServerLibrary public unsafe class ServerLibrary : IServerLibrary { - public readonly uint Methods = 1811; + public readonly uint Methods = 1812; public delegate* unmanaged[Cdecl] BaseObject_DeleteSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetMultipleSyncedMetaData { get; } public delegate* unmanaged[Cdecl] BaseObject_SetSyncedMetaData { get; } @@ -1925,7 +1925,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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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); diff --git a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs index c503b112..31b99f13 100644 --- a/api/AltV.Net.CApi/Libraries/SharedLibrary.cs +++ b/api/AltV.Net.CApi/Libraries/SharedLibrary.cs @@ -426,7 +426,7 @@ public unsafe interface ISharedLibrary public unsafe class SharedLibrary : ISharedLibrary { - public readonly uint Methods = 1811; + public readonly uint Methods = 1812; public delegate* unmanaged[Cdecl] Audio_GetID { get; } public delegate* unmanaged[Cdecl] AudioAttachedOutput_GetID { get; } public delegate* unmanaged[Cdecl] AudioFilter_GetID { get; } @@ -1669,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 != 2737407539021183714UL) Outdated = true; + else if (capiHash == IntPtr.Zero || *(ulong*)capiHash != 13628227844990757996UL) 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); diff --git a/api/AltV.Net.Client/Alt.Events.cs b/api/AltV.Net.Client/Alt.Events.cs index 299425df..24253df1 100644 --- a/api/AltV.Net.Client/Alt.Events.cs +++ b/api/AltV.Net.Client/Alt.Events.cs @@ -182,6 +182,12 @@ public static event PlayerChangeInteriorDelegate OnPlayerChangeInterior remove => ((Core)CoreImpl).PlayerChangeInteriorEventHandler.Remove(value); } + public static event PlayerDimensionChangeDelegate OnPlayerDimensionChange + { + add => ((Core)CoreImpl).PlayerDimensionChangeEventHandler.Add(value); + remove => ((Core)CoreImpl).PlayerDimensionChangeEventHandler.Remove(value); + } + public static event WeaponDamageDelegate OnWeaponDamage { add => ((Core)CoreImpl).WeaponDamageEventHandler.Add(value); diff --git a/api/AltV.Net.Client/Core.Events.cs b/api/AltV.Net.Client/Core.Events.cs index cb5c232d..6b92f782 100644 --- a/api/AltV.Net.Client/Core.Events.cs +++ b/api/AltV.Net.Client/Core.Events.cs @@ -114,6 +114,9 @@ public virtual IEnumerable GetRegisteredServerEvents() internal readonly IEventHandler PlayerChangeInteriorEventHandler = new HashSetEventHandler(EventType.PLAYER_CHANGE_INTERIOR_EVENT); + internal readonly IEventHandler PlayerDimensionChangeEventHandler = + new HashSetEventHandler(EventType.PLAYER_DIMENSION_CHANGE); + internal readonly IEventHandler PlayerWeaponShootEventHandler = new HashSetEventHandler(EventType.PLAYER_WEAPON_SHOOT_EVENT); @@ -368,6 +371,18 @@ public void OnPlayerChangeInterior(IntPtr playerPtr, BaseObjectType type, uint o PlayerChangeInteriorEventHandler.GetEvents().ForEachCatching(fn => fn(player, oldIntLoc, newIntLoc), $"event {nameof(OnPlayerChangeInterior)}"); } + public void OnPlayerDimensionChange(IntPtr playerPtr, BaseObjectType type, int oldDim, int newDim) + { + var player = (IPlayer)PoolManager.Get(playerPtr, type); + if (player == null) + { + Alt.LogWarning("OnPlayerDimensionChange: Invalid player " + playerPtr); + return; + } + + PlayerDimensionChangeEventHandler.GetEvents().ForEachCatching(fn => fn(player, oldDim, newDim), $"event {nameof(OnPlayerDimensionChange)}"); + } + public void OnPlayerWeaponShoot(uint weapon, ushort totalAmmo, ushort ammoInClip) { PlayerWeaponShootEventHandler.GetEvents().ForEachCatching(fn => fn(weapon, totalAmmo, ammoInClip), $"event {nameof(OnPlayerWeaponShoot)}"); diff --git a/api/AltV.Net.Client/Events/Events.cs b/api/AltV.Net.Client/Events/Events.cs index 66968dc4..23787f75 100644 --- a/api/AltV.Net.Client/Events/Events.cs +++ b/api/AltV.Net.Client/Events/Events.cs @@ -17,6 +17,7 @@ namespace AltV.Net.Client.Events public delegate void PlayerChangeVehicleSeatDelegate(IVehicle vehicle, byte oldSeat, byte newSeat); public delegate void PlayerChangeAnimationDelegate(IPlayer player, uint oldDict, uint newDict, uint oldName, uint newName); public delegate void PlayerChangeInteriorDelegate(IPlayer player, uint oldIntLoc, uint newIntLoc); + public delegate void PlayerDimensionChangeDelegate(IPlayer player, int oldDim, int newDim); public delegate void PlayerWeaponShootDelegate(uint weapon, ushort totalAmmo, ushort ammoInClip); public delegate void PlayerWeaponChangeDelegate(uint oldWeapon, uint newWeapon); public delegate void PlayerLeaveVehicleDelegate(IVehicle vehicle, byte seat); diff --git a/api/AltV.Net.Client/ModuleWrapper.cs b/api/AltV.Net.Client/ModuleWrapper.cs index 0279d30d..74d9d6fd 100644 --- a/api/AltV.Net.Client/ModuleWrapper.cs +++ b/api/AltV.Net.Client/ModuleWrapper.cs @@ -338,6 +338,11 @@ public static void OnPlayerChangeInterior(IntPtr player, BaseObjectType type, ui _core.OnPlayerChangeInterior(player, type, oldIntLoc, newIntLoc); } + public static void OnPlayerDimensionChange(IntPtr player, BaseObjectType type, int oldDim, int newDim) + { + _core.OnPlayerDimensionChange(player, type, oldDim, newDim); + } + public static void OnPlayerWeaponShoot(uint weapon, ushort totalAmmo, ushort ammoInClip) { _core.OnPlayerWeaponShoot(weapon, totalAmmo, ammoInClip); diff --git a/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs b/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs index dbfbfd5e..fd8f9dd1 100644 --- a/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs +++ b/api/AltV.Net.Client/Runtime/CSharpResourceImpl.cs @@ -1,5 +1,6 @@ using System.Runtime.InteropServices; using AltV.Net.CApi.ClientEvents; +using AltV.Net.Native; using AltV.Net.Shared; namespace AltV.Net.Client.Runtime @@ -216,6 +217,10 @@ internal void SetDelegates() ScriptRPCAnswerModuleDelegate onScriptRPCAnswer = ModuleWrapper.OnScriptRPCAnswer; handles.AddFirst(GCHandle.Alloc(onScriptRPCAnswer)); core.Library.Client.Event_SetScriptRPCAnswerDelegate(this.NativePointer, onScriptRPCAnswer); + + PlayerDimensionChangeModuleDelegate onPlayerDimensionChange = ModuleWrapper.OnPlayerDimensionChange; + handles.AddFirst(GCHandle.Alloc(onPlayerDimensionChange)); + core.Library.Client.Event_SetPlayerDimensionChangeDelegate(this.NativePointer, onPlayerDimensionChange); } } diff --git a/runtime b/runtime index 96c808e0..f4eb1db7 160000 --- a/runtime +++ b/runtime @@ -1 +1 @@ -Subproject commit 96c808e0adc34c5bdf8b17f36aa26f1592022bc8 +Subproject commit f4eb1db7fed95900be7ebefc882a790689ae1608