Post Your Source Codes Here

Posts 61–75 of 176 · Page 5 of 12
And for my last source i will be sharing

Teleport to cursor on mouse3 down

Code:
;
if (Input.GetMouseButtonDown(2))
{
        Ray screenRay = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
        RaycastHit hit;
        if (Physics.Raycast(screenRay, out hit, 1000))
        {
            Vector3 tpPos = hit.point;
            tpPos.y += 1;
            myPlayer().transform.position = tpPos;
        } 
}
you'll need these functions in order to get that to work
Get all players
Code:
Player[] allPlayers()
{
    return (Player[])(UnityEngine.Object.FindObjectsOfType(Type.GetTypeFromHandle(Type.GetTypeHandle(new Player()))));
}
Get current player
Code:
Player myPlayer()
    {
        Player player = new Player();
        Player[] players = allPlayers();
        if (isInGame(players))
        {
            if (!foundPlayer)
            {
                float closestDistance = 1000f;
                if (players.Count() > 0)
                {
                    foreach (Player plr in players)
                    {
                        float newDist = Vector3.Distance(plr.transform.position, Camera.main.transform.position);
                        if (newDist < closestDistance)
                        {
                            player = plr;
                        }
                    }
                    myUnit = player;
                    foundPlayer = true;
                }

            }
            else
            {
                player = myUnit;
            }
        }
        else
        {
            foundPlayer = false;
        }
        return player;
    }
You may need to place your own global variables to make up for some of the ones i use. sorry i didnt include them
Quote Originally Posted by Lystic View Post
Code:
Player myPlayer()
    {
        Player player = new Player();
        Player[] players = allPlayers();
        if (isInGame(players))
        {
            if (!foundPlayer)
            {
                float closestDistance = 1000f;
                if (players.Count() > 0)
                {
                    foreach (Player plr in players)
                    {
                        float newDist = Vector3.Distance(plr.transform.position, Camera.main.transform.position);
                        if (newDist < closestDistance)
                        {
                            player = plr;
                        }
                    }
                    myUnit = player;
                    foundPlayer = true;
                }

            }
            else
            {
                player = myUnit;
            }
        }
        else
        {
            foundPlayer = false;
        }
        return player;
    }
For Get current player
this is more simple
Code:
        private static Player me = null;
        private static long meTime = 0;
        public static Player getMe()
        {
            if ((getTimeStamp() - meTime) > 1 || me == null)
            {
                foreach (Player p in GameObject.FindObjectsOfType<Player>())
                {
                    if (p.networkView.isMine)
                    {
                        me = p;
                    }
                }
                meTime = getTimeStamp();
            }
            return me;
        }
in my hack all invoked repeatedly functions is cache 2 seconds
Quote Originally Posted by end360 View Post
If someone could release a GUI player list that would be nice, as i failed at making one.
If you click on the Name you'll TP to him
Code:
private Player[] players;

void Update()
{
    players = UnityEngine.Object.FindObjectsOfType(typeof(Player)) as Player[];
}
void OnGUI()
{
    for (int i = 0; i < players.Length; i++)
    {
        float single = this.calcDistance(playerArray[i].transform.position);
        int dist = Convert.ToInt32(single);
        if (SleekRender.button(new Rect(10, 100 + 45 * i, 260, 40), players [i].name + "\n" + dist.ToString() + "m", "button", new Color(44, 62, 80), Color.white))
        {
            GameObject me = UnityEngine.Object.FindObjectOfType&lt;CharacterController&gt;().gameObject;
            me.transform.position = players[i].gameObject.transform.position;
        }
    }
}
Zombie Models

Code:
#define Zombies (NumVertices == 969 && PrimitiveCount == 1192) 
#define Zombie2 (NumVertices == 969 && PrimitiveCount == 1192) 

#define ALL_ZOMBIES Zombies | Zombie2
Not sure if it's posted already. Firetruck spawner:
Code:
  private void FireTruckr()
{
    Color color = new Color(Random.Range((float) 0f, (float) 1f), Random.Range((float) 0f, (float) 1f), Random.Range((float) 0f, (float) 1f));
    SpawnVehicles.create("fireTruck_" + Random.Range(0, 2), 100, 100, Camera.main.transform.position + Vector3.up, base.transform****tation * Quaternion.Euler(-90f, 0f, 0f), color);
}
Also the spawn box around all players(except you)

