Originally Posted by
Blueblood1
This will just constantly give you the same vehicle, even if its exploded. I tried messing with Vehicles to see if i could get it too return its health but sadly not. Anyway here is the same code but with a Randomizer in it so that you don't get the same exploded vehicle every time.
Code:
if (GUI.Button(new Rect(scrWidth-100, 380, 100, 30), "Get Car"))
{
//Credit to Lystic
Vehicle[] mapVehicles = (Vehicle[])(UnityEngine.Object.FindObjectsOfType(Type.GetTypeFromHandle(Type.GetTypeHandle(new Vehicle()))));
int length = mapVehicles.Length;
int num = UnityEngine.Random.Range(0, length);
Vehicle veh = mapVehicles[num];
veh.tellExploded(false);
veh.tellFuel(100);
veh.tellHealth(100);
Vector3 camPos = Camera.main.transform.position;
Vector3 newPos = new Vector3(camPos[0] + 5, camPos[1] + 5, camPos[2]);
veh.updatePosition(newPos, Camera.main.transform(dot)rotation);
veh.transform.position = newPos;
}
Of course you could just set the Vehicle stats, but the randomizer still helps.
Code:
if (GUI.Button(new Rect(scrWidth-100, 380, 100, 30), "Get Car"))
{
//Credit to Lystic
Vehicle[] mapVehicles = (Vehicle[])(UnityEngine.Object.FindObjectsOfType(Type.GetTypeFromHandle(Type.GetTypeHandle(new Vehicle()))));
int num = UnityEngine.Random.Range(0, 10);
Vehicle veh = mapVehicles[num];
veh.tellExploded(false);
veh.tellFuel(100);
veh.tellHealth(100);
Vector3 camPos = Camera.main.transform.position;
Vector3 newPos = new Vector3(camPos[0] + 5, camPos[1] + 5, camPos[2]);
veh.updatePosition(newPos, Camera.main.transform****tation);
veh.transform.position = newPos;
}
Also first person to get MP item spawning working first I will suck their dick. I have some code that I've been working on with limited success. (If someone tells me how to reference methods from other classes with RPC successfully I'll have it done for y'all)