PDA

View Full Version : Dedicated Server HTTP API



M. -VIPER- Morgan
11-01-2018, 06:50
A new thread for all about the Dedicated Server HTTP API.

M. -VIPER- Morgan
11-01-2018, 06:56
I don't know if it is known, but there is a problem in the participant data if I poll /api/session/status?participants
Some values are not filled anymore, for example VehicleId, LiveryId. I know that it was working after release, maybe the problem came with one of the patches.


Here is an example how it looks now (first participant is me and the second an AI driver):


"participants" : [
{
"attributes" : {
"RefId" : 18880,
"Name" : "M. -VIPER- Morgan",
"IsPlayer" : 1,
"GridPosition" : 0,
"VehicleId" : 0,
"LiveryId" : 0,
"RacePosition" : 21,
"CurrentLap" : 0,
"CurrentSector" : 0,
"Sector1Time" : 0,
"Sector2Time" : 0,
"Sector3Time" : 0,
"LastLapTime" : 0,
"FastestLapTime" : 0,
"State" : "InGarage",
"HeadlightsOn" : 0,
"WipersLevel" : 0,
"Speed" : 0,
"Gear" : 0,
"RPM" : 1511,
"PositionX" : 310350,
"PositionY" : -890,
"PositionZ" : -278000,
"Orientation" : 345
},
"id" : 0
},
{
"attributes" : {
"RefId" : 18880,
"Name" : "Pilaud Fabien",
"IsPlayer" : 0,
"GridPosition" : 0,
"VehicleId" : 0,
"LiveryId" : 0,
"RacePosition" : 20,
"CurrentLap" : 0,
"CurrentSector" : 0,
"Sector1Time" : 0,
"Sector2Time" : 0,
"Sector3Time" : 0,
"LastLapTime" : 0,
"FastestLapTime" : 0,
"State" : "Racing",
"HeadlightsOn" : 0,
"WipersLevel" : 0,
"Speed" : 128,
"Gear" : 4,
"RPM" : 4584,
"PositionX" : -210580,
"PositionY" : 31190,
"PositionZ" : 172910,
"Orientation" : 79
},
"id" : 1
},
...



And here an example how it was in the past (first participant is me and the second an AI driver, example from pcars1):


"participants" : [
{
"attributes" : {
"RefId" : 20992,
"Name" : "M. -VIPER- Morgan",
"IsPlayer" : 1,
"GridPosition" : 1,
"VehicleId" : -1166911988,
"LiveryId" : 51,
"RacePosition" : 15,
"CurrentLap" : 0,
"CurrentSector" : 0,
"Sector1Time" : 0,
"Sector2Time" : 0,
"Sector3Time" : 0,
"LastLapTime" : 0,
"FastestLapTime" : 0,
"State" : "InGarage",
"HeadlightsOn" : 0,
"WipersOn" : 0,
"Speed" : 0,
"Gear" : 0,
"RPM" : 0,
"PositionX" : -101230,
"PositionY" : 223000,
"PositionZ" : 445100,
"Orientation" : 37
},
"id" : 0
},
{
"attributes" : {
"RefId" : 20992,
"Name" : "Eduardo S. Parreiras",
"IsPlayer" : 0,
"GridPosition" : 2,
"VehicleId" : 1884411907,
"LiveryId" : 54,
"RacePosition" : 14,
"CurrentLap" : 1,
"CurrentSector" : 1,
"Sector1Time" : 29775,
"Sector2Time" : 12718,
"Sector3Time" : 0,
"LastLapTime" : 0,
"FastestLapTime" : 0,
"State" : "Racing",
"HeadlightsOn" : 0,
"WipersOn" : 0,
"Speed" : 185,
"Gear" : 4,
"RPM" : 7627,
"PositionX" : 126110,
"PositionY" : 234080,
"PositionZ" : -477830,
"Orientation" : 265
},
"id" : 1
},
...

Pablo Medina
12-01-2018, 16:51
Thanks! We will take a look!

Dmitry Afanasyev
13-01-2018, 10:34
Few more questions about HTTP API. At some point (probably since PC1 DS) there were plans to make some player/participant/session parameters changable. According to /api/help we should be able to change session_NAME, player_NAME and participant_NAME, but this attributes currently ReadOnly. Can they be changed to ReadWrite? Maybe through LUA also?


{
"name" : "api/session/set_attributes",
"description" : "Request change of attributes from the game",
"access" : "admin",
"responsetype" : "json",
"parameters" : [
...
{
"name" : "refid",
"type" : "int",
"optional" : true,
"description" : "RefId of player to change. Used only when player attributes are included. Note that you need to run multiple calls to modify multiple players"
},
...
{
"name" : "session_NAME",
"type" : "string",
"optional" : true,
"description" : "Session attribute to set. See /api/list/attributes/session for the list of all valid attribute names and types. Only writable attributes can be set"
},
{
"name" : "player_NAME",
"type" : "string",
"optional" : true,
"description" : "Player attribute to set. Remember to also set 'refid'. See /api/list/attributes/player for the list of all valid attribute names and types. Only writable attributes can be set"
},
{
"name" : "participant_NAME",
"type" : "string",
"optional" : true,
"description" : "Participant attribute to set. Remember to also set 'participantid'. See /api/list/attributes/participant for the list of all valid attribute names and types. Only writable attributes can be set"
}
],
"response" : []
}

Another question is about some other participant attributes. Currently we can change session attributes such as GridSize, MaxPlayers, Flags and many other writable ones which will be applyed to either current or next session. But what if we will force to change some participant attributes (currently ReadOnly) such as GridPosition, VehicleId, LiveryId? Should it actually change current start position, car and it's livery for chosen player? So this will allow us to make custom grids.

Thanks in advance