Code:
 Player[] playerArray2 = Object.FindObjectsOfType(typeof(Player)) as Player[];
        foreach (Player player2 in playerArray2)
        {
            if (!player2.networkView.isMine)
            {
                Vector3 vector2 = player2.transform.position;
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        SpawnStructures.placeStructure(0x4269, vector2 + new Vector3(j * 0.5f, 0f, k * 0.5f), 1, "");
                        SpawnStructures.placeStructure(0x4269, vector2 + new Vector3(-(j * 0.5f), 0f, -(k * 0.5f)), 1, "");
                    }
                }
            }
         }
(for a button enclose in if(GUILayout.Button("name"... etc) {})
Quote Originally Posted by desertflame View Post
Not sure if it's posted already. Firetruck spawner:
Code:
  private void FireTruckr()
{
    Color color = new Color(Random.Range((float) 0f, (float) 1f), Random.Range((float) 0f, (float) 1f), Random.Range((float) 0f, (float) 1f));
    SpawnVehicles.create("fireTruck_" + Random.Range(0, 2), 100, 100, Camera.main.transform.position + Vector3.up, base.transform****tation * Quaternion.Euler(-90f, 0f, 0f), color);
}
Also the spawn box around all players(except you)

Code:
 Player[] playerArray2 = Object.FindObjectsOfType(typeof(Player)) as Player[];
        foreach (Player player2 in playerArray2)
        {
            if (!player2.networkView.isMine)
            {
                Vector3 vector2 = player2.transform.position;
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        SpawnStructures.placeStructure(0x4269, vector2 + new Vector3(j * 0.5f, 0f, k * 0.5f), 1, "");
                        SpawnStructures.placeStructure(0x4269, vector2 + new Vector3(-(j * 0.5f), 0f, -(k * 0.5f)), 1, "");
                    }
                }
            }
         }
(for a button enclose in if(GUILayout.Button("name"... etc) {})
Spawning box credit to Kunii
Has anyone been able to do a certain action when a player sais something in chat ?

e.g. additem <playername> <itemid>

Been looking all over to find a way to capture chat messages. Would be pretty sweet for admin commands
Quote Originally Posted by wouterkabouterlol View Post
Has anyone been able to do a certain action when a player sais something in chat ?

e.g. additem <playername> <itemid>

Been looking all over to find a way to capture chat messages. Would be pretty sweet for admin commands
The rude filter monitors and reads chat. There might be a way.
What void do I put these in? void Update()? I'm new to hacking unturned.
Quote Originally Posted by Trollaux View Post
What void do I put these in? void Update()? I'm new to hacking unturned.
Obviously new to C# and Unity too. These go wherever you put them to modify them.

so if a button in OnGui toggles them
Code:
if(GUI.Button(new Rect(0,0,100,100),"Swag Toggle"))
{
    swaghack = !swaghack;
}
where a bool called
Code:
bool swaghack = false;
exists then you can do in Update()
Code:
if(swaghack)
{
    //do hack stuff
}
Quote Originally Posted by jumboperson187 View Post
Obviously new to C# and Unity too. These go wherever you put them to modify them.

so if a button in OnGui toggles them
Code:
if(GUI.Button(new Rect(0,0,100,100),"Swag Toggle"))
{
    swaghack = !swaghack;
}
where a bool called
Code:
bool swaghack = false;
exists then you can do in Update()
Code:
if(swaghack)
{
    //do hack stuff
}
That swag!
Quote Originally Posted by jumboperson187 View Post
Obviously new to C# and Unity too. These go wherever you put them to modify them.

so if a button in OnGui toggles them
Code:
if(GUI.Button(new Rect(0,0,100,100),"Swag Toggle"))
{
    swaghack = !swaghack;
}
where a bool called
Code:
bool swaghack = false;
exists then you can do in Update()
Code:
if(swaghack)
{
    //do hack stuff
}
Thanks, I already figured it out on my own tho.
While you're at it, is there any way to get a NetworkPlayer by only his name ?

I don't understand why this works fine:

Code:
Player[] players = UnityEngine.Object.FindObjectsOfType(typeof(Player)) as Player[];
But this doesn't compile ? :
Code:
NetworkUser[] users = UnityEngine.Object.FindObjectsOfType(typeof(NetworkUser)) as NetworkUser[];
Quote Originally Posted by wouterkabouterlol View Post
While you're at it, is there any way to get a NetworkPlayer by only his name ?

Or that player's steamid ?
Code:
players = GameObject.FindObjectsOfType<Player>();
foreach (Player p in players)
{
	if (p.name.Equals(name))
	{
                NetworkPlayer np = p.networkView.owner;
		//this is the player.
	}
}
Posts 61–75 of 176 · Page 5 of 12

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us