Post Your Source Codes Here

Posts 106–120 of 176 · Page 8 of 12
Quote Originally Posted by Fowl3628800 View Post
What would be a less memory intensive way?
Instead of going through them all, go through the ones you need to.
Here is some code:
Code:
Skills[] SkillsArray = UnityEngine.Object.FindObjectsOfType(typeof(Skills)) as Skills[];
Inventory[] InventoryArray = UnityEngine.Object.FindObjectsOfType(typeof(Inventory)) as Inventory[];
Life[] LifeArray = UnityEngine.Object.FindObjectsOfType(typeof(Life)) as Life[];
Player[] PlayerArray = UnityEngine.Object.FindObjectsOfType(typeof(Player)) as Player[];
Faster + Less memory intensive
Quote Originally Posted by Trollaux View Post


Instead of going through them all, go through the ones you need to.
Here is some code:
Code:
Skills[] SkillsArray = UnityEngine.Object.FindObjectsOfType(typeof(Skills)) as Skills[];
Inventory[] InventoryArray = UnityEngine.Object.FindObjectsOfType(typeof(Inventory)) as Inventory[];
Life[] LifeArray = UnityEngine.Object.FindObjectsOfType(typeof(Life)) as Life[];
Player[] PlayerArray = UnityEngine.Object.FindObjectsOfType(typeof(Player)) as Player[];
Faster + Less memory intensive
That's what my method is doing.
If I call
Code:
getMine<Player>();
it gets the PlayerArray
Code:
UnityEngine.Object.FindObjectsOfType<Player>();
and goes only through it.

And what I don't understand is why most people do
Code:
UnityEngine.Object.FindObjectsOfType(typeof(T)) as T[]
instead of only
Code:
UnityEngine.Object.FindObjectsOfType<T>()
Quote Originally Posted by Fowl3628800 View Post
That's what my method is doing.
If I call
Code:
getMine<Player>();
it gets the PlayerArray
Code:
UnityEngine.Object.FindObjectsOfType<Player>();
and goes only through it.

And what I don't understand is why most people do
Code:
UnityEngine.Object.FindObjectsOfType(typeof(T)) as T[]
instead of only
Code:
UnityEngine.Object.FindObjectsOfType<T>()
Because its faster? I already explained this.
Quote Originally Posted by Trollaux View Post


Because its faster? I already explained this.
When I call
Code:
UnityEngine.Object.FindObjectsOfType<T>()
it calls
Code:
Resources.ConvertObjects<T>(Object.FindObjectsOfType(typeof(T)))
Is it the call of
Code:
Resources.ConvertObjects<T>()
which makes it slower?
I'm so bad at this I can't even W2S, LOL.

Code:
if (ZombieESP)
        {
            Zombie[] zombieArray = UnityEngine.Object.FindObjectsOfType(typeof(Zombie  )) as Zombie[];
            foreach (Zombie zombie in zombieArray)
            {
                Transform zombies = zombie.transform;
                Vector3 test = new Vector3();
                test.x = zombies.position.x;
                test.y = zombies.position.y;
                test.z = zombies.position.z;
                Vector3 pos = Camera.main.WorldToScreenPoint(test);
                GUI.Label(new Rect(pos.x, pos.y, 15, 15), "Zombie");
            }
        }
EDIT: I got confused and had the code in the wrong place. Anyways I have another problem now with Y, it seems to move with my camera.

mind helping me to get my esp working i have been trying to get it to work and its driving me crazy
Quote Originally Posted by momo_ex2 View Post
mind helping me to get my esp working i have been trying to get it to work and its driving me crazy
Here is the source code (This ESP is laggy >.<)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

public class Hacks : MonoBehaviour
{
public static bool esp = true;
public static bool EspBool = false;
public static Esp playeresp = new Esp(new Player());
public static Esp zombieesp = new Esp(new Zombie());
public static Esp itemesp = new Esp(new Item());
public static Esp crateesp = new Esp(new Crate());
public static Esp vehicleesp = new Esp(new Vehicle());
public static Esp animalesp = new Esp(new Animal());
public static Esp trapesp = new Esp(new Trap());
public static Esp lockedCrateesp = new Esp(new LockedCrate());

void Start()
{
Hacks.playeresp.enabled = false;
Hacks.zombieesp.enabled = false;
Hacks.itemesp.enabled = false;
Hacks.crateesp.enabled = false;
Hacks.vehicleesp.enabled = false;
Hacks.animalesp.enabled = false;
Hacks.trapesp.enabled = false;
Hacks.lockedCrateesp.enabled = false;
}

void OnGUI()
{

if (GUI.Button(new Rect(10, 10, 150, 20), "ESP Menu"))
{
EspBool = !EspBool;
}

if (Hacks.EspBool)
{
GUI.backgroundColor = new Color(1f, 0f, 0f, 1f);
GUI.skin.window.fontSize = 16;
EspEnable.EspWindow = GUI.Window(2, EspEnable.EspWindow, new GUI.WindowFunction(EspEnable.drawESP), "ESP Menu");
}

if (Hacks.esp)
{
Hacks.playeresp.dispesp();
Hacks.zombieesp.dispesp();
Hacks.itemesp.dispesp();
Hacks.crateesp.dispesp();
Hacks.vehicleesp.dispesp();
Hacks.animalesp.dispesp();
Hacks.trapesp.dispesp();
Hacks.lockedCrateesp.dispesp();
}
}
}

