See also: FieldTypes

GetFieldId

Usage:

GetFieldId(coords)

Example:

coords = "460,355"
echo GetFieldId(coords)

This function converts coordinates into a field id.

The field id is a number between 0-63999. Each number directly corresponds to a square on the 800x800 grid map. The game server uses field ids to reference all the squares on the map... 0,0 has field id of 0.... 1,0 has field id of 1... 799,0 has field id of 799... 1,1 is field id 800... and so on. Many of the advanced scripting functions require you to convert your coordinates into fieldIds to use them.

This example finds the coordinates of a field id:

FieldIdToCoords

Usage:

FieldIdToCoords(fieldId)

Example:

fid = 284460
echo FieldIdToCoords(fid)

This function converts a field id into coordinates.

This example finds the coordinates of a field id:

FindField

Usage:

FindField(x,y,radius,FieldTypes[,level])

Example:

FindField(city.x,city.y,20,12,10)

See also: FieldTypes

This function can find objects on the map within a specified radius of the searching city. You can for example use FindField to generate a list of all players near you, or all npcs level 10 within 20 miles, or whatever. The FieldTypes usable with FindField are linked above. The level is optional and can be omitted, or you may use "0" for any level. You can echo the results directly, or find and manipulate them from $result.

This example finds all the flats within a specified radius around your city, then echos the level of each:

This example gets a list of all npcs level 10 within 20 miles of your city, and then sorts them into an array of nearest to furthest from your city. Note - these are fieldIds not coordinates. You can turn the fieldIds into coordinates using FieldIdToCoords

AllCastles

Usage:

AllCastles(fieldId1,fieldId2)

Example:

AllCastles(0,159399)

This function returns an array of MapCastleBean objects within an area. The first fieldId will be the northwest (top left) most corner of the area. The second fieldId will be the southeast (bottom right) most corner of the area. Both values must be field id not coordinates.

This example returns an array of all MapCastleBean objects within the state of Friesland:

This example will return an array of all MapCastleBean objects within a specified distance. Like a radius but in a rectangle...

MapDistance

Usage:

MapDistance(x1,y1,x2,y2)

Example:

MapDistance(123,456,111,222)

This function finds the distance between two sets of coordinates on the map.

This example finds the distance between your own city and target coordinates, rounded to 2 decimal places:

FormatDistance

Usage:

FormatDistance(fieldId1,fieldId2)

Example:

FormatDistance(12345,23456)

This function finds the distance between two field ids and displays it in a nice readable format.

Basic example:

This example finds the distance between your own city and a target coordinates:

GetLevel

Usage:

GetLevel(fieldId)

Example:

GetLevel(city.fieldId)

This function returns the level of whatever is located at a certain field id.

GetZoneName

Usage:

GetZoneName(fieldId)

Example:

GetZoneName(city.fieldId)

This function returns the name of the state a field id is located in.


CategoryFunctions

MapFunctions (last edited 2014-12-27 19:20:02 by Inanna)