Skip to content

Commit 0b586a8

Browse files
committed
add set pos/dim for client
1 parent 5057ec9 commit 0b586a8

File tree

7 files changed

+43
-20
lines changed

7 files changed

+43
-20
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ public unsafe interface IServerLibrary
407407
public delegate* unmanaged[Cdecl]<nint, int, void> VoiceChannel_SetPriority { get; }
408408
public delegate* unmanaged[Cdecl]<nint, nint, void> VoiceChannel_UnmutePlayer { get; }
409409
public delegate* unmanaged[Cdecl]<nint, float*, float*, float*, int*, void> WorldObject_GetPositionCoords { get; }
410-
public delegate* unmanaged[Cdecl]<nint, int, void> WorldObject_SetDimension { get; }
411410
}
412411

413412
public unsafe class ServerLibrary : IServerLibrary
@@ -810,7 +809,6 @@ public unsafe class ServerLibrary : IServerLibrary
810809
public delegate* unmanaged[Cdecl]<nint, int, void> VoiceChannel_SetPriority { get; }
811810
public delegate* unmanaged[Cdecl]<nint, nint, void> VoiceChannel_UnmutePlayer { get; }
812811
public delegate* unmanaged[Cdecl]<nint, float*, float*, float*, int*, void> WorldObject_GetPositionCoords { get; }
813-
public delegate* unmanaged[Cdecl]<nint, int, void> WorldObject_SetDimension { get; }
814812
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void BaseObject_DeleteSyncedMetaDataDelegate(nint _baseObject, nint _key);
815813
private static void BaseObject_DeleteSyncedMetaDataFallback(nint _baseObject, nint _key) => throw new Exceptions.OutdatedSdkException("BaseObject_DeleteSyncedMetaData", "BaseObject_DeleteSyncedMetaData SDK method is outdated. Please update your module nuget");
816814
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void BaseObject_SetSyncedMetaDataDelegate(nint _baseObject, nint _key, nint _val);
@@ -1605,8 +1603,6 @@ public unsafe class ServerLibrary : IServerLibrary
16051603
private static void VoiceChannel_UnmutePlayerFallback(nint _channel, nint _player) => throw new Exceptions.OutdatedSdkException("VoiceChannel_UnmutePlayer", "VoiceChannel_UnmutePlayer SDK method is outdated. Please update your module nuget");
16061604
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WorldObject_GetPositionCoordsDelegate(nint _worldObject, float* _position_x, float* _position_y, float* _position_z, int* _dimension);
16071605
private static void WorldObject_GetPositionCoordsFallback(nint _worldObject, float* _position_x, float* _position_y, float* _position_z, int* _dimension) => throw new Exceptions.OutdatedSdkException("WorldObject_GetPositionCoords", "WorldObject_GetPositionCoords SDK method is outdated. Please update your module nuget");
1608-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WorldObject_SetDimensionDelegate(nint _worldObject, int _dimension);
1609-
private static void WorldObject_SetDimensionFallback(nint _worldObject, int _dimension) => throw new Exceptions.OutdatedSdkException("WorldObject_SetDimension", "WorldObject_SetDimension SDK method is outdated. Please update your module nuget");
16101606
public bool Outdated { get; private set; }
16111607
private IntPtr GetUnmanagedPtr<T>(IDictionary<ulong, IntPtr> funcTable, ulong hash, T fn) where T : Delegate {
16121608
if (funcTable.TryGetValue(hash, out var ptr)) return ptr;
@@ -2014,7 +2010,6 @@ public ServerLibrary(Dictionary<ulong, IntPtr> funcTable)
20142010
VoiceChannel_SetPriority = (delegate* unmanaged[Cdecl]<nint, int, void>) GetUnmanagedPtr<VoiceChannel_SetPriorityDelegate>(funcTable, 11160223830254443614UL, VoiceChannel_SetPriorityFallback);
20152011
VoiceChannel_UnmutePlayer = (delegate* unmanaged[Cdecl]<nint, nint, void>) GetUnmanagedPtr<VoiceChannel_UnmutePlayerDelegate>(funcTable, 10269140636860300589UL, VoiceChannel_UnmutePlayerFallback);
20162012
WorldObject_GetPositionCoords = (delegate* unmanaged[Cdecl]<nint, float*, float*, float*, int*, void>) GetUnmanagedPtr<WorldObject_GetPositionCoordsDelegate>(funcTable, 16135129168754632706UL, WorldObject_GetPositionCoordsFallback);
2017-
WorldObject_SetDimension = (delegate* unmanaged[Cdecl]<nint, int, void>) GetUnmanagedPtr<WorldObject_SetDimensionDelegate>(funcTable, 8281427375806201830UL, WorldObject_SetDimensionFallback);
20182013
}
20192014
}
20202015
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ public unsafe interface ISharedLibrary
344344
public delegate* unmanaged[Cdecl]<nint, nint> WorldObject_GetBaseObject { get; }
345345
public delegate* unmanaged[Cdecl]<nint, int> WorldObject_GetDimension { get; }
346346
public delegate* unmanaged[Cdecl]<nint, Vector3*, void> WorldObject_GetPosition { get; }
347+
public delegate* unmanaged[Cdecl]<nint, int, void> WorldObject_SetDimension { get; }
347348
public delegate* unmanaged[Cdecl]<nint, Vector3, void> WorldObject_SetPosition { get; }
348349
}
349350

