Popular Post StiviK Posted April 27, 2017 Popular Post Share Posted April 27, 2017 (edited) 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) Edited April 27, 2017 by StiviK 17 2 Link to comment
PeaceBomb99 Posted June 16, 2017 Share Posted June 16, 2017 Can you add support for 64-bit please? Link to comment
aka Blue Posted June 17, 2017 Share Posted June 17, 2017 @StiviK Very nice, it was necessary for some servers, thank you! But, can you explain how we can install/use it in our servers? Thank you again! 1 Link to comment
StiviK Posted June 22, 2017 Author Share Posted June 22, 2017 @eggman yeah, soon i will look into it. @aka Blue what do you want to know? Link to comment
Captain Cody Posted June 22, 2017 Share Posted June 22, 2017 What type of format do the graphs need to be in? (Asking due to the possibility of using this along side custom maps. Link to comment
StiviK Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) The grapsh needs to be a json file (like this https://raw.githubusercontent.com/eXo-MTA/ml_pathfind/v1.0.2/test/sa_nodes.json), i hope you unterstand the structure. By the way, Windows 64bit builds are now available: https://github.com/eXo-MTA/ml_pathfind/releases/tag/v1.0.2 Edited June 22, 2017 by StiviK 1 Link to comment
StiviK Posted June 24, 2017 Author Share Posted June 24, 2017 But @Jusonex and me are looking into creating a tool, to export Nodes from GTA:SA, for example for Ped routes. Link to comment
Syntrax# Posted June 24, 2017 Share Posted June 24, 2017 Is there an example of a script using this or? Link to comment
StiviK Posted June 24, 2017 Author Share Posted June 24, 2017 An example script directly not, but here is it how i use it in my Gamemode: function GPS:constructor() -- Check if module is loaded if not loadPathGraph then outputDebugString("GPS module not loaded. Continuing without...", 2) return end -- Load path graph self.m_GraphId = loadPathGraph("files/paths/sa_nodes.json") end function GPS:destructor() if unloadPathGraph then unloadPathGraph() end end function GPS:getRoute(callback, from, to) if not findShortestPathBetween then return false end return findShortestPathBetween(self.m_GraphId, from.x, from.y, from.z, to.x, to.y, to.z, callback) end 1 Link to comment
Jayceon Posted June 24, 2017 Share Posted June 24, 2017 I'm loaded the module, but i get "attempt to call global" error when i try to use those functions. Link to comment
StiviK Posted June 25, 2017 Author Share Posted June 25, 2017 Are you sure the module is loaded properly and an no errors occurred? Link to comment
Jayceon Posted June 25, 2017 Share Posted June 25, 2017 Yes. The console/debugscript didn't write anything error message. I tried the 32 and 64 bit modules, but same problem. Link to comment
StiviK Posted June 26, 2017 Author Share Posted June 26, 2017 You should see a message like 'MODULE: Loaded "Pathfind Module" (1.00) by "Jusonex, StiviK"' in the console, otherwise it was not loaded! Did you add it to your mtaserver.conf! Or try 'loadmodule ml_pathfind_TYPE.dll' in the console. Link to comment
Jayceon Posted June 26, 2017 Share Posted June 26, 2017 I see the message in console. I tried to add mtaconf. Start server and the module is loaded, and tried the loadmodule command but nothing changes. The functions dont work. Link to comment
Syntrax# Posted June 27, 2017 Share Posted June 27, 2017 (edited) I've managed to generate the path and get the shortest route to your destination.Now my question is how to seperate those in x,y,z coordinates since i'm going to use the draw lines function Edited June 27, 2017 by Syntrax# Link to comment
StiviK Posted June 27, 2017 Author Share Posted June 27, 2017 (edited) The return value of the function is a table with this structure: { { x1, y1, z1 }, { x2, y2, z2 }, ..., { xN, yN, zN } } (where N is the count of the used nodes in the Route) @Jayceon are you trying to use the functions server-side or client-side? Edited June 27, 2017 by StiviK Link to comment
Syntrax# Posted June 28, 2017 Share Posted June 28, 2017 (edited) 51 minutes ago, StiviK said: The return value of the function is a table with this structure: { { x1, y1, z1 }, { x2, y2, z2 }, ..., { xN, yN, zN } } (where N is the count of the used nodes in the Route) @Jayceon are you trying to use the functions server-side or client-side? Already got it working but i've to say the test nodes are seriously messed up they literally take the shortest route which means for example at the greenwood hospital to the highway they will decide to directly jump of the edge to to highway and visa versa This is what i've managed to create thanks to the module , i've to say that it isn't completed yet and is for from stable. I've to find a way to update the route without requesting too much peformance from the server or client. for example when someone doesn't follow the path. Edited June 28, 2017 by Syntrax# Link to comment
StiviK Posted June 28, 2017 Author Share Posted June 28, 2017 Which graph did you use? You'r own? Or the sa_nodes from the repo? Ich think you messed up the edges. Link to comment
Syntrax# Posted June 28, 2017 Share Posted June 28, 2017 Just now, StiviK said: Which graph did you use? You'r own? Or the sa_nodes from the repo? Ich think you messed up the edges. i've used the sa_nodes one but i've to say i'm just looping most of the values not considering the edges etc what is the meaning of those edges btw? Link to comment
StiviK Posted June 28, 2017 Author Share Posted June 28, 2017 (edited) I mean the modules find's the neighbour node of a node by looking at the edges of a node. The edges of a node are defined in the graph, the defined edges are only realistic reachable nodes. Which means if the Input graph (sa_nodes) is correct, what you described should not happen. Edited June 28, 2017 by StiviK Link to comment
Syntrax# Posted June 28, 2017 Share Posted June 28, 2017 oh okey thank you for this support going to take a look on it now Are those Id's btw? Link to comment
StiviK Posted June 28, 2017 Author Share Posted June 28, 2017 @Syntrax# if you need further support, just write me a PN and i'll try to help you. Link to comment
Jayceon Posted June 28, 2017 Share Posted June 28, 2017 I'm using it in client side, but tried it in server side. Every side return the "attempt to call" I don't know what the problem. I'm using Windows 10 Pro 64 bit, MTA SA server 1.5.4. The console show the module successfully loaded. Link to comment
Jayceon Posted July 1, 2017 Share Posted July 1, 2017 I'm now tried the module in MTA SA 1.4 server and successfully loaded. What the problem with 1.5.4 server? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now