public class Esp
{
private MonoBehaviour[] objects = null;
private MonoBehaviour type = null;
private int espskip = 0;
public bool enabled = false;
public Esp(MonoBehaviour theobject)
{
this.type = theobject;
}
public void dispesp()
{
if (this.enabled)
{
this.updateespitem();
int i = 0;
while (i < this.objects.Length)
{
try
{
MonoBehaviour monoBehaviour = this.objects[i];
float num = Vector3.Distance(monoBehaviour.transform.position, Camera.main.transform.position);
if (num <= EspEnable.espDist && !monoBehaviour.Equals(Helper.getMe()))
{
string text = monoBehaviour.GetType().ToString();
string name = monoBehaviour.name;
if (text == "Item")
{
name = ItemName.getName(System.Convert.ToInt32(monoBehavi our.name));
}
string text2 = string.Concat(new string[]
{
text,
"\n",
name,
"\nDist:",
num.ToString(),
"M"
});
Vector3 position = monoBehaviour.transform.position;
Vector3 vector = Helper.getCamera().WorldToScreenPoint(position);
if (vector.z >= 0f)
{
vector = new Vector2(vector.x, (float)Screen.height - vector.y);
int num2 = (int)((EspEnable.espDist - num) / EspEnable.espDist * 16f);
if (num2 == 0)
{
num2 = 1;
}
GUI.skin.label.fontSize = num2;
Vector2 vector2 = GUI.skin.label.CalcSize(new GUIContent(text2));
GUI.color = Color.green;
GUI.Label(new Rect(vector.x - vector2.x / 2f, vector.y, vector2.x, vector2.y), text2);
}
}
}
catch (System.Exception ex)
{
string message = ex.Message;
}
IL_1F3:
i++;
continue;
goto IL_1F3;
}
}
}
private void updateespitem()
{
if (this.espskip > 150 || this.objects == null)
{
this.objects = (UnityEngine.Object.FindObjectsOfType(this.type.Ge tType()) as MonoBehaviour[]);
this.espskip = 0;
}
this.espskip++;
}
}

public class EspEnable
{
public static Rect EspWindow = new Rect(0f, 0f, 190f, 400f);
public static float espDist = 300f;
public static void drawESP(int id)
{
float num = 0f;
Hacks.esp = GUI.Toggle(new Rect(10f, num += 25f, 130f, 20f), Hacks.esp, "Esp On/Off");
if (Hacks.esp)
{
GUI.skin.label.fontSize = 12;
GUI.Label(new Rect(0f, num += 25f, 120f, 20f), "Esp Range:" + (int)EspEnable.espDist + "M");
EspEnable.espDist = GUI.HorizontalSlider(new Rect(10f, num += 25f, 100f, 30f), EspEnable.espDist, 100f, 5000f);
Hacks.playeresp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.playeresp.enabled, "Player Esp");
Hacks.zombieesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.zombieesp.enabled, "Zombie Esp");
Hacks.trapesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.trapesp.enabled, "Trap Esp");
Hacks.itemesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.itemesp.enabled, "Item Esp");
Hacks.crateesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.crateesp.enabled, "Crate Esp");
Hacks.lockedCrateesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.lockedCrateesp.enabled, "LockedCrate Esp");
Hacks.vehicleesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.vehicleesp.enabled, "Vehicle Esp");
Hacks.animalesp.enabled = GUI.Toggle(new Rect(10f, num + 25f, 120f, 20f), Hacks.animalesp.enabled, "Animal Esp");
}
GUI.DragWindow();
}
}

