Skip to content

eXo-OpenSource/ml_pathfind

Repository files navigation

Pathfind Server Module for MTA:SA

Build Status Build Status

Developing

  1. Download and install the EditorConfig plugin for Visual Studio: https://github.com/editorconfig/editorconfig-visualstudio#readme
  2. Launch premake.bat
  3. Open Build/Pathfind.sln

Installing

  1. Put the resulting Bin/ml_gps.dll/.so into your MTA:SA server modules folder.
  2. Add <module src="ml_gps.dll"/> (or .so for Linux) to your mtaserver.conf.
  3. Start the server

API

Function: loadPathGraph

int loadPathGraph(string path)
  • path: The path to the graph definition file (relative to the resource directory)

Returns graphId if everything went fine, false otherwise.

Function: unloadPathGraph

bool unloadPathGraph(int graphId)
  • graphId: The id of the graph

Returns true if the graph has been unloaded, false otherwise.

Function: findShortestPathBetween

bool findShortestPathBetween(int graphId, float startX, float startY, float startZ, float endX, float endY, float endZ, function callback)
  • graphId: The id of the graph
  • startX, startY, startZ: The start position
  • endX, endY, endZ: The end position
  • callback: The callback function (parameters: table nodes)

Returns true if the route calculation has been scheduled successfully, false otherwise.

Function: isGraphLoaded

bool isGraphLoaded(int graphId)
  • graphId: The id of the graph

Returns true if the graph is already loaded, false otherwise.

Function: findNodeAt

int, float, float, float findNodeAt(int graphId, float positionX, float positionY, float positionZ)
  • graphId: The id of the graph
  • positionX, positionY, positionZ: The postion where to search for a node

Returns 4 integers representing nodeId and his position if a node was found, false otherwise.

Function: getNodeNeighbors

table getNodeNeighbors(int graphId, int nodeId, int depth)
  • graphId: The id of the graph
  • nodeId: The id of the start node
  • depth: The depth of the node neighbors

Returns a table with all neighbors of the node, false otherwise.

Contributors

  • Justus H.
  • Stefan K.