Distinguishing between dedicated server and game client

Discussion in 'Plugins' started by 1frey, Dec 23, 2019.

  1. 1frey

    1frey Registered

    Joined:
    Aug 9, 2017
    Messages:
    8
    Likes Received:
    0
    Hey Plugin Devs,

    I run the example plugin in multiplayer. Dedicated server + rfactor2.exe as client on the same PC.
    I subscribed for
    Code:
    WantsTelemetryUpdates() { return(2); }
    Remember: 0=no 1=player-only 2=all vehicles

    I can see that my plugin is running twice (dedicated server + game client).
    I am writing a TGPluginTelemetryOutput_xxx.txt file where x is a random number generated on Startup().
    So I end up with a file written by the dedicated server and one file written by the game client.

    My question is how can I distinguishing between the dedicated server and the game client in my code.
    My goal is to define if the plugin runs for dedicated server only, game client only or both.

    I cant find anything in the plugin api. I think i would need to find out the process name (if "rfactor2.exe" then its the game, if not its the dedicated server). Is there a better solution?

    Hope my question is clear.
    Thank you and merry x-mas!
    Frey
     
  2. 1frey

    1frey Registered

    Joined:
    Aug 9, 2017
    Messages:
    8
    Likes Received:
    0
    Ok, it could be done by this code:

    PHP:
    char szFileName[MAX_PATH];
    GetModuleFileName(NULLszFileNameMAX_PATH);
    char *pch;
    pch strstr (szFileName"rFactor2 Dedicated.exe");
    if(
    pch != NULL) {
        
    // IS DEDICATED SERVER
    } else {
        
    // IS NOT DEDICATED SERVER
    }
    Is there a better way?
    I dont want to receive updates if its not the dedicated server.

    Does anyone knows if there are any differences in the data between dedicated server and game client?
    Accuracy of the telemetry values will be higher on the server for sure I bet.

    Greetings
     
  3. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,633
    Likes Received:
    3,222
    In ScoringInfoV01:
    // multiplayer
    unsigned char mGameMode; // 1 = server, 2 = client, 3 = server and client

    Grab the rules plugin example from the dev page ( https://www.studio-397.com/modding-resources/ ) to get some updated entries compared to the example #7.

    Telemetry on the server will be better for all cars on average, but obviously a client plugin will have perfect telemetry for the player and then worse for all the other cars (than the server). So depends what you're wanting to do as to which is better.
     
  4. Tygernoot

    Tygernoot Registered

    Joined:
    Feb 26, 2012
    Messages:
    111
    Likes Received:
    56
    Interestingly thanks to this thread I only just figured out that you can actually enable telemetry for all cars, not just your own.

    Not all telemetry is available in the client though, you don't get access to competitors' fuel levels, tyre wear, etc. :p
     
  5. ADSTA

    ADSTA Registered

    Joined:
    Nov 19, 2011
    Messages:
    1,995
    Likes Received:
    1,340
    In the multiplayer.JSON there is this line
    "Client Fuel Visible":2,
    "Client Fuel Visible#":"whether fuel level is visible in results file (0=never, 1=on clients, 2=on server, 3=both)",

    If the multiplayer.JSON on the server had that set at 3 you could get fuel but nothing in there about tyres.
    Not live though, have to wait for the race result .xml file.
     
    Tygernoot likes this.

Share This Page