SA-MP Forums Archive
Coordinates in area - 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: Coordinates in area (/showthread.php?tid=620144)



Coordinates in area - MerryDeer - 26.10.2016

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?


Re: Coordinates in area - Vince - 26.10.2016

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.


Re: Coordinates in area - MerryDeer - 26.10.2016

How to get distancebetweenpoints in 2d?


Re: Coordinates in area - RockyGamer - 26.10.2016

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?


Re: Coordinates in area - MerryDeer - 26.10.2016

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?


Re: Coordinates in area - MerryDeer - 26.10.2016

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


Re: Coordinates in area - AbyssMorgan - 26.10.2016

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


Re: Coordinates in area - MerryDeer - 26.10.2016

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