#1

How can i make like, random a position from max x max y and min x and min y?
Reply
#2

Код:
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
Reply
#3

@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;
}
Reply
#4

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.
Reply
#5

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.
Reply
#6

@Zimon I am not thinking he'd want a completely random cord since he'd end up anywhere..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)