internal static class Helper
{
public static float scrHeight = (float)Screen.height;
public static float scrWidth = (float)Screen.width;
private static Camera mainCamera = null;
private static long cameraTime = 0L;
private static Player[] players = null;
private static long playersTime = 0L;
private static Player me = null;
private static long meTime = 0L;
private static CharacterController characterController = null;
private static long characterControllerTime = 0L;
public static Camera getCamera()
{
if (Helper.getTimeStamp() - Helper.cameraTime > 1L || Helper.mainCamera == null)
{
Helper.mainCamera = Camera.main;
Helper.scrHeight = (float)Screen.height;
Helper.scrWidth = (float)Screen.width;
Helper.cameraTime = Helper.getTimeStamp();
}
return Helper.mainCamera;
}
public static Player[] getPlayers()
{
if (Helper.getTimeStamp() - Helper.playersTime > 1L || Helper.players == null)
{
Helper.players = UnityEngine.Object.FindObjectsOfType<Player>();
Helper.playersTime = Helper.getTimeStamp();
}
return Helper.players;
}
public static Player getMe()
{
if (Helper.getTimeStamp() - Helper.meTime > 1L || Helper.me == null)
{
Player[] array = UnityEngine.Object.FindObjectsOfType<Player>();
for (int i = 0; i < array.Length; i++)
{
Player player = array;
if (player.networkView.isMine)
{
Helper.me = player;
}
}
Helper.meTime = Helper.getTimeStamp();
}
return Helper.me;
}
public static CharacterController getCharacterController()
{
if (Helper.getTimeStamp() - Helper.characterControllerTime > 1L || Helper.characterController == null)
{
Helper.characterController = UnityEngine.Object.FindObjectOfType<CharacterContr oller>();
Helper.characterControllerTime = Helper.getTimeStamp();
}
return Helper.characterController;
}
public static long getTimeStamp()
{
System.DateTime dateTime = new System.DateTime(1970, 1, 1);
return (System.DateTime.UtcNow.Ticks - dateTime.Ticks) / 10000000L;
}
}
Please pastebin it with C sharp syntaxing. Its almost impossible to read right now.

You can get rid of this, its not needed.

 
Code
Code:
void Start()
{
Hacks.playeresp.enabled = false;
Hacks.zombieesp.enabled = false;
Hacks.itemesp.enabled = false;
Hacks.crateesp.enabled = false;
Hacks.vehicleesp.enabled = false;
Hacks.animalesp.enabled = false;
Hacks.trapesp.enabled = false;
Hacks.lockedCrateesp.enabled = false;
}


You want to have the have the ESP in its on class so move all of this into its own class and name it ESP, Like this
http://gyazo.com/3caa7d8b230bdc7d0a3052aacf1ca8c5

 
Code
Code:
public class Esp
{
private MonoBehaviour[] objects = null;
private MonoBehaviour type = null;
private int espskip = 0;
public bool enabled = false;
public Esp(MonoBehaviour theobject)
{
this.type = theobject;
}
public void dispesp()
{
if (this.enabled)
{
this.updateespitem();
int i = 0;
while (i < this.objects.Length)
{
try
{
MonoBehaviour monoBehaviour = this.objects[i];
float num = Vector3.Distance(monoBehaviour.transform.position, Camera.main.transform.position);
if (num <= EspEnable.espDist && !monoBehaviour.Equals(Helper.getMe()))
{
string text = monoBehaviour.GetType().ToString();
string name = monoBehaviour.name;
if (text == "Item")
{
name = ItemName.getName(System.Convert.ToInt32(monoBehavi our.name));
}
string text2 = string.Concat(new string[]
{
text,
"\n",
name,
"\nDist:",
num.ToString(),
"M"
});
Vector3 position = monoBehaviour.transform.position;
Vector3 vector = Helper.getCamera().WorldToScreenPoint(position);
if (vector.z >= 0f)
{
vector = new Vector2(vector.x, (float)Screen.height - vector.y);
int num2 = (int)((EspEnable.espDist - num) / EspEnable.espDist * 16f);
if (num2 == 0)
{
num2 = 1;
}
GUI.skin.label.fontSize = num2;
Vector2 vector2 = GUI.skin.label.CalcSize(new GUIContent(text2));
GUI.color = Color.green;
GUI.Label(new Rect(vector.x - vector2.x / 2f, vector.y, vector2.x, vector2.y), text2);
}
}
}
catch (System.Exception ex)
{
string message = ex.Message;
}
IL_1F3:
i++;
continue;
goto IL_1F3;
}
}
}
private void updateespitem()
{
if (this.espskip > 150 || this.objects == null)
{
this.objects = (UnityEngine.Object.FindObjectsOfType(this.type.Ge tType()) as MonoBehaviour[]);
this.espskip = 0;
}
this.espskip++;
}
}

