Getting coordinates in an 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: Getting coordinates in an area? (
/showthread.php?tid=569143)
Getting coordinates in an area? -
Nicker - 28.03.2015
Say I have a square/rectangle area, and I want to get evenly-spaced coordinates in that area like this:
Код:
--------------------------
|. . . . . . . . |
|. . . . . . . . |
|. . . . . . . . |
|. . . . . . . . |
|. . . . . . . . |
|. . . . . . . . |
--------------------------
The dots are the coordinates I need to get. Is there a way of doing this with code, or do I have to just walk to every single spot and use /rs or /s?
Re: Getting coordinates in an area? -
Abagail - 28.03.2015
You can use offsetting to your advantage. For instance,
Say we have an object. We can then take a offset such as -0.5, and add it to the y coordinate of an object.
Example:
pawn Код:
new Float: x, Float: y, Float: z;
GetObjectPos(main_object, x, y, z);
new Float: offset = 0.5;
ObjectCoordinates[0] = x-offset;
If the x of the object is 1000, then it'd be 999.95. I actually made an object offset include a few months ago:
https://sampforum.blast.hk/showthread.php?tid=541980
That may be worth checking out.