18.03.2012, 02:20
Hello.
In order to familiarize my self with the random function, I decided to add three static vehicles. Now I chose three vehicle ID's, and I have been trying to add 3 cars to my script but I want the vehicle ID to be picked randomly. I want it either to spawn Vehicle ID 404, 401, or 405.
So I looked up the random function on the wiki, and I am completely lost on arrays. I have spent the last 2 hours or so reading tutorials, but it is not coming to me at all. If anyone experienced with arrays would be kind enough to provide a detailed explanation (just a piece of code with some comments will do) on 2D arrays, and on how to randomize them into AddStaticVehicle. I would greatly appreciate it.
This is my array for the vehicle ID's I wish to be randomly picked from.
This is the AddStaticVehicle part that I fail catastrophically on.
In order to familiarize my self with the random function, I decided to add three static vehicles. Now I chose three vehicle ID's, and I have been trying to add 3 cars to my script but I want the vehicle ID to be picked randomly. I want it either to spawn Vehicle ID 404, 401, or 405.
So I looked up the random function on the wiki, and I am completely lost on arrays. I have spent the last 2 hours or so reading tutorials, but it is not coming to me at all. If anyone experienced with arrays would be kind enough to provide a detailed explanation (just a piece of code with some comments will do) on 2D arrays, and on how to randomize them into AddStaticVehicle. I would greatly appreciate it.
This is my array for the vehicle ID's I wish to be randomly picked from.
pawn Код:
new RandomVehicles[][3] =
{
{404},
{401},
{405}
};
pawn Код:
AddStaticVehicleEx(RandomVehicles[rand][3],-901.9831,2687.4890,42.4714,43.9074,-1,0,60000); // RandCar1
AddStaticVehicleEx(RandomVehicles[rand][3],-902.2551,2707.3286,42.4701,223.0923,-1,0.60000); // RandCar2
AddStaticVehicleEx(RandomVehicles[rand][3],-911.8376,2697.6580,42.4780,225.7278,-1,0,60000); // RandCar3