BeamNG.drive Multiplayer (BeamNG-MP) Hey guys and girls, So i have been keeping my eye on something like this for a while now and have come to the conclusion that its time to try and make a multiplayer Lua based script for BeamNG to allow for multiplayer. How it works: The project now works / uses TCP and UDP packets typically running on ports 30813 & 30814 by default. TCP is used for all session information and to maintain the connection to the server. UDP is used for all data pertaining to the vehicles due to it being stateless and therefore faster which means we are able to send more data in a shorter space of time (Great news for us). At present (As of writing) the project updates your vehicle by updating its position at what is currently 10 times a second, though higher numbers have been proven to work this is the most reliable for performance in test cases so far. Now some of you, myself included will argue this is just a hack rather than "Multiplayer" however might i remind you, you can always try to make it yourself and i have spent a lot of time on this and are trying to get the best results with what i have at my disposal at the time. I am not a developer of the game and therefore do not have full insight into the inner mechanics of the game and its engine so for the time being this is the best we have. Current State: The project currently sits in a some what playable state though errors and bugs are almost garenteed still at this point. Once I am happy with it and am comfortable enough with it i will be putting it onto the mods repository for all to easily access. Links & Information The MP mod can be downloaded from the GitHub: https://github.com/Starystars67/BeamNG-MP/ To play mp on the internet you will need the bridge too which can be downloaded from: https://github.com/Starystars67/BeamNG-MP-Bridge/releases, Servers can be found in the official BeamNG-MP discord: (Available Further down, Rules stipulate i cannot put it but will update if i get permission to put it here). Project Tracker / Progress can be tracked here on the trello board that i have put together and update periodically: https://trello.com/b/Kw75j3zZ/beamngdrive-multiplayer For those of you who have asked for the likes of patreon and ways to donate towards this project I have setup a Patreon page for this. All donations are greatly received but not required to use / play this at all in any way, however I reserve the right to shut down any public servers I run / host for you since that comes out of my own money (Unless donations cover full costs). All donations go towards the running and continued up time of the servers provided for you: https://www.patreon.com/BeamNGMP PLEASE KEEP IN MIND THIS IS STILL VERY EARLY STAGES, FEATURES AND THE WAY THINGS WORK MAY AND ARE LIKELY TO CHANGE! IF YOU DO NOT ACCEPT THIS FACT THEN DO NOT PLAY / USE THIS MOD UNTIL IT IS ON THE MODS REPOSITORY! OLD ORIGINAL POST BELOW. The way this will work is using websockets to update the other clients and the host in almost real time. So from the start, Player starts the game, selects a map and loads in. They then open the GUI for multiplayer, enter a port and click host. 2nd player starts up the game, loads the same world and then opens the GUI. They enter the hosts port and IP and then click join. Providing the they can connect to the host the host will pause (or similar) and make a complete running config which will then be sent to the new client. The client will set their game to match this and then tell the host that we can unpause at XXX time. They are now mirroring each others game play using websockets to update each other. What i need from anyone of you who are willing to help is a better understanding of the Lua environment in BeamNG as i seem to be hitting issues even just trying to require files for some reason. I have put together a GitHub Repository for this and plan to get this done as soon as possible. https://github.com/Starystars67/BeamNG-MP I know that various issues have been brought up around the idea of multiplayer however i feel that it should be okay to play in your local network due to the people with you are likely to have an idea on what each of your computers can handle. Thanks for reading and i look forward to hearing from you.
@Zecoolest8 In theory yes, but i need some help from someone who has experience with the Lua environment for BeamNG. I have issues like `Failed to execute /scripts/mod/modScript.lua` and all this file does is include another file... So i need some help to get the understanding for game engine / Lua environment.
The idea of this is so that you do not have to have all players in your fov meaning you can play as you normally would but there will be other players too. This means you can play with your whoever on your own computer meaning you can play hide and seek or whatever your imagination can come up with.
I'm getting the impression your not really here to give anything constructive to the topic. We are in 2019 and im looking to make an actual multiplayer mod so that we can actually play multiplayer. And all I need from someone with some script making experience in BeamNG is for them to sit down for 10 mins with me to explain the setup and environment. Is that an issue?
Not sure if it's doable, but I'm gonna link someone who knows a lot about LUA and could tell you if it could work or not. @thomatoes50
Multiplayer have been attempted multiple times from modders. I'm not sure how much realism you want but you will have some technical limitation. Even I with the source of the game engine I'm unable to go around them. (average dev do not get the source of the physic engine obviously) So what remain is just hacks like teleport or push vehicles. From your Github project i saw you use some weird function, i think you are trying to use Torque3D GUI in lua. This is not recommended and you have better options like imgui or the apps system (angular) What i recommend is that your git repo become the exact data you have in your mod folder C:\users\name\Documents\BeamNG.drive\mods\unpacked\BeamNG-MP\ (then all your files) modScript.lua -> \scripts\BeamNG-MP\modScript.lua You also should look how the extensions system works /helper scripts/main.lua -> \lua\ge\BeamNGMP.lua then in your modscript to load and keep it loaded when you switch map you do this: Code: registerCoreModule("BeamNGMP") extensions.load("BeamNGMP") also there is already a webserver module integrated in the game Code: uiWebServer = require('utils/simpleHttpServer') uiWebServer.start(listenHost, httpListenPort, '/', nil, function(req, path) return { httpPort = httpListenPort, wsPort = httpListenPort + 1, host = listenHost, } end) print('created http server') -- the websocket counterpart wsServer = require('libs/lua-websockets/websocket').server.copas.listen({ interface = listenHost, port = httpListenPort + 1, protocols = { bngApi = bngApi_websocket_handler, }, default = bngApi_websocket_handler, })
Thank you @thomatoes50 this is the sort of information that i needed! I will update the Repo shortly with my progress!
Okay, Repository has been updated and the mod now loads in which is what i was having issues with originally. A temporary UI has been created: and now its time to move to connections.
This looks really promising. It will be interesting to see if you can get this working... Hopefully you can succeed where others failed Not sure how useful this thread may be for you, but I thought I should link it anyway just in case: https://www.beamng.com/threads/vehicle-lua-reference.62186/
Thanks for that dude, that will definitely come in handy for the next step which is to start copying over vehicles. At the moment im doing connections.
Mods should be allowed if they are cosmetics like vehicles, maps and objects as long as all players (the host and the client / clients) have them.
If this would work like most games... usually the data of the actual vehicle will not be copied over, just general location information as that cuts down on the amount of data that needs to be transferred significantly. As long as both the host and the connecting player have the same mod, there should be no issues.