AMS2 Dedicated Server Tool / SteamCMD Support

Discussion in 'Automobilista 2 - General Discussion' started by Dave Stephenson, May 29, 2020.

  1. roszman

    roszman Well-Known Member

    Joined:
    Jun 11, 2020
    Messages:
    338
    Likes Received:
    419
    hi

    I would like to find ping info in dedi api. In api/list/attributes/member response I can see this:
    Code:
    {
      "result": "ok",
      "response": {
        "description": "Gameplay attributes associated with a session's member (player)",
        "list": [
          //some olther attributes...
          {
            "name": "Ping",
            "type": "int16",
            "access": "ReadOnly",
            "description": "Player's ping to the dedicated server. This is the round trip time, so \"there and back\"."
          }
       ]
    }
    
    but api/session/status?members gives me back this:

    Code:
        "members": [
          {
            "index": 0,
            "refid": 18112,
            "steamid": "steamId",
            "state": "Connected",
            "name": "steam display name",
            "jointime": 1701284672,
            "host": true
          }
    ]
    
    do I call wrong endpoint? Where can I query for members ping info?
     
  2. roszman

    roszman Well-Known Member

    Joined:
    Jun 11, 2020
    Messages:
    338
    Likes Received:
    419
    and bonus question :p

    if I kick out host who have high ping, which driver will be promoted to host? the one with lowest ping or someone at random?
     
  3. Roy Niessink

    Roy Niessink Well-Known Member AMS2 Club Member

    Joined:
    Mar 27, 2020
    Messages:
    1,554
    Likes Received:
    738
    usually when the host changes, the person that joined the server 2nd becomes the host, should he leave, the 3rd that joined will become host, etc,etc,etc
     
    • Informative Informative x 1
  4. roszman

    roszman Well-Known Member

    Joined:
    Jun 11, 2020
    Messages:
    338
    Likes Received:
    419
    thx for reply.

    ehh, so my super idea about kicking out lagging host in order to replace it with one with lower ping could be tricky to implement :p
    I would need to kick all the players except the one with lowest ping :D It's doable, but I am not sure how drivers would react to this

    it would be super cool if dedi could promote to host driver with lowest ping, even more super cool would be if it could promote to host driver with lowest ping dynamically without the need to kick out laggin host first - dedi could do that once in a while or when the session is changing
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  5. roszman

    roszman Well-Known Member

    Joined:
    Jun 11, 2020
    Messages:
    338
    Likes Received:
    419
    neverthless the info about how to get ping info from api would be super cool
     
    Last edited: Nov 29, 2023
    • Agree Agree x 1
  6. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    try this /api/session/status?attributes&members

    Result under members block:

    Code:
    "members" : [
          {
            "index" : 0,
            "refid" : 32832,
            "steamid" : [secret],
            "state" : "Connected",
            "name" : "Svenny",
            "jointime" : 1701487180,
            "host" : true,
            "attributes" : {
              "VehicleId" : -520644472,
              "LiveryId" : 51,
              "LoadState" : "ADMIN_LOADING_RACE",
              "RaceStatFlags" : 0,
              "Ping" : 8
            }
          }
        ]
    PS: I use this to calculate a counter and cummulative ping every 15 secs for a few minutes, if user has avg ping >500ms I send warning in chat to user, if user gets 3 warnings they get kicked.
     
    Last edited: Dec 2, 2023
    • Informative Informative x 3
  7. Wolfgang Herold

    Wolfgang Herold I Like Liveries :) AMS2 Club Member

    Joined:
    Apr 3, 2016
    Messages:
    2,456
    Likes Received:
    1,456
    i remember, there were some custom lua scripts back in the pCARS days.
    It would be nice to have a section, where creative developers can share their gimmicks & tools
     
    • Agree Agree x 1
  8. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    Agree. There are posts scattered throughout this subforum/topic that has links to old PCars2 scripts. Currently mine is just a python script/code running on server..I haven't invested time into lua just yet but the test folder has a autokick function...Just don't know how to use it. I'd much prefer to use lua over the http api so that I can disable the http interface all together.
     
  9. roszman

    roszman Well-Known Member

    Joined:
    Jun 11, 2020
    Messages:
    338
    Likes Received:
    419
    awesome stuff, thx ;)
     
  10. SoulMaTriX

    SoulMaTriX New Member

    Joined:
    Oct 31, 2020
    Messages:
    22
    Likes Received:
    0
    Where in the dedicated server settings is the setting for Time Progression? In game, in the lobby awaiting to start a match, the time progression shows 2x. I'd like to time progression to be 1x. The sample below is the only settings I have set. Is the time progression the 3 under PracticeDateProgression? For some reason I thought this to be the day of the race weekend. I do not use lua scripts (too confusing for me).

    Example of my current settings:
    // Practice length in minutes, in-game time, and time multiplier.
    "PracticeLength" : 45,
    "PracticeDateHour" : 13
    "PracticeDateProgression" : 3
     
  11. Mamuto

    Mamuto New Member AMS2 Club Member

    Joined:
    Jun 21, 2023
    Messages:
    8
    Likes Received:
    4
    Race weekend is set by "RaceDateYear", "RaceDateMonth", "RaceDateDay", and "RaceDateHour".
    You are right about the progression, it is the multiplier, so set it to 1.
    Make sure you get the Qualifying and Race ones as well.
    "QualifyDateProgression", "RaceDateProgression"
     
    • Like Like x 1
  12. SoulMaTriX

    SoulMaTriX New Member

    Joined:
    Oct 31, 2020
    Messages:
    22
    Likes Received:
    0
    Thank you good sir!
     
  13. Asturbo

    Asturbo Member AMS2 Club Member

    Joined:
    Apr 8, 2017
    Messages:
    44
    Likes Received:
    48
    In case it helps, I attach my SERVER.CFG template with comments and parameters, because there are many missing fields in the original sample file.
     

    Attached Files:

    Last edited: Dec 6, 2023
    • Winner Winner x 2
    • Like Like x 1
  14. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    OK - So I decided to reinvent the wheel (read: couldn't find lua script for it) and had a go at lua scripting, some copy and pasting from existing code and have made a high ping kicker.

    Ps: Haven't extensively tested this, but feel free to use without warranty!

    What does it do:
    Runs in background once first member joins server.
    Will monitor each member's ping and calculate an avg ping time.
    If the avg ping exceed's the values set in the config file, user will be sent a warning via ingame chat
    If the avg ping remains above threshold on next check, user will receive another warning.
    Finally, if user receives a warning count that is equal to of greater than the value in the config, that will be added to a kick queue, then after ~10 secs will be kicked out of server.

    Like other lua scripts,
    extract the attachment into the DS lua folder
    Now you should have a folder called ams2_bot
    Ensure lua is enabled in your server.cfg and add "ams2_bot" under the luaApiAddons.
    Code:
    enableLuaApi : true
    luaAddonRoot: "lua"
    luaConfigRoot: "lua_config"
    luaOutputRoot: "lua_output"
    luaApiAddons : [
        "sms_base",
        //"sms_rotate",
        "sms_motd",
        "sms_stats",
        "ams2_bot"
    ]
    luaAllowedLibraries : [
    
        "lib_rotate"
    ]
    In the ams2_bot folder, open up "ams2_bot_default_config.json" and set the parameters you'd like to run with or leave as is.
    Code:
    config : {
        // High Ping Kicker BOT - Enabled. Default true
        "BOT_HighPingKicker" : true,
        // High Ping Kicker BOT - Define the acceptable ms ping the member can have. Default 500
        "ping_limit_ms" : 500,
        // High Ping Kicker BOT - Grab the members ping every x seconds . Default 15 (4 times per miniute)
        "grab_seconds" : 15,
        // How many warnings before kicking. Default 3
        "warnings" : 3,
    
    }
    In Game Image - Low ping threshold just to show it in action..
    ams2_bot.PNG
    Feedback welcomed.

    Updated 27/12/23: Issue with "global member" being nil when called.
     

    Attached Files:

    Last edited: Nov 15, 2024
    • Winner Winner x 4
    • Like Like x 2
  15. Asturbo

    Asturbo Member AMS2 Club Member

    Joined:
    Apr 8, 2017
    Messages:
    44
    Likes Received:
    48
    Some DS suggestions:
    • Warning message in the command line window when you set an invalid parameter for track, car, class, weather, flags or grid players higher than the track player slots. Most here know that in this situation the server starts but loads a random config, or it's not visible in the game browser. It makes not easy to debug (you only have to read this thread). Don't starting the server with an message error of "Wrong track", "Wrong Flags" or "Too much players for track slots", would help a lot.
    • New parameter to change the count down before the race. In communities where you have to give instructions, the 2 minutes counter is too short for strategies and briefing. On the contrary in public races with impatient people is too long. A parameter like “TimeOutBeforeRace” configurable from 60 to 600 would help.
    • Some additional parameter needed for “RaceDateYear”, "RaceDateMonth" and ”RaceDateDay" as “current” or similar to set actual date for the session. The date could be obtained from the DS system clock.
    • Filter clients by ping. Users with ping higher than a specific value in the DS shouldn't be able to join the session. In my experience with pings lower than 100ms and 20 users everything works well. With a player with ping over 300 things could go worse, not only for him, but for the rest of the players. Filtering by latency could help to more stable sessions without human intervention or kicking players, that is ever disgusting. Similar to filter by reputation with a message of "Latency too high for this server".
    • Option to save status after the qualy session to load again in case some driver discconects in the transition to race (quite usual). That would help to keep the grid order and relaunch the race. Other option could be sort the grid, but I'm afraid it would be more complicated, because needs UI integration.
    • Add an option of “random” for the persist_index in LUA setup to select a random combo of the rotate list. That makes that we can program a huge list of combos and we don’t know what we will get, because it doesn’t follow a sequential order. That could help also to have different race conditions as explained in post #19 of this thread.
    • Option to disable “Driver Swap” because is useless in online (hope some day works with other human player...) and can cause accidental AI taking control of the car (too easy to change inadvertently in ICM).
    • Manual FullCourseYellow deployed by the host of the session when required, pressing a button or sending a command to the server. It would be very useful for the race director when incidents or solve unforeseen situations .
     
    Last edited: Dec 8, 2023
    • Winner Winner x 2
    • Like Like x 1
  16. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    I'm no expert, barely a novice in lua but for random race you could try this in the sms_rotate.lua file.

    • comment out line 71
    • add math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
    • add add addon_data.index = math.(random( 0, 10 )
    The math(randomseed()) is to provide a better randomisation seed for the random function. Credit: lua-users wiki: Math Library Tutorial

    The numbers of 0 and 10 reference the lower and upper range limit (inclusive) to randomise the numbers through. This should be the count of the rotations/combos you have in the file, but starting at zero.
    In the example above, my rotation file has 11 tracks.
    Have done a few test runs and appears to randomise tracks now on my servers

    upload_2023-12-8_22-27-37.png
     
    • Like Like x 2
  17. Asturbo

    Asturbo Member AMS2 Club Member

    Joined:
    Apr 8, 2017
    Messages:
    44
    Likes Received:
    48
    Looks good. I will try ;)

    My real intention for the "random" parameter is to set in example a 30% percent or rain options. We could set 10 rotations with same track/car but with 3 of them with rain, an let the DS choose one of them randomly.

    Other more elegant option for this purpose would be asign a weight for the different weather conditions and generate a random number to set the values of RaceWeatherSlot1, RaceWeatherSlot2... Also setting the number of weather slots random from 1 to 4 we could have a "variability" in the weather with 1 for no change and 4 for more options of change during the race.
     
    Last edited: Dec 8, 2023
  18. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    Well that could potentially be injected when the next setup is being called in sms_rotate.lua.

    I did a quick test to confirm and adding the below did infact randomise the practice start hour.

    So yes possible but how to randomise and apply realistic weather slots/cycles to suit is another story.

    I might have a look over the weekend, but will most likely branch this out into it's own lua so updates don't overwrite it in future.

    No promises...

    upload_2023-12-9_0-14-41.png
     
    • Like Like x 1
  19. Svenny

    Svenny New Member

    Joined:
    Jul 25, 2023
    Messages:
    21
    Likes Received:
    22
    I just updated my server with random track selection in rotation and also added variable race date day and random session start times between hours of 6 and 17.

    Proof on base concept...

    Server Name: Sven's: [F1 HTech G1: 11 Historic Track Rotation][P:5/Q:10/R:8 Laps][AUS]
     
    • Like Like x 2
  20. Odd Socks

    Odd Socks Active Member AMS2 Club Member

    Joined:
    Feb 29, 2020
    Messages:
    275
    Likes Received:
    164
    Can anyone tell me where we should send log files if we have had a multiplayer issue.
    I'm a great fan of the online racing in AMS2 and want to help in any way I can, having the log files generated is a good step forward, but only helps if they get to the right person / team.
     

Share This Page