@@ -684,6 +685,7 @@ public unsafe class SharedLibrary : ISharedLibrary
684685
public delegate* unmanaged[Cdecl]<nint, nint> WorldObject_GetBaseObject { get; }
685686
public delegate* unmanaged[Cdecl]<nint, int> WorldObject_GetDimension { get; }
686687
public delegate* unmanaged[Cdecl]<nint, Vector3*, void> WorldObject_GetPosition { get; }
688+
public delegate* unmanaged[Cdecl]<nint, int, void> WorldObject_SetDimension { get; }
687689
public delegate* unmanaged[Cdecl]<nint, Vector3, void> WorldObject_SetPosition { get; }
688690
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate uint Audio_GetIDDelegate(nint _audio);
689691
private static uint Audio_GetIDFallback(nint _audio) => throw new Exceptions.OutdatedSdkException("Audio_GetID", "Audio_GetID SDK method is outdated. Please update your module nuget");
@@ -1353,6 +1355,8 @@ public unsafe class SharedLibrary : ISharedLibrary
13531355
private static int WorldObject_GetDimensionFallback(nint _worldObject) => throw new Exceptions.OutdatedSdkException("WorldObject_GetDimension", "WorldObject_GetDimension SDK method is outdated. Please update your module nuget");
13541356
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WorldObject_GetPositionDelegate(nint _worldObject, Vector3* _position);
13551357
private static void WorldObject_GetPositionFallback(nint _worldObject, Vector3* _position) => throw new Exceptions.OutdatedSdkException("WorldObject_GetPosition", "WorldObject_GetPosition SDK method is outdated. Please update your module nuget");
1358+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WorldObject_SetDimensionDelegate(nint _worldObject, int _dimension);
1359+
private static void WorldObject_SetDimensionFallback(nint _worldObject, int _dimension) => throw new Exceptions.OutdatedSdkException("WorldObject_SetDimension", "WorldObject_SetDimension SDK method is outdated. Please update your module nuget");
13561360
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void WorldObject_SetPositionDelegate(nint _worldObject, Vector3 _pos);
13571361
private static void WorldObject_SetPositionFallback(nint _worldObject, Vector3 _pos) => throw new Exceptions.OutdatedSdkException("WorldObject_SetPosition", "WorldObject_SetPosition SDK method is outdated. Please update your module nuget");
13581362
public bool Outdated { get; private set; }
@@ -1699,6 +1703,7 @@ public SharedLibrary(Dictionary<ulong, IntPtr> funcTable)
16991703
WorldObject_GetBaseObject = (delegate* unmanaged[Cdecl]<nint, nint>) GetUnmanagedPtr<WorldObject_GetBaseObjectDelegate>(funcTable, 7682733547279772474UL, WorldObject_GetBaseObjectFallback);
17001704
WorldObject_GetDimension = (delegate* unmanaged[Cdecl]<nint, int>) GetUnmanagedPtr<WorldObject_GetDimensionDelegate>(funcTable, 17276300057698662707UL, WorldObject_GetDimensionFallback);
17011705
WorldObject_GetPosition = (delegate* unmanaged[Cdecl]<nint, Vector3*, void>) GetUnmanagedPtr<WorldObject_GetPositionDelegate>(funcTable, 13069539607851095701UL, WorldObject_GetPositionFallback);
1706+
WorldObject_SetDimension = (delegate* unmanaged[Cdecl]<nint, int, void>) GetUnmanagedPtr<WorldObject_SetDimensionDelegate>(funcTable, 8281427375806201830UL, WorldObject_SetDimensionFallback);
17021707
WorldObject_SetPosition = (delegate* unmanaged[Cdecl]<nint, Vector3, void>) GetUnmanagedPtr<WorldObject_SetPositionDelegate>(funcTable, 15027192667173077188UL, WorldObject_SetPositionFallback);
17031708
}
17041709
}

