SA-MP Forums Archive
how do i create a random vehicle? please help... - 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: how do i create a random vehicle? please help... (/showthread.php?tid=132974)



how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

Quote:

new RandomVehicle = random(400,401,402,404,410,412,413,418,419);

AddStaticVehicle(RandomVehicle,2205.2,-1177.0,25.7,270.8,-1,-1); // a car

please help me ... thanks..




Re: how do i create a random vehicle? please help... - Desert - 10.03.2010

pawn Код:
new randomcar [9][1] = {
{400},
{401},
{402},
{404},
{410},
{412},
{413},
{418},
{419}
}

new rand = random(sizeof(randomcar));
AddStaticVehicle(randomcar[rand][0],2205.2,-1177.0,25.7,270.8,-1,-1);
Not sure but should work



Re: how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

works but i've got an error:

Quote:

(8461) : error 001: expected token: ";", but found "new"

thanks for your help.


Re: how do i create a random vehicle? please help... - Desert - 10.03.2010

forgot to add a ; sorry should be here

{419}
}; <----


Re: how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

yeap thanks bro!


Re: how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

problem..... there are no vehicles at the spots i've created..

Quote:

new randomcar [51][1] = {
{400},{401},{402},
{404},{410},{412},{413},{418},{419},{422},{426},{4 39},{440},{458},{461},
{462},{463},{466},{467},{468},{471},{474},{475},{4 78},{479},{489},{492},
{496},{507},{509},{510},{516},{517},{521},{526},{5 27},{529},{533},{542},
{543},{549},{554},{562},{566},{567},{575},{581},{5 86},{600},{604},{605}
};

new rand = random(sizeof(randomcar));

//PART 1
AddStaticVehicle(randomcar[rand][0],645.8277,-1772.6516,12.0704,346.0127,0,0); //



please help dude...


Re: how do i create a random vehicle? please help... - adsy - 10.03.2010

its adding 1 car.

if you are dynamically adding during gameplay use CreateVehicle


Re: how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

it's still on AddStaticVehicle and i see all the cars but! they are all not randmly selected all the cars are ID: 400

how do i change this?.... thank you....


Re: how do i create a random vehicle? please help... - adsy - 10.03.2010

try this

Код:
new randomcar[51] = {

400,401,402,404.....

};
without the:
{} on each one

then change this from:

AddStaticVehicle(randomcar[rand][0]

to

AddStaticVehicle(rand,

if you are planning a new car after an event i would recommend changing addstaticvehcile to createvehicle


Re: how do i create a random vehicle? please help... - FujiNNN - 10.03.2010

Quote:

(8532) : warning 204: symbol is assigned a value that is never used: "randomcar"

........... what now....?


Re: how do i create a random vehicle? please help... - FujiNNN - 12.03.2010

please help.........


Re: how do i create a random vehicle? please help... - Jeffry - 12.03.2010

There is a
pawn Код:
new randomcar;
that is never used, just delete it.


Re: how do i create a random vehicle? please help... - smeti - 13.03.2010

Quote:
Originally Posted by FujiNNN
Quote:

new RandomVehicle = random(400,401,402,404,410,412,413,418,419);

AddStaticVehicle(RandomVehicle,2205.2,-1177.0,25.7,270.8,-1,-1); // a car

please help me ... thanks..

pawn Код:
new
        RandomVehicle[] = { 400, 401, 402, 404, 410, 412, 413, 418, 419 };
    AddStaticVehicle(RandomVehicle[random(sizeof RandomVehicle)], 2205.2, -1177.0, 25.7, 270.8, -1, -1); // car
   
    AddStaticVehicle(RandomVehicle[random(sizeof RandomVehicle)], 2215.2, -1177.0, 25.7, 270.8, -1, -1); // car
    AddStaticVehicle(RandomVehicle[random(sizeof RandomVehicle)], 2225.2, -1177.0, 25.7, 270.8, -1, -1); // car