PDA

View Full Version : Dedicated server: Failed to read sms_rotate.lua/lib_rotate.lua



Minolin
23-09-2017, 15:25
Trying to use the sms_rotate plugin my server config fails on startup:



[2017-09-23 17:18:31] INFO: HttpApi disabled
[2017-09-23 17:18:31] INFO: Loading LuaApi addon 'sms_base'...
[2017-09-23 17:18:31] INFO: Loading LuaApi addon 'sms_rotate'...
[2017-09-23 17:18:31] INFO: Loading LuaApi addon 'lib_rotate'...
[2017-09-23 17:18:31] WARNING: Lua: lua\lib_rotate\lib_rotate.lua:181: attempt to index a nil value (global 'server')
[2017-09-23 17:18:31] ERROR: Failed to read addon Lua file from 'lua\sms_rotate\sms_rotate.lua'
[2017-09-23 17:18:31] INFO: LuaApi started
[2017-09-23 17:18:31] INFO: Dedicated server is starting...


It will run, but use the server.cfg settings. I'm confused as I've seen servers that definitively run rotations, but the error message doesn't look like a configuration mistake.
This is the sms_rotate_config.json:



// Config version.
version : 7

// Default configuration.
config : {
"persist_index" : true,
"default" : {
"TrackId" : -810715843,
"VehicleClassId" : "Road E",

"PracticeLength" : 0,
"QualifyLength" : 6,
"RaceLength" : 10,

"Flags" : "ABS_ALLOWED,TCS_ALLOWED,FORCE_REALISTIC_DRIVING_AIDS,AUTO_START_ENGINE,MECHANICAL_FAILURES,TIMED_RACE,ONLINE_REPUTATION_ENABLED",
"DamageType" : "FULL",
"TireWearType" : "STANDARD",
"FuelUsageType" : "STANDARD",
"PenaltiesType" : "FULL",
"AllowedViews" : "Any",

"QualifyDateProgression" : 1,
"QualifyDateYear" : 2017,
"QualifyDateMonth" : 6,
"QualifyDateDay" : 22,
"QualifyDateHour" : 7,
"RaceDateProgression" : 1,
"RaceDateYear" : 2017,
"RaceDateMonth" : 6,
"RaceDateDay" : 22,
"RaceDateHour" : 14,

"QualifyWeatherProgression" : 1,
"QualifyWeatherSlots" : 2,
"QualifyWeatherSlot1" : "Foggy",
"QualifyWeatherSlot2" : "MediumCloud",

"QualifyWeatherProgression" : 1,
"RaceWeatherSlots" : 2,
"RaceWeatherSlot1" : "MediumCloud",
"RaceWeatherSlot2" : "LightCloud"

},

"rotation" : [
{
"QualifyWeatherSlot1" : "Foggy",
"QualifyWeatherSlot2" : "MediumCloud",
"RaceWeatherSlot1" : "MediumCloud",
"RaceWeatherSlot2" : "LightCloud"
},
{
"QualifyWeatherSlot1" : "MediumCloud",
"QualifyWeatherSlot2" : "Overcast",
"RaceWeatherSlot1" : "MediumCloud",
"RaceWeatherSlot2" : "LightCloud"
},
{
"QualifyWeatherSlot1" : "LightRain",
"QualifyWeatherSlot2" : "MediumCloud",
"RaceWeatherSlot1" : "MediumCloud",
"RaceWeatherSlot2" : "HeavyCloud"
}, {
"QualifyWeatherSlot1" : "Clear",
"QualifyWeatherSlot2" : "LightCloud",
"RaceWeatherSlot1" : "LightCloud",
"RaceWeatherSlot2" : "MediumCloud",
}
]
}


Thanks for any help

Visceral_Syn
23-09-2017, 17:59
First thing i noticed, is you have track rotation configured, but no tracks defined. try adding a "TrackId" : "Mazda Raceway Laguna Seca", or whatever trackID you want to use to each one of those sections you have in rotation.

Minolin
23-09-2017, 18:02
I have "TrackId" : -810715843 in the "default" config. I understood the rotation attributes override the default ones, is this wrong?

Edit: Adding individual TrackIds to the rotations doesn't remove the .lua error. But thanks for the guess

patycy
24-09-2017, 09:01
I have "TrackId" : -810715843 in the "default" config. I understood the rotation attributes override the default ones, is this wrong?

Edit: Adding individual TrackIds to the rotations doesn't remove the .lua error. But thanks for the guess

I think you need to add TrackIds for every rotation config you have.

Minolin
24-09-2017, 14:12
I did, doesn't change the .lua error message

Visceral_Syn
24-09-2017, 14:16
Have you made changes to the sms_rotate document, and not deleted the one in the lua_config folder which an output file? If you make changes to the document, in the lua folder, but not delete the output document in the lua_config folder, the server reads the one in the lua_config folder, if there is no document there, then it parses the one you have edited in the lua folder. Woof... confused myself...

Minolin
24-09-2017, 14:30
My only changes are
a) copied the ./config_sample/server.cfg to ./server.cfg
b) edited server.cfg to my needs
c) edited the ./lua_config/sms_rotate_config.json

I understand the ./lua folder as "binary" where we must not fiddle around. According to the ./lua_config/readme.txt the luaConfigRoot defaults to ./lua_config, where my updated file is placed.

Minolin
24-09-2017, 15:44
Having a look at the lua code, it looks like lib_rotate.lua uses not initialized global variables server (and also session below):



-- Estimate the grid size. Note that while the session is not running, this is not reliable. But it's a good upper limit.
local grid_size = 32 -- current the game will never ask for more than this
if server.max_player_count > 0 and server.max_player_count < grid_size then grid_size = server.max_player_count end
if session.max_member_count > 0 and session.max_member_count < grid_size then grid_size = session.max_member_count end


I couldn't find a piece of code where those globals are initialized. Looks like the sms_rotate.lua creates a new object in line 26, but both server and session aren't assigned in sms_rotate.lua, lib_rotate.lua or sms_base.lua. Actually I have no clue about lua and might be wrong. Probably parts of the init is done inside the dedicated server process.

Visceral_Syn
24-09-2017, 15:50
In the old pCars server, if sms_rotate is configured it overrode the server.cfg, however I remember where if something is not in the server.cfg it won't configurable in sms_rotate. I faintly remember reading in the obfuscated pdf on using the scripts

Minolin
24-09-2017, 16:11
Finally found the problem: You MUST NOT define a TrackId in the config.default object, otherwise the server/session globals aren't initialized.
So I finally have a server that might run the sms_rotate, and my last problem left is that it still shows up broken in the client's server list (and it fills the slots with AIs):



http://forum.projectcarsgame.com/showthread.php?51949-Dedicated-Server-configuration

Visceral_Syn
24-09-2017, 18:11
OK, I got the sms_rotate to work, however am also stuck at how to enable multi-classes. It keeps poopin an error saying the value is invalid, I tried using the class name, and the value. Both spat out an error...