Posts: 19
Threads: 7
Joined: Jun 2009
Reputation:
0
09.02.2014, 17:18
(
Последний раз редактировалось SWET; 31.12.2014 в 00:47.
)
How to divide the whole map of San Andreas zones with dimensions such as 100m x 100 m?
Sorry for my bad english, i'm polish.
Posts: 2,856
Threads: 6
Joined: Jun 2007
Reputation:
0
You should rephrase your question because if you just ask how to divide the SA map into 100x100 sqaures I just gonna tell you that you need to divide the default 6000x6000 (~ -3000 till +3000 on x and y) by 60 to get your 100x100 square
MapAndreas is a plugin which gets the highest z value of the nearest 1mІ
Posts: 19
Threads: 7
Joined: Jun 2009
Reputation:
0
I want to create the whole map area 100x100, assigning each area a unique ID. Could you give an example?
Posts: 1,801
Threads: 21
Joined: Mar 2008
Reputation:
0
Do you want a 100x100 pattern or zones of 100x100 meters?
Posts: 1,733
Threads: 20
Joined: Nov 2010
Reputation:
0
Bottom left corner of the map is x = -3000, y = -3000 by default.
When you get your coordinates (GetPlayerPos for example), add 3000 to both the x and y coordinates.
Then your virtual coordinates in the bottom left corner is x = 0, y = 0, while the upper-right corner is x = 6000, y = 6000.
Dividing those by 60 gives you the grid you want (squares of 60x60 meters, 100 divisions in both directions).
To find the square you're in:
- get your coordinates (GetPlayerPos)
- add 3000. to both x and y
- divide those by 60.0
Then you have the X and Y positions of the grid.
You could give ID's to them by multiplying the X by 100, then add Y to that.
Example:
GetPlayerPos returns x = 1245 and y = 784.
We add 3000 to those:
x = 4245, y = 3784.
Divide both by 60:
x = 70.75, y = 63.06 (rounded down: x = 70, y = 63)
Square ID: (70 x 100) + 63 = 7063.
Example 2:
GetPlayerPos returns x = -2997 and y = -2998 (near bottom left corner).
Add 3000: x = 3, y = 2
Divide by 60: x = 0.05, y = 0.033 (rounded down: x = 0, y = 0)
Square ID: (0 x 100) + 0 = 0.
Example 3:
GetPlayerPos returns x = 2998, y = 2995 (top left corner)
Add 3000: x = 5998, y = 5995
Divide by 60: x = 99.96, y = 99.91 (rounded down: x = 99, y = 99)
Square ID: (99 x 100) + 99 = 9999.
Posts: 19
Threads: 7
Joined: Jun 2009
Reputation:
0
okay, thank you! but how can I create gangzone on the area in which currently I stand?
Posts: 1,733
Threads: 20
Joined: Nov 2010
Reputation:
0
Only on your current square?
Suppose you find the square-ID to be 4754 (you're standing at coords: x = -140, y = 275).
x = (-140 + 3000) / 60 = 47.6666 -> rounded down = 47
y = (275 + 3000) / 60 = 54.5833 -> rounded down = 54
Square ID: (47 x 100) + 54 = 4754.
Create a gangzone ranging from:
xMin = (47 * 60) - 3000 = -180.0 (bottom left corner of the square)
yMin = (54 * 60) - 3000 = 240.0 (bottom left corner of the square)
xMax = ((47 + 1) * 60) - 3000 = -120.0 (upper right corner of the square)
yMax = ((54 + 1) * 60) - 3000 = 300.0 (upper right corner of the square)