Skip to content

Commit

Permalink
ALTV-643 - add IsInWater getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Jan 14, 2025
1 parent af460e3 commit f31862c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
12 changes: 12 additions & 0 deletions api/AltV.Net.Async/Elements/Entities/AsyncPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,18 @@ public bool IsParachuting
}
}

public bool IsInWater
{
get
{
lock (Player)
{
if (!AsyncContext.CheckIfExistsOrCachedNullable(Player)) return default;
return Player.IsInWater;
}
}
}

public void SetWeaponTintIndex(uint weapon, byte tintIndex)
{
lock (Player)
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.CApi/Libraries/ClientLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ public unsafe interface IClientLibrary

public unsafe class ClientLibrary : IClientLibrary
{
public readonly uint Methods = 1812;
public readonly uint Methods = 1813;
public delegate* unmanaged[Cdecl]<nint, nint, void> Audio_AddOutput { get; }
public delegate* unmanaged[Cdecl]<nint, nint> Audio_GetBaseObject { get; }
public delegate* unmanaged[Cdecl]<nint, double> Audio_GetCurrentTime { get; }
Expand Down
2 changes: 1 addition & 1 deletion api/AltV.Net.CApi/Libraries/ServerLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public unsafe interface IServerLibrary

public unsafe class ServerLibrary : IServerLibrary
{
public readonly uint Methods = 1812;
public readonly uint Methods = 1813;
public delegate* unmanaged[Cdecl]<nint, nint, void> BaseObject_DeleteSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint[], nint[], ulong, void> BaseObject_SetMultipleSyncedMetaData { get; }
public delegate* unmanaged[Cdecl]<nint, nint, nint, void> BaseObject_SetSyncedMetaData { get; }
Expand Down
7 changes: 6 additions & 1 deletion api/AltV.Net.CApi/Libraries/SharedLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public unsafe interface ISharedLibrary
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInMelee { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInRagdoll { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInWater { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsJumping { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsLeavingVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsOnLadder { get; }
Expand Down Expand Up @@ -426,7 +427,7 @@ public unsafe interface ISharedLibrary

public unsafe class SharedLibrary : ISharedLibrary
{
public readonly uint Methods = 1812;
public readonly uint Methods = 1813;
public delegate* unmanaged[Cdecl]<nint, uint> Audio_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioAttachedOutput_GetID { get; }
public delegate* unmanaged[Cdecl]<nint, uint> AudioFilter_GetID { get; }
Expand Down Expand Up @@ -764,6 +765,7 @@ public unsafe class SharedLibrary : ISharedLibrary
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInMelee { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInRagdoll { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsInWater { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsJumping { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsLeavingVehicle { get; }
public delegate* unmanaged[Cdecl]<nint, byte> Player_IsOnLadder { get; }
Expand Down Expand Up @@ -1512,6 +1514,8 @@ public unsafe class SharedLibrary : ISharedLibrary
private static byte Player_IsInRagdollFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_IsInRagdoll", "Player_IsInRagdoll SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_IsInVehicleDelegate(nint _player);
private static byte Player_IsInVehicleFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_IsInVehicle", "Player_IsInVehicle SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_IsInWaterDelegate(nint _player);
private static byte Player_IsInWaterFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_IsInWater", "Player_IsInWater SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_IsJumpingDelegate(nint _player);
private static byte Player_IsJumpingFallback(nint _player) => throw new Exceptions.OutdatedSdkException("Player_IsJumping", "Player_IsJumping SDK method is outdated. Please update your module nuget");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate byte Player_IsLeavingVehicleDelegate(nint _player);
Expand Down Expand Up @@ -2007,6 +2011,7 @@ public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
Player_IsInMelee = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsInMeleeDelegate>(funcTable, 9656359974229471670UL, Player_IsInMeleeFallback);
Player_IsInRagdoll = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsInRagdollDelegate>(funcTable, 13866510163503569909UL, Player_IsInRagdollFallback);
Player_IsInVehicle = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsInVehicleDelegate>(funcTable, 3966288765716642074UL, Player_IsInVehicleFallback);
Player_IsInWater = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsInWaterDelegate>(funcTable, 12569204323936167181UL, Player_IsInWaterFallback);
Player_IsJumping = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsJumpingDelegate>(funcTable, 8318404148061760703UL, Player_IsJumpingFallback);
Player_IsLeavingVehicle = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsLeavingVehicleDelegate>(funcTable, 7801590821162478013UL, Player_IsLeavingVehicleFallback);
Player_IsOnLadder = (delegate* unmanaged[Cdecl]<nint, byte>) GetUnmanagedPtr<Player_IsOnLadderDelegate>(funcTable, 3159353707403506220UL, Player_IsOnLadderFallback);
Expand Down
12 changes: 12 additions & 0 deletions api/AltV.Net.Client/Elements/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ public bool IsParachuting
}
}

public bool IsInWater
{
get
{
unsafe
{
CheckIfEntityExistsOrCached();
return this.Core.Library.Shared.Player_IsInWater(this.PlayerNativePointer) == 1;
}
}
}

ISharedEntity ISharedPlayer.EntityAimingAt => EntityAimingAt!;

public bool IsFlashlightActive
Expand Down
2 changes: 2 additions & 0 deletions api/AltV.Net.Shared/Elements/Entities/ISharedPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,7 @@ public interface ISharedPlayer : ISharedEntity
void GetCurrentWeaponComponents(out uint[] weaponComponents);

bool IsParachuting { get; }

bool IsInWater { get; }
}
}
12 changes: 12 additions & 0 deletions api/AltV.Net/Elements/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,5 +1753,17 @@ public bool IsParachuting
}
}
}

public bool IsInWater
{
get
{
unsafe
{
CheckIfEntityExistsOrCached();
return this.Core.Library.Shared.Player_IsInWater(this.PlayerNativePointer) == 1;
}
}
}
}
}
2 changes: 1 addition & 1 deletion runtime

0 comments on commit f31862c

Please sign in to comment.