Coordinates in area
#1

Hi,

I have area and i need random coordinate in that area. But i have points where i don't want object will spawn, how to check?
Reply
#2

Pick random point. If it's in a "prohibited" area, pick again. Repeat until suitable point is found.

PHP код:
new
    
Float:x,
    
Float:y,
    
Float:z;

do
{
    
random(...);
    
random(...);
    
random(...);
}
while(
IsPointInForbiddenArea(xyz, ...)); 
Something like that. Has the possibility of creating an infinite loop but as long as your "forbidden" areas don't consist of more than 50% of the actual area you shouldn't notice any drop in performance.
Reply
#3

How to get distancebetweenpoints in 2d?
Reply
#4

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
How to get distancebetweenpoints in 2d?
http://forum.sa-mp.com/showpost.php?...82&postcount=2

EDIT: sry actually this is 3d but why do you want it in 2d?
Reply
#5

I found myself. I create area, i need minx,miny,maxx,maxy, but i make perfect foursquare minx, two coordinates same, so what i need to do? i can use still?
Reply
#6

And if i use while in stock or in function, it will wait until while found, when while end and then return &values?
Reply
#7

PHP код:
GetRandomPointInRectangle(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:tx,&Float:ty); 
3DTryg:
https://sampforum.blast.hk/showthread.php?tid=591010
Reply
#8

Yes now i take this. So i can use in this function while?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)