/
PlayerHelper.cs
107 lines (88 loc) · 2.54 KB
/
PlayerHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sharpest_Internal.Helpers;
namespace Sharpest_Internal.SDK.Entities
{
public enum EntityFlags
{
FL_ONGROUND = (1 << 0),
FL_DUCKING = (1 << 1),
FL_WATERJUMP = (1 << 2),
FL_ONTRAIN = (1 << 3),
FL_INRAIN = (1 << 4),
FL_FROZEN = (1 << 5),
FL_ATCONTROLS = (1 << 6),
FL_CLIENT = (1 << 7),
FL_FAKECLIENT = (1 << 8),
MAX_ENTITYFLAGS
}
public unsafe class PlayerHelper // I would do C_BasePlayer pointer but .NET says I can't use "this" as a variable.
{
static IntPtr internalPointer;
public PlayerHelper(IntPtr basePtr)
{
internalPointer = basePtr;
}
private int GetIntNetvar(Int32 offs)
{
return *((int*)(internalPointer + offs));
}
private bool GetBooleanNetvar(Int32 offs)
{
return *((bool*)(internalPointer + offs));
}
private QAngle GetAngleNetvar(Int32 offs)
{
return *((QAngle*)(internalPointer + offs));
}
private Vector GetVectorNetvar(Int32 offs)
{
return *((Vector*)(internalPointer + offs));
}
public int GetHealth()
{
return GetIntNetvar(Offsets.netvars.m_iHealth);
}
public bool IsAlive()
{
return GetIntNetvar(Offsets.netvars.m_lifeState) == 0;
}
public bool IsValid()
{
return internalPointer != IntPtr.Zero;
}
public QAngle GetPunchAngles()
{
return GetAngleNetvar(Offsets.netvars.m_aimPunchAngle);
}
public Vector GetOrigin()
{
return GetVectorNetvar(Offsets.netvars.m_vecOrigin);
}
public Vector GetViewOffset()
{
return GetVectorNetvar(Offsets.netvars.m_vecViewOffset);
}
public Vector GetEyePos()
{
return GetOrigin().Add(GetViewOffset());
}
public int GetTeam()
{
return GetIntNetvar(Offsets.netvars.m_iTeamNum);
}
public bool IsEnemy()
{
if (!Utils.GetLocalPlayer().IsValid())
return true;
return GetTeam() != Utils.GetLocalPlayer().GetTeam();
}
public EntityFlags GetFlags()
{
return (EntityFlags)GetIntNetvar(Offsets.netvars.m_fFlags);
}
}
}