mxserver-2018-06-30-1412
Re: mxserver-2018-06-30-1412
Since it's javascript, try " += " instead of " .= ". Let me know if it makes a difference.
Discord: StorkeN#6883 - StorkenMXS Youtube - StorkenMXS Instagram - StorkenMXS Facebook - TMFR on Faceboook
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
my leaderboard is coded in PHP not in javascript so "+=" is right.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
I didn't find how add this line in my server (I'm on windows). I think it will be easier for me if you add a js hook for this event.jlv wrote: tail -f log.txt | grep '^All ready!$' | (while read line; do echo "x/mypassword/customallreadycmd" >/dev/udp/127.0.0.1/19800; done)
I also try to use 'forceplay UID' before restart but I have to restart a second time for server take account of these.
Re: mxserver-2018-06-30-1412
There is no bug in the "date" field unless you count the year 2038 rollover. It's the direct output of the C time() function. Here's the code:MxSimulatorMods wrote:I konw that but the date have a bug. When I totally restart the server, the date is right and my leaderboard work correctly. But after few hours, the result date is not the same than real date. There is a gap between both.jlv wrote: "starttime" is when the gate dropped in 1/128 second units. "date" is seconds since the beginning of time in 1970.
I use this function to know when the start will begin in php :Code: Select all
$h_debut = $race[date] + convertHumanGap($race[starttime]); function ConvertHumanGap($time) { if ( $time <= 0 ) return ""; $time = $time / 128; $sec = floor($time); $ms = round(($time - $sec)*10); if ($sec<=99) { $time = ""; $time .= "$sec.$ms"; } else { $time=$sec; } return $time; }
fprintf(g_results_file, "date=%u\n", (unsigned int)time(NULL));
Your server might have a broken clock or you may have a bug somewhere else.
It's probably harmless but I don't see why you're adding the gate drop time to the date. It's always going to be 13-15 seconds which is not significant as far as dates go.
Also, your ConvertHumanGap() function will convert .99 to .10. You'll save yourself a lot of trouble by just using sprintf("%.1f", $time) instead.
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.
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
Could you add this hook please ? It will be awesome for MxsRank !jlv wrote:No good way right now. This might work but it's definitely not pretty (and not tested either):MxSimulatorMods wrote:Is it possible to add hook when riders have finished to load the track after restart ?
I would like to send message if the rider is in spectator status after restart.
For now, I use "at +X" but if the rider take lot of time time to load the track, he didn't see the message.
tail -f log.txt | grep '^All ready!$' | (while read line; do echo "x/mypassword/customallreadycmd" >/dev/udp/127.0.0.1/19800; done)
Probably would be a good idea to add an all ready hook.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
JLV, is it possible?
Re: mxserver-2018-06-30-1412
Yes. I want to finish some client side scripting stuff first.
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.
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
Thanks, I look forward to this update to add features at MxsRank.jlv wrote:Yes. I want to finish some client side scripting stuff first.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
I'm come back with my problem : I don't find how to determinate when the gate will drop with the result file.
I use this (in php) :
But I always have gap between this time and the real gate drop, between 1 and 10 secondes.
For exemple, with my php code, the start is at 17h23min05s and the real gate drop was at 17h23min12s, so 7s gap
PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.
I use this (in php) :
Code: Select all
$h_debut = $race[date] + ConvertTime($race[starttime]);
function ConvertTime($time)
{
if ( $time <= 0 ) return 0;
// convert mxs time to second
$time = $time / 128;
$time = floor($time);
return $time;
}
For exemple, with my php code, the start is at 17h23min05s and the real gate drop was at 17h23min12s, so 7s gap
PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.
Re: mxserver-2018-06-30-1412
I wouldn't bother with it. The gate drop time is there so you can interpret the other timings, for example, the total race time for the winner will be incorrect if you don't subtract out the start time from the time he crossed the finish line. As far as calendar time goes it's pretty irrelevant.MxSimulatorMods wrote:I'm come back with my problem : I don't find how to determinate when the gate will drop with the result file.
I use this (in php) :
But I always have gap between this time and the real gate drop, between 1 and 10 secondes.Code: Select all
$h_debut = $race[date] + ConvertTime($race[starttime]); function ConvertTime($time) { if ( $time <= 0 ) return 0; // convert mxs time to second $time = $time / 128; $time = floor($time); return $time; }
For exemple, with my php code, the start is at 17h23min05s and the real gate drop was at 17h23min12s, so 7s gap
I just realized you can do that by polling mxserver.get_number("race_time", 0). It'll be <= 0 when the clients are loading and start counting up when everyone is loaded in. Poll it from tic_handler or second_handler and you should be set.MxSimulatorMods wrote:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.
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.
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
It's working, thanks.jlv wrote:I just realized you can do that by polling mxserver.get_number("race_time", 0). It'll be <= 0 when the clients are loading and start counting up when everyone is loaded in. Poll it from tic_handler or second_handler and you should be set.MxSimulatorMods wrote:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.
My code :
Code: Select all
var second_count = 0;
var second_count_next_report = 1;
var Loading = false;
function log_seconds() {
if (mxserver.get_number("race_time", 0).toFixed(0) == 0 && Loading == false) {
Loading = true;
}
if (Loading == true && mxserver.get_number("race_time", 0) > 0) {
Loading = false;
//My start broadcast
}
log_seconds_prev();
}
var log_seconds_prev = mxserver.second_handler;
mxserver.second_handler = log_seconds;
Re: mxserver-2018-06-30-1412
A couple of comments on the code - no need for .toFixed(0) there. It's already an integer and you don't want to convert to string there. Also, when the server first starts race_time will be -1, so it might be a good idea to test for <= 0 instead of == 0. Actually, just in case something weird happens and it loads in less than a second you should save the previous value of race_time and set "Loading = true" when the new value is lower than the old value. Something like this:MxSimulatorMods wrote:It's working, thanks.jlv wrote:I just realized you can do that by polling mxserver.get_number("race_time", 0). It'll be <= 0 when the clients are loading and start counting up when everyone is loaded in. Poll it from tic_handler or second_handler and you should be set.MxSimulatorMods wrote:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.
My code :Code: Select all
var second_count = 0; var second_count_next_report = 1; var Loading = false; function log_seconds() { if (mxserver.get_number("race_time", 0).toFixed(0) == 0 && Loading == false) { Loading = true; } if (Loading == true && mxserver.get_number("race_time", 0) > 0) { Loading = false; //My start broadcast } log_seconds_prev(); } var log_seconds_prev = mxserver.second_handler; mxserver.second_handler = log_seconds;
Code: Select all
race_time = mxserver.get_number("race_time", 0);
if (race_time < prev_race_time)
Loading = true;
prev_race_time = race_time;
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.
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
-
- Crushed Dissenter
- Posts: 62
- Joined: Fri Aug 03, 2018 6:37 pm
Re: mxserver-2018-06-30-1412
Other question about js.
Why we need to callback the hook at the end of function ?
Why we need to callback the hook at the end of function ?
Code: Select all
function send_greeting(slot) {
mxserver.send(slot, "Welcome to the server!");
send_greeting_prev(slot); /* Why this line ? */
}
var send_greeting_prev = mxserver.connect_handler;
mxserver.connect_handler = send_greeting;
Re: mxserver-2018-06-30-1412
You don't need to. I've just been writing stuff that way to make it easier for people to cut and paste the various scripts together. Otherwise only the last hook would run. If you know you only have one hook there's no need to pass it through.MxSimulatorMods wrote:Other question about js.
Why we need to callback the hook at the end of function ?
Code: Select all
function send_greeting(slot) { mxserver.send(slot, "Welcome to the server!"); send_greeting_prev(slot); /* Why this line ? */ } var send_greeting_prev = mxserver.connect_handler; mxserver.connect_handler = send_greeting;
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.
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Re: mxserver-2018-06-30-1412
Is there a way I can set a certain time instead of laps, IE: 20mins + 2laps?
jlv wrote:This post is useless.