Dear community,
today I'd like to release a SIMPLE triggerbot made in C#, uses CrosshairID and mouse events. Maybe someone would make a use from it. Sorry for my bad coding habits, I don't really like C#, it was one-time project made about a year ago.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SimpleTriggerbot
{
class Program
{
[DllImport("kernel32.dll")]
public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
[DllImport("user32.dll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(int vKey);
static int BaseAdressClientDLL = 0;
static int pHandle = 0;
static void Main(string[] args)
{
bool FoundCSGO = false;
while (true)
{
if (FoundCSGO == false)
{
foreach (Process Proc in Process.GetProcesses())
{
if (Proc.ProcessName.Equals("csgo"))
{
pHandle = OpenProcess(2035711, false, Proc.Id);
foreach (ProcessModule Module in Proc.Modules)
{
if (Module.ModuleName.Equals("client.dll"))
{
BaseAdressClientDLL = (int)Module.BaseAddress;
FoundCSGO = true;
}
}
}
}
}
else
{
if (GetAsyncKeyState(0x20) != 0)
{
int LocalPlayer = readInt(BaseAdressClientDLL + 0xA6E444);
int CrosshairID = readInt(LocalPlayer + 0xA940);
if (CrosshairID > 0 && CrosshairID <= 64)
{
int Enemy = readInt(BaseAdressClientDLL + 0x4A5C9C4 + ((CrosshairID - 1) * 0x10));
int PlayerTeam = readInt(LocalPlayer + 0xF0);
int EnemyTeam = readInt(Enemy + 0xF0);
int EnemyHealth = readInt(Enemy + 0xFC);
if (EnemyHealth > 0 && PlayerTeam != EnemyTeam)
{
mouse_event(0x002, 0, 0, 0, (System.UIntPtr)0);
mouse_event(0x004, 0, 0, 0, (System.UIntPtr)0);
}
}
}
}
System.Threading.Thread.Sleep(5);
}
}
public static int readInt(int address)
{
byte[] buffer = new byte[4];
ReadProcessMemory(pHandle, address, buffer, 4, 0);
return BitConverter.ToInt32(buffer, 0);
}
}
}