Race random places - 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: Race random places (
/showthread.php?tid=388814)
Race random places -
fordawinzz - 30.10.2012
Hello, I want to do a betting system with random places but I need some help at choising them random. How can I make the places to be random and not to repeat ? (6 places)
Re: Race random places -
[HK]Ryder[AN] - 30.10.2012
Top of your script
pawn Код:
new Float:RandomSpawns[][] =
{
{ x , y , z , angle },
{ x , y , z , angle },
{ x , y , z , angle },
{ x , y , z , angle },
{ x , y , z , angle },
{ x , y , z , angle }
};
then in the code where the player spawns
pawn Код:
new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
Re: Race random places -
fordawinzz - 30.10.2012
Nah, I'm not talking about this ...
Like horse races: place 1 is horse number 3, place 2 is horse number 1, place 3 is horse number 2, etc...
Re: Race random places -
[HK]Ryder[AN] - 30.10.2012
Then i guess you can use cases..but it will be like EVERYTIME horse 1 will be place 3 or something.
Re: Race random places -
fordawinzz - 30.10.2012
Yeah, that would be the problem..
Re: Race random places -
[HK]Ryder[AN] - 30.10.2012
otherwise create variables..random it everytime..once a place is selected set its value to 1
when you are doing the next random check if any variable's value is 1 and do not use that :P
Re: Race random places -
fordawinzz - 30.10.2012
Tried that and it didn't worked