SA-MP Forums Archive
Random car pos?.. - 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: Random car pos?.. (/showthread.php?tid=177018)



Random car pos?.. - AndriusZ* - 15.09.2010

hello, well im created a car shop, using gui menu.. but i idk, how can i do when player buy some car, car positions will be random? Like this:
Quote:

masinike = CreateVehicle(415, RANDOM,161,161, -1);

coords for ex:
Quote:

-2432.7859,2314.7695,4.7579,324.4159
-2432.6313,2294.3455,4.7548,321.2483

thanks.


Re: Random car pos?.. - Cameltoe - 15.09.2010

Make an array


Re: Random car pos?.. - Ash. - 15.09.2010

Edit: Cameltoe beat me too it xD

Maybe add your random coordinates into an array?

pawn Код:
enum DataEnum {Float:x, Float:y, Float:z}
new Data[][DataEnum] = {
{-2432.7859,2314.7695,4.7579,324.4159}
{-2432.6313,2294.3455,4.7548,321.2483}
};

// And then do:

new rand = random(sizeof(Data));
masinike = CreateVehicle(415, Data[rand][x], Data[rand][y], Data[rand][z], 161, 161, -1);
Theres probably a different way that i dont know, this is probably easier anyway


Re: Random car pos?.. - Cameltoe - 15.09.2010

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Edit: Cameltoe beat me too it xD

Maybe add your random coordinates into an array?

pawn Код:
enum DataEnum {Float:x, Float:y, Float:z}
new Data[][DataEnum] = {
{-2432.7859,2314.7695,4.7579,324.4159}
{-2432.6313,2294.3455,4.7548,321.2483}
};

// And then do:

new rand = random(sizeof(Data));
masinike = CreateVehicle(415, Data[rand][x], Data[rand][y], Data[rand][z], 161, 161, -1);
Theres probably a different way that i dont know, this is probably easier anyway
Great example