mxserver-2018-06-30-1412

Post anything about MX Simulator here. Please. I'm begging you.
User avatar
Wahlamt
Posts: 7219
Joined: Mon Sep 13, 2010 3:15 pm
Team: MLG Compton
Location: Sweden
Contact:

Re: mxserver-2018-06-30-1412

Postby Wahlamt » Tue Feb 05, 2019 12:45 pm

Since it's javascript, try " += " instead of " .= ". Let me know if it makes a difference.

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Tue Feb 05, 2019 4:50 pm

my leaderboard is coded in PHP not in javascript so "+=" is right.
Image

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Wed Feb 06, 2019 1:20 am

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 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.
I also try to use 'forceplay UID' before restart but I have to restart a second time for server take account of these.
Image

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

Re: mxserver-2018-06-30-1412

Postby jlv » Wed Feb 06, 2019 2:17 am

MxSimulatorMods wrote:
jlv wrote:"starttime" is when the gate dropped in 1/128 second units. "date" is seconds since the beginning of time in 1970.


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.

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;
}
 

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:

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.

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Thu Feb 14, 2019 12:20 pm

jlv wrote:
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.

No good way right now. This might work but it's definitely not pretty (and not tested either):

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.



Could you add this hook please ? It will be awesome for MxsRank !
Image

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Wed Feb 20, 2019 9:57 pm

JLV, is it possible?
Image

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

Re: mxserver-2018-06-30-1412

Postby jlv » Thu Feb 21, 2019 2:21 am

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.

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Thu Feb 21, 2019 1:36 pm

jlv wrote:Yes. I want to finish some client side scripting stuff first.


Thanks, I look forward to this update to add features at MxsRank.
Image

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Fri Mar 01, 2019 4:25 pm

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) :

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;
}
 


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

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

Re: mxserver-2018-06-30-1412

Postby jlv » Sat Mar 02, 2019 3:12 am

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) :

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;
}


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

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:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.

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.
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: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Sat Mar 02, 2019 11:08 am

jlv wrote:
MxSimulatorMods wrote:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.

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.


It's working, thanks.

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

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

Re: mxserver-2018-06-30-1412

Postby jlv » Sun Mar 03, 2019 3:40 am

MxSimulatorMods wrote:
jlv wrote:
MxSimulatorMods wrote:PS : JLV, Did you work on the new hook ? Because I'm waiting after you to improve automatic messages on MxsRank.

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.


It's working, thanks.

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;

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:

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.

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

Re: mxserver-2018-06-30-1412

Postby MxSimulatorMods » Mon Mar 04, 2019 12:48 am

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

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

Re: mxserver-2018-06-30-1412

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

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;

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.
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 “General Discussion”

Who is online

Users browsing this forum: Fullwood and 4 guests