SA-MP Forums Archive
Random - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random (/showthread.php?tid=542019)



Random - humphrey - 16.10.2014

Greetings,

I have this code:
PHP код:
enum Vehicles
{
    
v00,
    
v01
};
new 
Vehicle[Vehicles];
Vehicle[v00] = CreateVehicle(41188.4730, -80.32540.932873.947300, -1);
Vehicle[v01] = CreateVehicle(411133.0589, -85.03111.4297239.075500, -1);
new 
random(sizeof(Vehicle));
if(!
IsVehicleOccupied(v)) PutPlayerInVehicle(iv0); 
Most time I spawn in one of the cars, however, sometimes I don't. Am I doing something wrong?


Re: Random - Sawalha - 16.10.2014

yes , you are doing it wrongly, you didn't put a value for your enum list, I suggest you to:
pawn Код:
new Vehicles[2];

Vehicle[0] = ....
Vehicle[1] = ....

new v = random(2); // the size of them both
// Continue..



Re: Random - humphrey - 16.10.2014

It is working now, had to edit some things tho. Thank you!