Random & Array Help [Slightly Advanced]
#4

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
you dont need a 2d array for this,
the reason the wiki using one is each row is storing 3 values...

so code like this should work,

pawn Код:
new RandomVehicles[] =
{
    404,
    401,
    405
};


new rand = random(sizeof(RandomVehicles));
AddStaticVehicleEx(RandomVehicles[rand],-901.9831,2687.4890,42.4714,43.9074,-1,0,60000); // RandCar1
random(sizeof(RandomVehicles));
AddStaticVehicleEx(RandomVehicles[rand],-901.9831,2687.4890,42.4714,43.9074,-1,0,60000); // RandCar2
random(sizeof(RandomVehicles));
AddStaticVehicleEx(RandomVehicles[rand],-901.9831,2687.4890,42.4714,43.9074,-1,0,60000); // RandCar3
it wont seam very random with just 3 values however
there is a 33.333333333% chance that each car will be called


hope this helps,
Thank you for your reply, but it's only spawning a Perrenial (404). To test if it was really outputting a random vehicle ID, I made a /respawncars command to see if it would change. But it still keeps spawning a Perrenial.
Reply


Messages In This Thread
Random & Array Help [Slightly Advanced] - by ReneG - 18.03.2012, 02:20
Re: Random & Array Help [Slightly Advanced] - by antonio112 - 18.03.2012, 02:32
Re: Random & Array Help [Slightly Advanced] - by Jonny5 - 18.03.2012, 02:32
Re: Random & Array Help [Slightly Advanced] - by ReneG - 18.03.2012, 02:41
Re: Random & Array Help [Slightly Advanced] - by Jonny5 - 18.03.2012, 04:45
Re: Random & Array Help [Slightly Advanced] - by ReneG - 18.03.2012, 19:04

Forum Jump:


Users browsing this thread: 1 Guest(s)