[Server] Reload JS File

Post your suggestions here
User avatar
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

[Server] Reload JS File

Postby MxSimulatorMods » Sat Mar 02, 2019 11:22 pm

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.
Image

User avatar
Wahlamt
Posts: 7197
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: [Server] Reload JS File

Postby Wahlamt » Sat Mar 02, 2019 11:40 pm

How do you mean, like if you add a track?

User avatar
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

Re: [Server] Reload JS File

Postby MxSimulatorMods » Sun Mar 03, 2019 12:16 am

Yes, may be. Or just a command which reloads all js scripts like 'server, reloadjs'
Image

User avatar
Wahlamt
Posts: 7197
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: [Server] Reload JS File

Postby Wahlamt » Sun Mar 03, 2019 1:29 am

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.

jlv
Site Admin
Posts: 13305
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: [Server] Reload JS File

Postby jlv » Sun Mar 03, 2019 4:25 am

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.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.

User avatar
MxSimulatorMods
Crushed Dissenter
Posts: 62
Joined: Fri Aug 03, 2018 6:37 pm

Re: [Server] Reload JS File

Postby MxSimulatorMods » Sun Mar 03, 2019 10:38 pm

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.
Image

jlv
Site Admin
Posts: 13305
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: [Server] Reload JS File

Postby jlv » Mon Mar 04, 2019 2:42 am

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.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.


Return to “Suggestion Box”

Who is online

Users browsing this forum: No registered users and 2 guests