Read entity position directly from memory

This commit is contained in:
Sardelka
2022-07-23 23:45:20 +08:00
parent e52135c343
commit e072c2aee8
9 changed files with 59 additions and 16 deletions

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GTA.Math;
using GTA;
namespace RageCoop.Client
{
internal static class Memory
{
#region OFFSET-CONST
public const int PositionOffset = 144;
#endregion
public static Vector3 ReadPosition(this Entity e)
{
return ReadVector3(e.MemoryAddress+PositionOffset);
}
public unsafe static Vector3 ReadVector3(IntPtr address)
{
float* ptr = (float*)address.ToPointer();
return new Vector3()
{
X=*ptr,
Y=ptr[1],
Z=ptr[2]
};
}
}
}