Hello,
We, the eXo-Reallife team, would like to release a module that is also used on our server.
It is a pathfinding module developed by Jusonex and StiviK.
The module uses the A * algorithm. (https://en.wikipedia.org/wiki/A*_search_algorithm)
We use this for our GPS:
Why did we develop a module for this and did not simply write a script?
This has a very simple reason. The module calculates the routes in your own threads, which has the advantage that it is much faster than a script, and secondly, you can calculate how much routes as you want side by side. This will not cause any lags etc.!
What are the features of the module?
The module can load several graphs / nodes side by side
The module calculates the routes in its own threads
Very useful API functions (such as findNodeAt or getNodeNeighbors)
What are the main features? int loadPathGraph (String pathToGraphFile)
This function loads the graph from the given file and returns a GraphId which you need for all other functions. If something does not work, false is returned. bool findShortestPathBetween (int graphId, float startX, float startY, float startZ, float endX, float endY, float endZ, function callback)
This function finds the shortest route between the points. (Unfortunately, no vectors can be handed over!)
The callback function is called when the calculation is finished. As an argument, either a table is returned that contains all nodes, or false if no route is found. bool unloadPathGraph (int graphId)
You can use this function if you no longer need and want to unload the graph, it returns true if everything is fine, false if an error has occurred.
You will find all the other functions that are included in our documentation. Why is the eXo team releasing all this?
Well, that has the simple reason, we want to share our work with others and not just keep it for us! We hope we can enrich you with it and vlt. Even help!
Where can I download the module?
The whole module is open-source and can be viewed in our GitHub organization.
It's released under the MIT License.
GitHub organization: https://github.com/eXo-MTA
Repository: https://github.com/eXo-MTA/ml_pathfind
Download the module (Windows / Linux): https://github.com/eXo-MTA/ml_pathfind/releases
Nodes of all roads in SA: https://github.com/eXo-MTA/ml_pathfind/blob/master/test/sa_nodes.json
If you find any mistakes or suggestions, you can simply create a new issue and we will look into it.
So now that's it, have fun with the module!
- StiviK and the eXo-Reallife team
(Original thread in German: https://www.mta-sa.org/thread/36365-release-mta-sa-pathfinding-module/?postID=407938#post407938)