SA-MP Forums Archive
Spawning car system without repeating position - 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: Spawning car system without repeating position (/showthread.php?tid=560866)



Spawning car system without repeating position - TheReptile - 30.01.2015

Hello users, i am new to programming, I am creating a system derby .
The problem is that by using "random spawns " positions are repeated and users spawn above others.
How I can create a system of spawning cars without repeating positions?
Thank You.
(This is my first thread, sorry for my bad english, I'm using language translator)


Re: Spawning car system without repeating position - DRIFT_HUNTER - 30.01.2015

pawn Code:
new Float:Spawns[MAX_SPAWNS][4];
new bool:SpawnUsed[MAX_SPAWNS];


new randomspawn = random(MAX_SPAWNS);
while(SpawnUsed[randomspawn]==true))
{
    randomspawn++;
    if(randomspawn >= MAX_SPAWNS)randomspawn = 0;
}
SpawnUsed[randomspawn]=true;

//Im giving example for player, you do it for vehicles...
SetPlayerPos(playerid, Spawns[randomspawn][0],Spawns[randomspawn][1],Spawns[randomspawn][2]);
SetPlayerFacingAngle(playerid, Spawns[randomspawn][4]);



Respuesta: Spawning car system without repeating position - TheReptile - 30.01.2015

Thank you very much , I will test them and then comment on the results.


Respuesta: Spawning car system without repeating position - TheReptile - 03.02.2015

Hello , sorry for not responding sooner.
Regarding the code you gave me , I do not understand how it works , could explain ?, I 'm new to programming , sorry for the inconvenience