using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace Trigger { class Trigger { const int dwLocalPlayer = 0x00A77D3C; //Local Player const int dwTeamNumber = 0x000000F0; //Team number offset, Either T or CT. const int dwCrosshairID = 0x00002410; // Crosshair offset const int dwEntityList = 0x04A19DA4; // Entity List offset const int dwEntitySize = 0x10; // Size of Entity List const int dwHealth = 0x000000FC; // Health offset const int dwActiveWeapon = 0x000012C0; // Active weapon offset (Weapon that's in hands.) const int dwWeaponID = 0x00001690; // Offset of weapon ID (See Weapon Names Enum) public static int dwDelay = 75; [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(UInt16 virtualKeyCode); public enum WindowsVirtualKey { VK_XBUTTON1 = 0x05, // Extended mouse button 1 VK_XBUTTON2 = 0x06, // Extended mouse button 2 } public enum WeaponNames : int { Deagle = 1, DualBerettas = 2, FiveSeven = 3, Glock18 = 4, AK47 = 7, AUG = 8, AWP = 9, Famas = 10, G35G1 = 11, //T-Side Auto Galil = 13, M249 = 14, M4A4 = 16, Mac10 = 17, P90 = 19, UMP45 = 24, XM1014 = 25, PPBizon = 26, Mag7 = 27, Negev = 28, SawedOff = 29, Tec9 = 30, Zues = 31, P2000 = 32, Mp7 = 33, Mp9 = 34, Nova = 35, P250 = 36, Scar20 = 38, // CT-Side Auto SG553 = 39, SSG08 = 40, CTKnife = 42, //default Flasbang = 43, HEGrenade = 44, Smoke = 45, Molotov = 46, Decoy = 47, Incendiary = 48, C4 = 49, TKnife = 59,// Default M4A1 = 60, USP = 61, CZ75 = 63, Bayonet = 500, FlipKnife = 505, GutKnife = 506, Karambit = 507, M9Bayo = 508, Huntsman = 509, Falchion = 512, Butterfly = 515, }; public Trigger() { Memory mem = new Memory("csgo"); // Attach to CSGO mem.StartProcess(); // Start reading memory while (true) { int cDLL = mem.DllImageAddress("client.dll"); // Load modules in Client.dll int localPlayer = mem.ReadInt(cDLL + dwLocalPlayer); // Read Client.dll + dwLocalPlayer offset -- Get's the base LocalPlayer, where all information is stored that we need. int localPlayerHealth = mem.ReadInt(localPlayer + dwHealth); // Read localPlayer + dwHealth offset -- Gets the health of players. int localTeam = mem.ReadInt(localPlayer + dwTeamNumber); // read localPlayer + dwTeamNumber offset -- Gets the team number of players. int crosshairID = mem.ReadInt(localPlayer + dwCrosshairID); // read localPlayer + dwCrosshairID -- Gets the crosshairID int enemyInCrosshair = mem.ReadInt(cDLL + dwEntityList + ((crosshairID - 1) * dwEntitySize)); // read client.dll + dwEntityList + crosshairID - 1 * dwEntityList -- Determins if anyone is within the crosshair int enemyInCrosshairHealth = mem.ReadInt(enemyInCrosshair + dwHealth); // read enemyInCrosshair + dwHealth -- Checks to players health within the crosshair. int enemyCrosshairTeam = mem.ReadInt(enemyInCrosshair + dwTeamNumber); // read nemyinCrosshair + dwTeamNumber -- Checkes the players teamnumber. //Credits : reidenz @ Unknown // Translated C++ to C#. int wLocalPlayer = mem.ReadInt(cDLL + dwLocalPlayer); // read client.dll + dwLocalPlayer int dwWeaponIndex = mem.ReadInt(wLocalPlayer + dwActiveWeapon) & 0xFFF; // read wLocalPlayer + dwActiveweapon & 0xFFF. int dwWeaponEntity = mem.ReadInt((cDLL + dwEntityList + dwWeaponIndex * 0x10) - 0x10); // read client.dll + dwWeaponIndex * 0x10 - 0x10 // gets the weapon entity position. int weaponID = mem.ReadInt(dwWeaponEntity + dwWeaponID); // Reads the entity position and weapon ID. if (localPlayer != enemyCrosshairTeam && enemyInCrosshairHealth > 0 && enemyCrosshairTeam != localTeam) // If localPlayer is not enemyCrosshairTeam && enemyincrosshairhealth is greater than 0, and enemyincrosshair is not on the same team { //Acts as a boolean function, isn't triggered once a loop, but seems to be triggered and stays true on button press. if (GetAsyncKeyState((ushort)WindowsVirtualKey.VK_XBUTTON2) != 0 || GetAsyncKeyState((ushort)WindowsVirtualKey.VK_XBUTTON1) != 0) // Determine if hotkey was pressed. { //Check for knife/Grenade/Etc. if (weaponID != (int)WeaponNames.Bayonet || weaponID != (int)WeaponNames.Butterfly || weaponID != (int)WeaponNames.C4 || weaponID != (int)WeaponNames.CTKnife || weaponID != (int)WeaponNames.Decoy || weaponID != (int)WeaponNames.Falchion || weaponID != (int)WeaponNames.Flasbang || weaponID != (int)WeaponNames.FlipKnife || weaponID != (int)WeaponNames.GutKnife || weaponID != (int)WeaponNames.HEGrenade || weaponID != (int)WeaponNames.Huntsman || weaponID != (int)WeaponNames.Incendiary || weaponID != (int)WeaponNames.Karambit || weaponID != (int)WeaponNames.M9Bayo || weaponID != (int)WeaponNames.Molotov || weaponID != (int)WeaponNames.Smoke || weaponID != (int)WeaponNames.TKnife || weaponID != (int)WeaponNames.Zues) { System.Threading.Thread.Sleep(dwDelay); // Delay mouse_event(0x002, 0, 0, 0, (System.UIntPtr)0); // Click mouse_event(0x004, 0, 0, 0, (System.UIntPtr)0); // Release } } } } } } }