[Plugin] MapAndreas plugin v1.0 beta
#1

Plugin :: MapAndreas v1.0 beta

This plugin is designed to read provided data regarding the San Andreas map and provide that information to SA-MP pawn scripts.

This version contains a height map of the San Andreas geometry and provides a function to obtain the highest ground position from a provided 2D point. It is expected that future versions could include other types of maps, such as water maps and road maps.



Important: This plugin uses approximately 70MB of RAM. If you are using shared hosting or a VPS, please confirm with your host that this is okay. A version that uses less RAM is planned although it won't have the same level of accuracy.

Possible uses:

This plugin potentially has many uses although here are some obvious examples:

Teleporting:
When the server wants to teleport a player or vehicle to another player, right now the scripts will usually pick a point on the same Z position as the other player. It is only luck most of the time that prevents you from being teleported in to a building or wall, or even below the ground. Using the data made available by this plugin, the server could search around player to find a suitable ground position for teleporting.

Anti-cheat:
Using this plugin you can tell the difference between someone still on top of a building and someone still floating in the air.

Dynamic object placement:
You can potentially use this plugin to determine the ground position around a player for placing objects.

Pawn Natives:

pawn Code:
native MapAndreas_Init(mode); // Used to initalise the data files in to memory - should be called at least once before any other function.
native MapAndreas_FindZ_For2DCoord(Float:X, Float:Y, &Float:Z); // return highest Z point (ground level) for the provided X,Y co-ordinate.
Limitations of MapAndreas_FindZ_For2DCoord()

- San Andreas is a 3D world, although the output provided by this plugin only represents a single dimension. It will only return the highest Z co-ord for the X,Y position you provide. As an example, someone could be standing underneath a bridge and you won't be able to find the ground level which they are standing on. That means it's valid for a player to be beneath the highest ground level. Although using a height map has some serious drawbacks compared to 3D data, it is extremely fast and you can call this function almost as often as you like.
- The Z return value is accurate to 1.0 square world unit (1mІ) for the entire San Andreas landmass (6kmІ).
- The Z return value is accurate to within a few centimeters from the actual ground surface position.
- There is no data about heights below sea level (0.0Z). The function will always return 0.0 for those areas.
- There are parts of San Andreas below sea level that do not contain water. ie the quarry in LV and the underground airport terminal in LS.
- The SA map has small holes in some places. They are fairly rare, although these holes are often not big enough to fall through. The function will return 0.0 for these co-ords. You can potentially check neighbouring co-ordinates if you want to check if the 0.0 return value is a hole.
- This works only in interior 0 (main SA world) and cannot handle areas with custom objects.

Installation:

- Extract the contents of the zip in to your SA-MP server folder/directory.
- Windows Server: edit server.cfg and add the line: plugins MapAndreas
- Linux Server: edit server.cfg and add the line: plugins MapAndreas.so
- To test everything is working, you can load the mapandreas_test filterscript and use the /glvl command.

Downloads:

MapAndreas plugin v1.0 beta (28.2MB)
MapAndreas plugin v1.0 beta source code

Revision history:

v1.0 beta
---------
Initial test version.

Included files:

plugins/MapAndreas.dll - The Windows dll plugin.
plugins/MapAndreas.so - The linux shared object plugin.
scriptfiles/SAfull.hmap - The San Andreas heightmap data.
scriptfiles/SAfull.jpg - A graphical representation of the heightmap data.
pawno/include/mapandreas.inc - The pawn include for the MapAndreas plugin natives.
filterscripts/mapandreas_test.amx - A filterscript with a test command /glvl
filterscripts/mapandreas_test.pwn - Pawn script source for the above filterscript.
Reply
#2

nice job!
Reply
#3

Great job Kye.
Reply
#4

Damn nice, kinda sucks about that ram usage but should provide some nice uses. Thanks!
Reply
#5

Good job Kye!
Reply
#6

Awesome.
Reply
#7

Couldn't you do something like this with SetPlayerPosFindZ and a random player or even a bot ?
Reply
#8

Excellent Kye.
Hopefully this will help with our grids, atm it's a static height then the others cars are dropped (or in some cases fall though floor).

Climbing too will be possible now, even if the building is a skyscraper. Perfect parkour mod.

I'm already loving this and I haven't even downloaded it yet.

Thanks a million. Let's hope KJ allows it for an update plugin install

Quote:
Originally Posted by dice7
Couldn't you do something like this with SetPlayerPosFindZ and a random player or even a bot ?
Speed and accuracy would be poor. Unless you got a genius way of doing it?
Reply
#9

Why would speed and accuracy be poor ? It would be instant
Reply
#10

Quote:
Originally Posted by dice7
Couldn't you do something like this with SetPlayerPosFindZ
pawn Code:
stock
  SetPlayerFindPosZ(playerid, Float:x, Float:y)
{
  new
    Float:z;

  MapAndreas_FindZ_For2DCoord(x, y, z);
  SetPlayerPos(playerid, x, y, z);
}
Reply
#11

Great!
Reply
#12

Quote:
Originally Posted by Balon
Quote:
Originally Posted by dice7
Couldn't you do something like this with SetPlayerPosFindZ
pawn Code:
stock
  SetPlayerFindPosZ(playerid, Float:x, Float:y)
{
  new
    Float:z;

  MapAndreas_FindZ_For2DCoord(x, y, z);
  SetPlayerPos(playerid, x, y, z);
}
https://sampwiki.blast.hk/wiki/SetPlayerPosFindZ
Reply
#13

nice job
it would be perfect if the function MapAndreas_FindZ_For2DCoord could check if there's a gamemode-created object as highest Z too
Reply
#14

Quote:
Originally Posted by dice7
Quote:
Originally Posted by Balon
Quote:
Originally Posted by dice7
Couldn't you do something like this with SetPlayerPosFindZ
pawn Code:
stock
  SetPlayerFindPosZ(playerid, Float:x, Float:y)
{
  new
    Float:z;

  MapAndreas_FindZ_For2DCoord(x, y, z);
  SetPlayerPos(playerid, x, y, z);
}
https://sampwiki.blast.hk/wiki/SetPlayerPosFindZ
Forgot about that. Anyway my function can be used for vehicles then
Reply
#15

Awesome plugin Kye
Reply
#16

Quote:
Originally Posted by Rac3r
Thanks a million. Let's hope KJ allows it for an update plugin install
Yep, we'll have this available for install shortly, I know it will be extremely useful to many people.
Reply
#17

Great Job, will be using this for sure.
Reply
#18

Wow, I was actually thinking of re-making a road map in PAWN, with this and others on the way theres no need to.

Nice one and thanks.
Reply
#19

Wow...Nice plugin Key
Reply
#20

Nice plugin, very useful
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)