public class EspEnable
{
public static Rect EspWindow = new Rect(0f, 0f, 190f, 400f);
public static float espDist = 300f;
public static void drawESP(int id)
{
float num = 0f;
Hacks.esp = GUI.Toggle(new Rect(10f, num += 25f, 130f, 20f), Hacks.esp, "Esp On/Off");
if (Hacks.esp)
{
GUI.skin.label.fontSize = 12;
GUI.Label(new Rect(0f, num += 25f, 120f, 20f), "Esp Range:" + (int)EspEnable.espDist + "M");
EspEnable.espDist = GUI.HorizontalSlider(new Rect(10f, num += 25f, 100f, 30f), EspEnable.espDist, 100f, 5000f);
Hacks.playeresp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.playeresp.enabled, "Player Esp");
Hacks.zombieesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.zombieesp.enabled, "Zombie Esp");
Hacks.trapesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.trapesp.enabled, "Trap Esp");
Hacks.itemesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.itemesp.enabled, "Item Esp");
Hacks.crateesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.crateesp.enabled, "Crate Esp");
Hacks.lockedCrateesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.lockedCrateesp.enabled, "LockedCrate Esp");
Hacks.vehicleesp.enabled = GUI.Toggle(new Rect(10f, num += 25f, 120f, 20f), Hacks.vehicleesp.enabled, "Vehicle Esp");
Hacks.animalesp.enabled = GUI.Toggle(new Rect(10f, num + 25f, 120f, 20f), Hacks.animalesp.enabled, "Animal Esp");
}
GUI.DragWindow();
}
}

internal static class Helper
{
public static float scrHeight = (float)Screen.height;
public static float scrWidth = (float)Screen.width;
private static Camera mainCamera = null;
private static long cameraTime = 0L;
private static Player[] players = null;
private static long playersTime = 0L;
private static Player me = null;
private static long meTime = 0L;
private static CharacterController characterController = null;
private static long characterControllerTime = 0L;
public static Camera getCamera()
{
if (Helper.getTimeStamp() - Helper.cameraTime > 1L || Helper.mainCamera == null)
{
Helper.mainCamera = Camera.main;
Helper.scrHeight = (float)Screen.height;
Helper.scrWidth = (float)Screen.width;
Helper.cameraTime = Helper.getTimeStamp();
}
return Helper.mainCamera;
}
public static Player[] getPlayers()
{
if (Helper.getTimeStamp() - Helper.playersTime > 1L || Helper.players == null)
{
Helper.players = UnityEngine.Object.FindObjectsOfType<Player>();
Helper.playersTime = Helper.getTimeStamp();
}
return Helper.players;
}
public static Player getMe()
{
if (Helper.getTimeStamp() - Helper.meTime > 1L || Helper.me == null)
{
Player[] array = UnityEngine.Object.FindObjectsOfType<Player>();
for (int i = 0; i < array.Length; i++)
{
Player player = array;
if (player.networkView.isMine)
{
Helper.me = player;
}
}
Helper.meTime = Helper.getTimeStamp();
}
return Helper.me;
}
public static CharacterController getCharacterController()
{
if (Helper.getTimeStamp() - Helper.characterControllerTime > 1L || Helper.characterController == null)
{
Helper.characterController = UnityEngine.Object.FindObjectOfType<CharacterContr oller>();
Helper.characterControllerTime = Helper.getTimeStamp();
}
return Helper.characterController;
}
public static long getTimeStamp()
{
System.DateTime dateTime = new System.DateTime(1970, 1, 1);
return (System.DateTime.UtcNow.Ticks - dateTime.Ticks) / 10000000L;
}
}


That's all i can help with until you pastebin it. It hurts my head to read it like this.
thank you guys but how do i add this to my main script is it already called and i just change the bools to true and also it says i cannot convert player to a array
Quote Originally Posted by momo_ex2 View Post
thank you guys but how do i add this to my main script is it already called and i just change the bools to true and also it says i cannot convert player to a array
It was made to be in its own class, why is it so important to merge it into one?
i just prefer to include everything in one script it is easyer for me to manage
Quote Originally Posted by momo_ex2 View Post
i just prefer to include everything in one script it is easyer for me to manage
The only reason why someone wouldn't want to use multiple class files is either that they don't know how to use them or that they don't care about neatness.

He are some simple things to know about other class files.

If you wish to use another class file, both namespaces must be the same.
To use a variable from another class file, you can just type Myclassfile.myvarname =

If you don't want to use a second class file, then don't use zths esp.
i do know how but i just prefer everything in one place but another problem is that source code the other guy sent didnt work it says i cannot conver player to an array
Quote Originally Posted by momo_ex2 View Post
i do know how but i just prefer everything in one place but another problem is that source code the other guy sent didnt work it says i cannot conver player to an array
I can't help you if i cant see the code.
should i put his code in paste bin because im confussed by it because he has hacks class and esp in the same thing
Posts 106–120 of 176 · Page 8 of 12

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us