Solved Aimbot - Aim at the Nearest Player

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

fx705HUJX0

Jr.Coder
Dank Tier Donator
Nobleman
Mar 24, 2016
65
838
0
Hello Guys,

Some while ago i already made a Thread about the Problem but i couldnt figure it out.
My Problem: How can make the Aimbot to just aim at the nearest Player? Because right now its just Looping through the Entity List and picking one after one.

Here is my Full Source:
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace AcClient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static string process = "ac_client";
        public static VAMemory vam = new VAMemory(process);

        public static int Base = 0x509B74;
        public static int oX = 0x4;
        public static int oY = 0x8;
        public static int oZ = 0xC;
        public static int ovAngleX = 0x40;
        public static int ovAngleY = 0x44;
        public static int oHealth = 0xF8;
        public static int oEntity = 0x510D90;
        public static float AngleDToDegree = 57.29578f;
        public static float PI = 3.14159265359f;
        public static int TeamOffset1 = 0x204;
        public static int TeamOffset2 = 0x32C;
        public int offsetAmmo = 0x150;
        public int offsetULTRAFASTBALLERNarifle = 0x178;


        private void button1_Click(object sender, EventArgs e)
        {
            Thread newThread1 = new Thread(xyz);
            newThread1.Start();
        }

        private void xyz ()
        {
            while (true)
            {
                int Base_ = vam.ReadInt32((IntPtr)Base);
                float X = Base_ + oX;
                float Y = Base_ + oY;
                float Z = Base_ + oZ;
                float AngleX = Base_ + ovAngleX;
                float AngleY = Base_ + ovAngleY;
                int Health = Base_ + oHealth;
                float X_ = vam.ReadFloat((IntPtr)X);
                float Y_ = vam.ReadFloat((IntPtr)Y);
                float Z_ = vam.ReadFloat((IntPtr)Z);
                float AngleX_ = vam.ReadFloat((IntPtr)AngleX);
                float AngleY_ = vam.ReadFloat((IntPtr)AngleY);
                int Health_ = vam.ReadInt32((IntPtr)Health);

                MethodInvoker inv = delegate
                {
                    textBox1.Text = X_.ToString();
                    textBox2.Text = Y_.ToString();
                    textBox3.Text = Z_.ToString();
                    textBox4.Text = AngleX_.ToString();
                    textBox5.Text = AngleY_.ToString();
                    textBox6.Text = Health_.ToString();
                };
                this.Invoke(inv);
            } 
       }

        private void aimbot()
        {
            while (true)
            {
                int list0 = vam.ReadInt32((IntPtr)oEntity);
                list0 += 0x4;
                for (int i = 0; i < 32; i++)
                {
                    //dynamic address of the entity first == dynEntAddressOutput + Offset == Enemy Value
                    int dynEntAddressOutput = vam.ReadInt32((IntPtr)list0 + (i * 0x4));
                    int Base_ = vam.ReadInt32((IntPtr)Base);
                    int eHealth = vam.ReadInt32((IntPtr)(dynEntAddressOutput + oHealth));
                    int MyTeam = vam.ReadInt32((IntPtr)(TeamOffset1));
                    int MyTeam2 = vam.ReadInt32((IntPtr)(TeamOffset2));
                    int Team1e = vam.ReadInt32((IntPtr)(dynEntAddressOutput + TeamOffset1));
                    int Team2e = vam.ReadInt32((IntPtr)(dynEntAddressOutput + TeamOffset2));
                    if (eHealth <= 100 && eHealth > 0 && Team2e == 1 /*&& dynEntAddressOutput == 218793136 */)
                    {
                        float eX = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oX));
                        float eY = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oY));
                        float eZ = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oZ));
                        float AngleX = Base_ + ovAngleX;
                        float AngleY = Base_ + ovAngleY;
                        float X = Base_ + oX;
                        float Y = Base_ + oY;
                        float Z = Base_ + oZ;
                        float X_ = vam.ReadFloat((IntPtr)X);
                        float Y_ = vam.ReadFloat((IntPtr)Y);
                        float Z_ = vam.ReadFloat((IntPtr)Z);
                        float XV = eX - X_;
                        float YV = eY - Y_;
                        float ZV = eZ - Z_;
                        float hyp = (float)Math.Sqrt(XV * XV + YV * YV + ZV * ZV);                       
                        float pitchX = (float)Math.Atan2(eZ - Z_, hyp ) * 180 / PI;
                        float yawY = -(float)Math.Atan2(eX - X_, eY - Y_) / PI * 180 + 180;
                        MethodInvoker inv = delegate
                        {
                            richTextBox1.Text += (dynEntAddressOutput.ToString() + " Team 1 E  " + Team1e.ToString() + " MyTeam 1 " + MyTeam.ToString()+ " Team2e " + Team2e.ToString() + " MyTeam2 " + MyTeam2.ToString()) + Environment.NewLine;
                        };
                        this.Invoke(inv);

                        vam.WriteFloat((IntPtr)AngleY, pitchX);
                        vam.WriteFloat((IntPtr)AngleX, yawY);

                        if (i == 32)
                        {
                            i++;

                            i = 0;
                        }
                    }

                }
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Thread newThread2 = new Thread(aimbot);
            newThread2.Start();
        }
    }
}
Also you can download the full source if you want too see the broken Aimbot in Action.

I Hope you Guys can help, because I really tried very hard figuring it out, but with no luck.

Also sorry for the bad english, im German :D

Thank you very much guys,

fx705HUJX0
 

Attachments

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
It's hard to help when it is painful to read your code :p But good job so far!

I would remove this immediately:
C++:
                        if (i == 32)
                        {
                            i++;
 
                            i = 0;
                        }
Becuase this already does that logic for you:
C++:
for (int i = 0; i < 32; i++)

It's time for you to read some aimbot source codes written by other people and understand how the logic works. Seperate your code into seperate individualized functions:

Attach to the process
Read Memory and populate your local data structures, this will include calculating base addresses and offsets. Offsets and baseaddresses shouldn't be calculated in your aimbot code, it should all be done before hand
Calculate distance/angle etc...
Find the best target.
Aim at target

This will make it much more modular and making changes easier.

If you want a video tutorial explaining to you the logic of a hack please watch this video:
https://youtu.be/LT4n0KiSA90

If you get your code organized better it will be easy to help you, good luck!
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,294
37,938
269
C++:
                        float eX = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oX));
                        float eY = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oY));
                        float eZ = vam.ReadFloat((IntPtr)(dynEntAddressOutput + oZ));
                        float AngleX = Base_ + ovAngleX;
                        float AngleY = Base_ + ovAngleY;
                        float X = Base_ + oX;
                        float Y = Base_ + oY;
                        float Z = Base_ + oZ;
                        float X_ = vam.ReadFloat((IntPtr)X);
                        float Y_ = vam.ReadFloat((IntPtr)Y);
                        float Z_ = vam.ReadFloat((IntPtr)Z);
                        float XV = eX - X_;
                        float YV = eY - Y_;
                        float ZV = eZ - Z_;
                        float hyp = (float)Math.Sqrt(XV * XV + YV * YV + ZV * ZV);                      
                        float pitchX = (float)Math.Atan2(eZ - Z_, hyp ) * 180 / PI;
                        float yawY = -(float)Math.Atan2(eX - X_, eY - Y_) / PI * 180 + 180;
Damn son, make that look cleaner.

Anyways.

Get your position

loop through all enemies -> get position -> get 3d distance ( can just use good ol pythag for something simple ) -> check if closer than your current closest -> that enemy is now your target, keep looping until done

-> aim at current target
 
  • Like
Reactions: tvojama

fx705HUJX0

Jr.Coder
Dank Tier Donator
Nobleman
Mar 24, 2016
65
838
0
Hello mambda,

Yep the code is looking bad :D

Well I already got that part- My Problem is how to convert the Theorie in to Code. Mostly how to get all the diiferent length and then compare them. Maybe using Arrays? Adding them to a array and then get the smallest number from the Array? I tried it, but i couldnt figure out how to code it :(

Thanks for your help,

fx705HUJX0
 

Lovelace

Jr.Coder
Full Member
Nobleman
Oct 23, 2015
83
938
5
You could use an array and store each player number and distance and use the bubblesort algorithm to place the nearest player at index 0.

But why do that when something like this is simpler.

Time for some pseudo

C#:
int bestTarget = -1; // since first player starts with 0
float nearestDistance = float.MaxValue; // just set it up to something high
for (int i = 0; i < playerCount; i++)
{
     float distance = GetDistance(player[i]);
     if (distance < nearestDistance)
     {
           nearestDistance = distance;
           bestTarget = i;
     }
}

if (bestTarget >= 0)
{
     // do aimbot stuff here
}
 

fx705HUJX0

Jr.Coder
Dank Tier Donator
Nobleman
Mar 24, 2016
65
838
0
Hello,

Well thanks for the Code, but still i don't know where i could place it in my code. Because everything in that for each is not usable in a other place of the code. Also this line:

C#:
float distance = GetDistance(player[i]);
What should i insert at GetDistance and player? Is GetDistance just the the length between me and the Enemy? And is Player just the Entity List player id?

Maybe you could give me a hint where to put it in my code.

Thank you very much,

fx705HUJX0
 

Lovelace

Jr.Coder
Full Member
Nobleman
Oct 23, 2015
83
938
5
It's just a pseudo code. Though I thought I provided a noob friendly example...

GetDistance depends on you. You could get the 3D distance of the entity, 2D distance (screen coordinates of bone target), or distance of calculated aimbot angle (2D distance is enough tho). For simplicity, just go ahead and use the 3D distance formula or AKA the pythagorean theorem to get the hypotenuse.
 

fx705HUJX0

Jr.Coder
Dank Tier Donator
Nobleman
Mar 24, 2016
65
838
0
Hello,

Well i already get the Distance via the Distance of a Vector. My question is how to use your code to make the aimbot work. Because as i said a cant get it to work in my code, because. Even if i change the pseudo code a bit arround it doesnt work.
Well thanks for the help anyways! I appreciate it :) I just have to see how i do it, maybe i get a flash of genius lol. Its just that im so close and all of the code that i did yet i could work out nearly myself. Actually i calculated all the Math on a piece of Paper haha.
I would need someone who showed me were to place it in code, but ye doesnt matter i will see how i will go :D

Have a great day,

fx705HUJX0
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods