SA-MP Forums Archive
[help]Random Car - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [help]Random Car (/showthread.php?tid=85011)



[help]Random Car - Marc_307 - 04.07.2009

Hey, I've got the funktion CreateVehicle(v,x,y,z,r,c1,c2,rd); in my script. For v(vehicletype) I want to add a random car out of six.
The ID's to use are 558, 559, 560, 561, 562 and 565.
Does somebody know how to do a random car?


Re: [help]Random Car - YamahaYZ - 04.07.2009

https://sampwiki.blast.hk/wiki/Random rly simple


Re: [help]Random Car - yezizhu - 04.07.2009

new
randVec[] =
{558, 559, 560, 561, 562, 565};

CreateVehicle (randVec[random(sizeof( randVec))],x,y,z,r,c1,c2,rd);


Re: [help]Random Car - illay - 04.07.2009

removed Sorry


Re: [help]Random Car - Marc_307 - 04.07.2009

Quote:
https://sampwiki.blast.hk/wiki/Random rly simple

I've already tried this exacly like Wiki, but it had some mistakes:
Quote:
pawn Код:
#include <a_samp>

//new iRandomNumber = random(25); //you can create a variable global but you cant use a funtion global
new Float:RandomSpawn[][4] =
{
  {-2796.9854, 1224.8180, 20.5429, 192.0335},
  {-2454.2170, 503.8759, 30.0790, 267.2932},
  {-2669.7322, -6.0874, 6.1328, 89.8853}
}; //you forgot here a semicolon

//rest of the code is ok
Quote:

new
randVec[] =
{558, 559, 560, 561, 562, 565};

CreateVehicle (randVec[random(sizeof( randVec))],x,y,z,r,c1,c2,rd);

Thanks, works well.