View Full Version : Confused With SetNextSessionAttributes

02-10-2017, 19:41
I'm working on an addon and I need to make use of SetNextSessionAttributes, however I can't seem to figure out what the proper use of this should look like. The guide just arbitrarily says "attributes".

Is it a JSON string similar to the config for the sms_rotate addon? Or is it a Lua table? If I use this function, does it default attributes that are left out? For example if I don't provide a DamageType parameter - will it be reset to the default value?

I've been looking at the lib_rotate addon a bit, but it uses metatables which are the bane of my existence.

Also, is there a way to get the current number of players in the session? I'm a bit worried things will go all wonky if I set a map that has a starting grid of let's say 20 but there's 32 players on the server. :rolleyes:


Figured it out by trial and error, if anyone else gets stuck on this - here's how to work it with it for future reference;

local setupAttributes = {
-- Generated Session Setup
TrackId = randomTrack[2],
VehicleClassId = randomClass[1],
Flags = -1714683208,
ServerControlsVehicleClass = 1,
ServerControlsVehicle = 0,
-- Default Generic Session Settings
PracticeLength = 10,
QualifyLength = 10,
RaceLength = lapCount

On a side-note, if the attributes aren't set and you're trying to do it on an empty dedicated server. Use SetNextSessionAttributes instead of SetSessionAttributes. As the former will apply once the first player has connected. :rolleyes: