private void Esp()
 {
     if (esptoggle)
     {
         int localplayer = vam.ReadInt32((IntPtr)(bClient + Offsets.oLocalPlayer));
         int playerIndex = vam.ReadInt32((IntPtr)(localplayer + 0x64)) - 1;
         int i           = 0;
         do
         {
             if (playerIndex == i)
             {
                 i++; continue;
             }
             int entity  = vam.ReadInt32((IntPtr)(bClient + Offsets.oEntityList + (i) * Offsets.oEntityLoopDistance));
             int dormant = vam.ReadInt32((IntPtr)(entity + Offsets.oDormant));
             if (isAlive(i, vam, bClient) && !(dormant == 1 || dormant == 2))
             {
                 Point aimAt = new Point();
                 bool  g     = WorldToScreen(getPlayerVectorByIndex(vam, bClient, i), ref aimAt, vam, getMatrixFloats2(csgo, bClient), t);
                 if (g && aimAt.x > t.Left && aimAt.x < t.Right && aimAt.y > t.Top && aimAt.y < t.Bottom)
                 {
                     float d      = Get3dDistance(getLocalPlayerPosition(vam, bClient), getPlayerVectorByIndex(vam, bClient, i));
                     float width  = 20000 / d;
                     float height = 47500 / d;
                     int   team   = vam.ReadInt32((IntPtr)(entity + Offsets.oTeam));
                     if (team == 3)
                     {
                         DrawBoundingBox(aimAt.x - (width / 2), aimAt.y - height, width, height, 1, false);
                         device.DrawLine(
                             new RawVector2(windowWidth / 2 + t.Left, windowHeight + t.Top),
                             new RawVector2(aimAt.x, aimAt.y),
                             blueBrush,
                             1f);
                     }
                     else if (team == 2)
                     {
                         DrawBoundingBox(aimAt.x - (width / 2), aimAt.y - height, width, height, 1, true);
                         device.DrawLine(
                             new RawVector2(windowWidth / 2 + t.Left, windowHeight + t.Top),
                             new RawVector2(aimAt.x, aimAt.y),
                             redBrush,
                             1f);
                     }
                     if (team == 2 || team == 3)
                     {
                         //DrawText("Health: " + , aimAt.x - width/2, aimAt.y - height - height/3);
                         DrawHealthBar(vam.ReadInt32((IntPtr)(entity + Offsets.oHealth)), aimAt.x, aimAt.y, width, height, d);
                         var a = vam.ReadInt32((IntPtr)(bClient + Offsets.dwRadarBase));
                         a = vam.ReadInt32((IntPtr)(a + 0x20));
                         byte[]     returnbytes  = csgo.Read((IntPtr)(a + 0x1E0 * i + 0x204), 32);
                         byte[]     returnbytes2 = vam.ReadByteArray((IntPtr)(a + 0x1E0 * i + 0x204), 32);
                         string     asd          = System.Text.Encoding.Unicode.GetString(returnbytes2, 0, 32);
                         TextFormat thisFont     = new TextFormat(fontFactory, fontFamily, width * 30 / 100);
                         //device.DrawText(asd, thisFont, new RawRectangleF(aimAt.x-width/2,aimAt.y-height-10,Width,Height), new SolidColorBrush(device, new RawColor4(1,1,1,1)));
                     }
                 }
             }
             i++;
         } while (i < 65);
     }
 }
        private void sDXThread(object sender)
        {
            showwarning();
            vam     = new VAMemory("csgo");
            csgo    = new Memory("csgo");
            bEngine = getModule("engine.dll");
            bClient = getModule("client.dll");
            Button[] buttons =
                new Button[] {
                new ToggleableButton("Aimbot", delegate() { aimbottoggle = !aimbottoggle; }),
                new ToggleableButton("Wallhack", delegate() { wallhacktoggle = !wallhacktoggle; }),
                new ToggleableButton("ESP", delegate() { esptoggle = !esptoggle; }),
                new ToggleableButton("Bhop", delegate() { bhoptoggle = !bhoptoggle; }, true),
                new ToggleableButton("Triggerbot", delegate() { triggertoggle = !triggertoggle; }),
                new ToggleableButton("Noflash", delegate() { noflashtoggle = !noflashtoggle; }),
                //new SliderButton("FOV: %value%", delegate (float f) { randomFloat = f; }, abstractValue: 180f)
            };
            menu = new Menu(buttons, (int)Math.Floor((decimal)(Height * 55.5 / 100)), 0);

            d = new Thread(() =>
            {
                bool c = false;
                while (true)
                {
                    while (c == false)
                    {
                        while (GetAsyncKeyState(0x26) < 0)
                        {
                            //aimbottoggle = !aimbottoggle;
                            if (c == false)
                            {
                                menu.shiftSelected(false);
                            }
                            c = true;
                        }
                        while (GetAsyncKeyState(0x28) < 0)
                        {
                            //wallhacktoggle = !wallhacktoggle;
                            if (c == false)
                            {
                                menu.shiftSelected(true);
                            }
                            c = true;
                        }
                        while (GetAsyncKeyState(0x25) < 0 || GetAsyncKeyState(0x27) < 0)
                        {
                            //esptoggle = !esptoggle;
                            if (c == false)
                            {
                                menu.activateCurrent();
                            }
                            c = true;
                        }
                        if (c == true)
                        {
                            showMenu = true;
                            //start timer
                            if (timer.Enabled == true)
                            {
                                timer.Stop();
                            }
                            menuOffTicks = 150;
                            timer.Start();
                        }
                    }
                    c = false;
                }
            });
            d.Start();
            bhop = new Thread(() =>
            {
                while (true)
                {
                    jumpy();
                    Thread.Sleep(1);
                }
            });
            bhop.Start();
            Thread checkmap = new Thread(() =>
            {
                while (true)
                {
                    var clientstate = vam.ReadInt32((IntPtr)(bEngine + Offsets.oClientState));
                    var name        = vam.ReadByteArray((IntPtr)(clientstate + 0x28C), 32);
                    var stringthing = Encoding.ASCII.GetString(name);
                    stringthing     = Regex.Replace(stringthing, @"[^\u0020-\u007F].*$+", string.Empty);
                    var isInGame    = vam.ReadInt32((IntPtr)clientstate + 0x108);
                    if ((lastmap == "" || lastmap != stringthing) && isInGame == 6)
                    {
                        string location = Process.GetProcessesByName("csgo")[0].MainModule.FileName;
                        location        = location.Substring(0, location.Length - 8);
                        //stringthing = stringthing.Substring(0, stringthing.IndexOf(@"\"));
                        location += @"csgo\maps\" + stringthing + ".bsp";
                        if (stringthing.Length > 0)
                        {
                            map     = new BSP(location);
                            lastmap = stringthing;
                        }
                    }
                    yield return(0);
                }
            });

            checkmap.Start();
            while (true)
            {
                device.BeginDraw();
                device.Clear(new RawColor4(1f, 1f, 1f, 0f));
                int id = 0;
                var g2 = GetForegroundWindow();
                GetWindowThreadProcessId(g2, out id);
#if !DEBUG
                if (id != csgoProcess.Id)
                {
                    device.EndDraw(); continue;
                }
#endif
                if (showMenu == true)
                {
                    menu.showMenu(device, font);
                }
                t = new RECT();
                GetWindowRect(GetForegroundWindow(), out t);
                int sd = t.Right;
                int st = t.Bottom;

                windowWidth              = t.Right - t.Left;
                windowHeight             = t.Bottom - t.Top;
                device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased;// you can set another text mode
                //device.DrawText("http://detolly.no | Private Cheat | Copyright 2017.", font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 20, t.Right + 600, t.Bottom + 20), redBrush);
                //device.DrawText("F1 | Aimbot: " + (aimbottoggle ? "On." : "Off.") + " | Fov: " + currentFov, font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 60, t.Right + 600, t.Bottom + 100), redBrush);
                //device.DrawText("F2 | Wallhack: " + (wallhacktoggle ? "On." : "Off."), font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 100, t.Right + 600, t.Bottom + 100), redBrush);
                //device.DrawText("F3 | ESP: " + (esptoggle ? "On." : "Off."), font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 140, 600, t.Bottom + 140), redBrush);
                //device.DrawText("F6 | Triggerbot: " + (triggertoggle ? "On." : "Off."), font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 220, t.Right + 600, t.Bottom + 220), redBrush);
                //device.DrawText("F4 | Bhop: " + (bhoptoggle ? "On." : "Off."), font, new SharpDX.Mathematics.Interop.RawRectangleF(t.Left + 5, t.Top + 180, t.Right + 600, t.Bottom + 220), redBrush);

                //var g22 = getMatrixFloats2(csgo, bClient);
                //string g22text = "";
                //for (int i = 0; i < g22.Length; i++)
                //{
                //    for (int x = 0; x < g22[i].Length; x++)
                //    {
                //        g22text += g22[i][x] + "\t";
                //    }
                //    g22text += "\r\n";
                //}
                //g22text += "First Length: " + g22.Length + "\tSecond Length: " + g22[0].Length;
                //device.DrawText(
                //    g22text,
                //    font,
                //    new SharpDX.Mathematics.Interop.RawRectangleF(0,100000,100000,windowHeight/2),
                //    blueBrush
                //    );
                //device.DrawText("Player Position: " + getLocalPlayerPosition(vam, bClient).x + ", " + getLocalPlayerPosition(vam, bClient).y + ", " + getLocalPlayerPosition(vam, bClient).z
                //    , font
                //    , new SharpDX.Mathematics.Interop.RawRectangleF(0, windowHeight - 20, 1000, windowHeight)
                //    , redBrush);

                Esp();
                device.EndDraw();
                seethroughthing();
                Aimbot();
                tragger();
                noflash();
                if (performance)
                {
                    Thread.Sleep(5);
                }
            }
        }