How to make this code efficient?
I followed some guy's tutorial, and I don't plan on actually using this, but I would like to know why this eats up so much CPU, and sucks at the same time.
Code:
static string process = "csgo";
static int aLocalPlayer = 0xA9D0DC;
static int oEntityList = 0x4A79EC4;
static int oCrosshairID = 0xB2A4;
static int oTeam = 0xF0;
static int oHealth = 0xFC;
static int oAttack = 0x2EBC23C;
static int oEntityLoopDistance = 0x10;
static int bClient;
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int GetAsyncKeyState(int vKey);
static void Main(string[] args)
{
VAMemory vam = new VAMemory(process);
if (GetModuleAddy())
{
int fAttack = bClient + oAttack;
while (true)
{
Console.Clear();
Console.WriteLine("Nothing...");
int address = bClient + aLocalPlayer;
int LocalPlayer = vam.ReadInt32((IntPtr)address);
address = LocalPlayer + oTeam;
int myTeam = vam.ReadInt32((IntPtr)address);
address = LocalPlayer + oCrosshairID;
int PlayerInCross = vam.ReadInt32((IntPtr)address);
if(PlayerInCross > 0 && PlayerInCross < 65)
{
address = bClient + oEntityList + (PlayerInCross - 1) * oEntityLoopDistance;
int PtrToPIC = vam.ReadInt32((IntPtr)address);
address = PtrToPIC + oHealth;
int PICHealth = vam.ReadInt32((IntPtr)address);
address = PtrToPIC + oTeam;
int PICteam = vam.ReadInt32((IntPtr)address);
if((PICteam != myTeam) && (PICteam > 1) && (PICHealth > 0))
{
Console.Clear();
Console.WriteLine("Shooting");
vam.WriteInt32((IntPtr)fAttack, 1);
Thread.Sleep(1);
vam.WriteInt32((IntPtr)fAttack, 4);
}
}
Thread.Sleep(10);
}
}
}