Spawn a Random Vehicle by a Command?
#4

Quote:
Originally Posted by ic3cr3am
Посмотреть сообщение
Код:
new Float:RandomVehicles[][] =
{
	{400},
	{401},
	{402},
	{403},
	{404},
	{405},
	{}, << all car's id you want here
	{}, << all car's id you want here
	{}, << all car's id you want here
	{}, << all car's id you want here
	{}, << all car's id you want here
	{}, << all car's id you want here
	{} << when all is added dont add ","
};

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/randomcar", cmdtext, true, 10) == 0) //randomcar is the command they'll be using to get car
	{
 		new Random = random(sizeof(RandomVehicles));
 		new Float:x, Float:y, Float:z;
	    GetPlayerPos(playerid, x, y, z);
		CreateVehicle(Random, x, y, z, 90, -1, -1, 60); //CreateVehicle([vehicle id], [x position], [y position], [z position], [rotation], [car color 1 (-1 = random color)], [car color 2], [respawn time(seconds)]
		return 1;
	}
	return 0;
}
A 2D array with Float tag? Did you even try to compile (not that it's going to be compiled..) before posting this?

---

Quote:
Originally Posted by nGen.SoNNy
Посмотреть сообщение
pawn Код:
...
new rand_car = random( MAX_RANDOM_VEHICLES - 1 ), s_car = AllCars[ rand_car ], interior = GetPlayerInterior( playerid ), Float:cPos[ 4 ];...
Why -1, the last one is never going to be returned like that.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)