how? - 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? (
/showthread.php?tid=248342)
how? -
Carrot - 13.04.2011
How can i make like, random a position from max x max y and min x and min y?
Re: how? -
ronnie3148 - 13.04.2011
Код:
SafeSetPlayerPos(playerid, grandomxyz[rand][0], grandomxyz[rand][1], grandomxyz[rand][2]);//example
new Float:grandomxyz[2][3] = {//first number = number of checkpoints 3= x,y,z
{216.9725,79.1339,1005.0391},
{219.8852,75.5487,1005.0391}
};
use a array..... put x,y,z coords in the array..
next time check out this tutorial..... aka search.
http://forum.sa-mp.com/search.php
Re: how? -
Zimon95 - 13.04.2011
@ronnie3148: they are random position but still defined.
If you are looking for some random coords, here's the code:
pawn Код:
RandomX = RandomEx(maxX, minX);
RandomY = RandomEx(maxY, minY);
stock RandomEx(min, max) //******
{
return random(max - min) + min;
}
Re: how? -
Carrot - 13.04.2011
Quote:
Originally Posted by Zimon95
@ronnie3148: they are random position but still defined.
If you are looking for some random coords, here's the code:
pawn Код:
RandomX = RandomEx(maxX, minX); RandomY = RandomEx(maxY, minY);
stock RandomEx(min, max) //****** { return random(max - min) + min; }
|
I didn't understand that.
Re: how? -
Zimon95 - 13.04.2011
The function RandomEx returns a random value that is beetween max and min.
Simply put:
pawn Код:
RandomX = RandomEx(maxX, minX); //Returns a random X value
RandomY = RandomEx(maxY, minY); //Returns a random Y value
SetPlayerPos(playerid, RandomX, RandomY, 1); //This is just an example, it will set player pos. in a random area
where you need to use the random coords.
Re: how? -
ronnie3148 - 13.04.2011
@Zimon I am not thinking he'd want a completely random cord since he'd end up anywhere..