Page 1 of 1
[Server] Reload JS File
Posted: Sat Mar 02, 2019 11:22 pm
by MxSimulatorMods
Hi JLV,
It will be great if we can reload js files on the server without restart it. With this feature, we have not to setup again all tracks on it after each little update on js.
Re: [Server] Reload JS File
Posted: Sat Mar 02, 2019 11:40 pm
by Wahlamt
How do you mean, like if you add a track?
Re: [Server] Reload JS File
Posted: Sun Mar 03, 2019 12:16 am
by MxSimulatorMods
Yes, may be. Or just a command which reloads all js scripts like 'server, reloadjs'
Re: [Server] Reload JS File
Posted: Sun Mar 03, 2019 1:29 am
by Wahlamt
You could double it. Like *inserting stuff in js file via GUI button click* also runs something like:
Code: Select all
x<XCMD PASSWORD>server,addtrack <time> <laps> <change interval> <trackinfo>
or
x<XCMD PASSWORD>server,removetrack <track number>
It perhaps isn't the full solution you want, but for specifically adding tracks, this could work.
Re: [Server] Reload JS File
Posted: Sun Mar 03, 2019 4:25 am
by jlv
You could try 'eval(mxserver.file_to_string("myscript.js"))'. You'd have to make sure you reset any handlers you hooked at the start of your script to avoid turning the handler chain into a loop. I'd feel safer just restarting the server.
It'd also be possible to save your track list and reload it when the server starts.
Re: [Server] Reload JS File
Posted: Sun Mar 03, 2019 10:38 pm
by MxSimulatorMods
It's not just for tracks. It's also to allow me to make a little update without have to ask at all players to come back after few minutes.
If I could restart js without restart server, it will be easier for me to fix issues very fast on MxsRank.
Re: [Server] Reload JS File
Posted: Mon Mar 04, 2019 2:42 am
by jlv
Probably best to just do the eval thing in that case and be careful with the hooks. The default handlers are all just empty functions so it's safe to not call them.