api/AltV.Net.Client/Elements/Entities/WorldObject.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ public Position Position
3636
return position;
3737
}
3838
}
39+
set
40+
{
41+
unsafe
42+
{
43+
CheckIfEntityExists();
44+
this.Core.Library.Shared.WorldObject_SetPosition(this.WorldObjectNativePointer, value);
45+
}
46+
}
47+
}
48+
49+
public int Dimension
50+
{
51+
get
52+
{
53+
unsafe
54+
{
55+
CheckIfEntityExistsOrCached();
56+
return this.Core.Library.Shared.WorldObject_GetDimension(this.WorldObjectNativePointer);
57+
}
58+
}
59+
set
60+
{
61+
unsafe
62+
{
63+
CheckIfEntityExists();
64+
this.Core.Library.Shared.WorldObject_SetDimension(this.WorldObjectNativePointer, value);
65+
}
66+
}
3967
}
4068

4169
public override void CheckIfEntityExists()

api/AltV.Net.Shared/Elements/Entities/ISharedWorldObject.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ namespace AltV.Net.Shared.Elements.Entities
77
public interface ISharedWorldObject : ISharedBaseObject
88
{
99
IntPtr WorldObjectNativePointer { get; }
10-
10+
1111
/// <summary>
1212
/// Get or set position of the entity.
1313
/// </summary>
1414
/// <exception cref="EntityRemovedException">This entity was deleted before</exception>
15-
Position Position { get; }
15+
Position Position { get; set; }
16+
17+
/// <summary>
18+
/// Get or set dimension of the entity.
19+
/// </summary>
20+
/// <exception cref="EntityRemovedException">This entity was deleted before</exception>
21+
int Dimension { get; set; }
1622
}
1723
}

api/AltV.Net/Elements/Entities/IWorldObject.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ namespace AltV.Net.Elements.Entities
66
{
77
public interface IWorldObject : ISharedWorldObject, IBaseObject
88
{
9-
/// <summary>
10-
/// Get or set position of the entity.
11-
/// </summary>
12-
/// <exception cref="EntityRemovedException">This entity was deleted before</exception>
13-
new Position Position { get; set; }
14-
15-
/// <summary>
16-
/// Get or set dimension of the entity.
17-
/// </summary>
18-
/// <exception cref="EntityRemovedException">This entity was deleted before</exception>
19-
int Dimension { get; set; }
209
}
2110

2211
public static class WorldObjectExtensions

api/AltV.Net/Elements/Entities/WorldObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public int Dimension
5555
CheckIfEntityExists();
5656
unsafe
5757
{
58-
Core.Library.Server.WorldObject_SetDimension(WorldObjectNativePointer, value);
58+
Core.Library.Shared.WorldObject_SetDimension(WorldObjectNativePointer, value);
5959
}
6060
}
6161
}

runtime

0 commit comments

Comments
 (0)