mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 22:36:23 +00:00
change settings to be a hash map instead of a fixed struct
this makes adding settings and changing settings incredibly easy, both from the console and from lua.
This commit is contained in:
@@ -208,56 +208,56 @@ void LuaAPI::MP::Set(int ConfigID, sol::object NewValue) {
|
||||
switch (ConfigID) {
|
||||
case 0: // debug
|
||||
if (NewValue.is<bool>()) {
|
||||
Application::Settings.DebugModeEnabled = NewValue.as<bool>();
|
||||
beammp_info(std::string("Set `Debug` to ") + (Application::Settings.DebugModeEnabled ? "true" : "false"));
|
||||
Application::SetSetting(StrDebug, NewValue.as<bool>());
|
||||
beammp_info(std::string("Set `Debug` to ") + (Application::GetSettingBool(StrDebug) ? "true" : "false"));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected boolean");
|
||||
}
|
||||
break;
|
||||
case 1: // private
|
||||
if (NewValue.is<bool>()) {
|
||||
Application::Settings.Private = NewValue.as<bool>();
|
||||
beammp_info(std::string("Set `Private` to ") + (Application::Settings.Private ? "true" : "false"));
|
||||
Application::SetSetting(StrPrivate, NewValue.as<bool>());
|
||||
beammp_info(std::string("Set `Private` to ") + (Application::GetSettingBool(StrPrivate) ? "true" : "false"));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected boolean");
|
||||
}
|
||||
break;
|
||||
case 2: // max cars
|
||||
if (NewValue.is<int>()) {
|
||||
Application::Settings.MaxCars = NewValue.as<int>();
|
||||
beammp_info(std::string("Set `MaxCars` to ") + std::to_string(Application::Settings.MaxCars));
|
||||
Application::SetSetting(StrMaxCars, NewValue.as<int>());
|
||||
beammp_info(std::string("Set `MaxCars` to ") + std::to_string(Application::GetSettingInt(StrMaxCars)));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected integer");
|
||||
}
|
||||
break;
|
||||
case 3: // max players
|
||||
if (NewValue.is<int>()) {
|
||||
Application::Settings.MaxPlayers = NewValue.as<int>();
|
||||
beammp_info(std::string("Set `MaxPlayers` to ") + std::to_string(Application::Settings.MaxPlayers));
|
||||
Application::SetSetting(StrMaxPlayers, NewValue.as<int>());
|
||||
beammp_info(std::string("Set `MaxPlayers` to ") + std::to_string(Application::GetSettingInt(StrMaxPlayers)));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected integer");
|
||||
}
|
||||
break;
|
||||
case 4: // Map
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.MapName = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Map` to ") + Application::Settings.MapName);
|
||||
Application::SetSetting(StrMap, NewValue.as<std::string>());
|
||||
beammp_info(std::string("Set `Map` to ") + Application::GetSettingString(StrMap));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected string");
|
||||
}
|
||||
break;
|
||||
case 5: // Name
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.ServerName = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Name` to ") + Application::Settings.ServerName);
|
||||
Application::SetSetting(StrName, NewValue.as<std::string>());
|
||||
beammp_info(std::string("Set `Name` to ") + Application::GetSettingString(StrName));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected string");
|
||||
}
|
||||
break;
|
||||
case 6: // Desc
|
||||
if (NewValue.is<std::string>()) {
|
||||
Application::Settings.ServerDesc = NewValue.as<std::string>();
|
||||
beammp_info(std::string("Set `Description` to ") + Application::Settings.ServerDesc);
|
||||
Application::SetSetting(StrDescription, NewValue.as<std::string>());
|
||||
beammp_info(std::string("Set `Description` to ") + Application::GetSettingString(StrDescription));
|
||||
} else {
|
||||
beammp_lua_error("set invalid argument [2] expected string");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user