Click here to Skip to main content
15,923,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i need little bit help it showing Distange betwen me and others but wont drawbox or is it player / bot or / other faction player.
Okay. i will try to explain it better, my problem is am trying to create ESP and merge it with assembly-csharp (unity game) and manage to works, but now my problem is that my code just showing distance from player but not BOX form them but am have that code for drawing boxes and dont understand where is my problem and how to fix it.
I gived abov fully working code if somebody can take me example what am i doing wrong... Thank you.

<pre>using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using EFT;
using EFT.Interactive;
using System.IO;
using System.Runtime.InteropServices;

// Released by TheWWorld on UnknowCheats
// I think the godmode cause my ban or maybe i was reported for for weird killings
namespace Absolutly
{
    public class Abso : MonoBehaviour
    {
        public Abso() { }

        private GameObject GameObjectHolder;

        private IEnumerable<Player> _playerInfo;
        private IEnumerable<ExfiltrationPoint> _extractPoints;


        private float _plyNextUpdateTime;
        private float _evaNextUpdateTime;
        protected float _infoUpdateInterval = 5f; // You can reduce this value for fastest update esp but can cause lag


        private bool _isInfoMenuActive;
        private bool _showPlayersInfo;
        private bool _showExtractInfo;


        private float _maxVueDistance = 600f; // View Distance (you can change it on overlay by pressing F11 and modify the red value)


        public void Load()
        {
            GameObjectHolder = new GameObject();
#pragma warning disable CS0436 // Type conflicts with imported type
            GameObjectHolder.AddComponent<Abso>();
#pragma warning restore CS0436 // Type conflicts with imported type

            DontDestroyOnLoad(GameObjectHolder);
        }

        public void Unload()
        {
            Destroy(GameObjectHolder);
            Destroy(this);
        }

        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.F12))
            {
                Unload();
            }
            if (Input.GetKeyDown(KeyCode.F11))
            {
                _isInfoMenuActive = !_isInfoMenuActive;
            }
        }

        private void OnGUI()
        {
            if (_isInfoMenuActive)
            {
                DrawInfoMenu();
            }

            if (_showPlayersInfo && Time.time >= _plyNextUpdateTime)
            {
                _playerInfo = FindObjectsOfType<Player>();
                _plyNextUpdateTime = Time.time + _infoUpdateInterval;
            }

            if (_showPlayersInfo)
            {
                DrawPlayers();
            }


            if (_showExtractInfo && Time.time >= _evaNextUpdateTime)
            {
                _extractPoints = FindObjectsOfType<ExfiltrationPoint>();
                _evaNextUpdateTime = Time.time + _infoUpdateInterval;
            }

            if (_showExtractInfo)
            {
                DrawExtractInfo();
            }
        }

        private void DrawExtractInfo()
        {
            try
            {
                foreach (var point in _extractPoints)
                {
                    float distanceToObject = Vector3.Distance(Camera.main.transform.position, point.transform.position);
                    var exfilContainerBoundingVector = new Vector3(
                        Camera.main.WorldToScreenPoint(point.transform.position).x,
                        Camera.main.WorldToScreenPoint(point.transform.position).y,
                        Camera.main.WorldToScreenPoint(point.transform.position).z);

                    if (exfilContainerBoundingVector.z > 0.01)
                    {
                        GUI.color = Color.green;
                        int distance = (int)distanceToObject;
                        String exfilName = point.name;
                        string boxText = $"{exfilName} - {distance}M";

                        GUI.Label(new Rect(exfilContainerBoundingVector.x - 50f, (float)Screen.height - exfilContainerBoundingVector.y, 100f, 50f), boxText);
                    }
                }
            }
            catch (Exception ex)
            {
                File.WriteAllText("evasion.txt", ex.ToString());
            }
        }


        private void DrawPlayers()
        {
            try
            {
                foreach (var player in _playerInfo)
                {

                    float distanceToObject = Vector3.Distance(Camera.main.transform.position, player.Transform.position);
                    var playerBoundingVector = new Vector3(
                        Camera.main.WorldToScreenPoint(player.Transform.position).x,
                        Camera.main.WorldToScreenPoint(player.Transform.position).y,
                        Camera.main.WorldToScreenPoint(player.Transform.position).z);

                    if (distanceToObject <= _maxVueDistance && playerBoundingVector.z > 0.01)
                    {
                        var playerHeadVector = new Vector3(
                            Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).x,
                            Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y,
                            Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).z);

                        float boxXOffset = Camera.main.WorldToScreenPoint(player.Transform.position).x;
                        float boxYOffset = Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y + 10f;
                        float boxHeight = Math.Abs(Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y - Camera.main.WorldToScreenPoint(player.Transform.position).y) + 10f;
                        float boxWidth = boxHeight * 0.65f;

                        var playerColor = GetPlayerColor(player.Side);
                        var isAi = player.Profile.Info.RegistrationDate <= 0;

                        var playerName = isAi ? "AI" : player.Profile.Info.Nickname;
                        string playerText = $"[{(int)distanceToObject}m]";

                        var playerTextVector = GUI.skin.GetStyle(playerText).CalcSize(new GUIContent(playerText));
                        GUI.Label(new Rect(playerBoundingVector.x - playerTextVector.x / 2f, (float)Screen.height - boxYOffset - 20f, 300f, 50f), playerText);
                    }
                }
            }
            catch (Exception ex)
            {
                File.WriteAllText("plyzlog.txt", ex.ToString());
            }
        }

        private string CurrentWeaponIDtoName(string id)
        {
            if (id.Contains("p226"))
                return "P226R";
            else if (id.Contains("mp443"))
                return "MP443";
            else if (id.Contains("aks74"))
                return "AKS-74";
            else if (id.Contains("_mr133_"))
                return "MR-133";
            else if (id.Contains("_mr153_"))
                return "MR-153";
            else if (id.Contains("saiga12"))
                return "Saig.12";
            else if (id.Contains("akm"))
                return "AKM";
            else if (id.Contains("ak74n"))
                return "AK-7N";
            else if (id.Contains("ak74m"))
                return "AK-7M";
            else if (id.Contains("mr43e"))
                return "MR-43E";
            else if (id.Contains("model_870"))
                return "M870";
            else if (id.Contains("mosin"))
                return "Mosin";
            else if (id.Contains("_zarya_"))
                return "Zarya";
            else if (id.Contains("_pb_"))
                return "PB9x18PM";
            else if (id.Contains("_izhmeh_pm_"))
                return "Makarov";
            else if (id.Contains("saiga_9"))
                return "SaigaPM";
            else if (id.Contains("_tt_"))
                return "TT";
            else if (id.Contains("pp-9"))
                return "pp91";
            else if (id.Contains("vepr"))
                return "VEPR";
            else if (id.Contains("glock"))
                return "Glock";
            else if (id.Contains("sks"))
                return "SKS";
            else if (id.Contains("akms"))
                return "AKMS";
            else if (id.Contains("akm_vpo"))
                return "AKM VPO";
            else if (id.Contains("vepr_km"))
                return "VEPR KM VPO";
            else if (id.Contains("mp5"))
                return "MP5";
            else if (id.Contains("mp7a1"))
                return "MP7";
            else if (id.Contains("_mpx_"))
                return "MPX";
            else if (id.Contains("molot_aps"))
                return "Molot";
            else if (id.Contains("m1a"))
                return "m1a";
            else if (id.Contains("sa58"))
                return "SA58";
            else if (id.Contains("ak101"))
                return "AK101";
            else if (id.Contains("ak102"))
                return "AK102";
            else if (id.Contains("ak103"))
                return "AK103";
            else if (id.Contains("ak104"))
                return "AK104";
            else if (id.Contains("ak105"))
                return "AK105";
            else if (id.Contains("m4a1"))
                return "M4A1";
            else if (id.Contains("sv-98"))
                return "SV-98";
            else if (id.Contains("_val_"))
                return "ASVAL";
            else if (id.Contains("_vss_"))
                return "VSS";
            else if (id.Contains("rsass"))
                return "RSASS";
            else if (id.Contains("dvl-10"))
                return "DVL10";
            else
                return id;

        }

        private Color GetPlayerColor(EPlayerSide side)
        {
            switch (side)
            {
                case EPlayerSide.Bear:
                    return Color.red;
                case EPlayerSide.Usec:
                    return Color.blue;
                case EPlayerSide.Savage:
                    return Color.green;
                default:
                    return Color.white;
            }
        }

        private void DrawInfoMenu()
        {
            GUI.color = Color.black;
            GUI.Box(new Rect(100f, 100f, 190f, 190f), "");

            GUI.color = Color.white;
            GUI.Label(new Rect(180f, 110f, 150f, 20f), "OPCIJE");

            _showPlayersInfo = GUI.Toggle(new Rect(110f, 140f, 120f, 20f), _showPlayersInfo, "ESP");
            _showExtractInfo = GUI.Toggle(new Rect(110f, 160f, 120f, 20f), _showExtractInfo, "EXFIL");
            _maxVueDistance = float.Parse(GUI.TextField(new Rect(110f, 200f, 120f, 20f), _maxVueDistance.ToString(), 10, "DISTANCE"));

        }

        private double GetDistance(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt(Math.Pow(x2 - x1, 2.0) + Math.Pow(y2 - y1, 2.0));
        }
    }
}


What I have tried:

Everyting possible!
Try to remove some playerinfo to replice class but 0
any idea?
Posted
Updated 18-Dec-19 2:11am
v2
Comments
Richard MacCutchan 18-Dec-19 7:50am    
1. Your question is far from clear.
2. Telling us that you have tried everything possible does not leave scope for more suggestions.
MRHals Gospodin 18-Dec-19 8:10am    
Okay. i will try to explain it better, my problem is am trying to create ESP and merge it with assembly-csharp (unity game) and manage to works, but now my problem is that my code just showing distance from player but not BOX form them but am have that code for drawing boxes and dont understand where is my problem and how to fix it.
I gived abov fully working code if somebody can take me example what am i doing wrong... Thank you.

PIC: https://i.imgur.com/JQH8Ibm.png

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900