Skip to content

Commit 4d357d8

Browse files
committed
refactor: BEAMMP_PROVIDER_DISABLE_MP_SET environment variable
1 parent 02fd30d commit 4d357d8

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/LuaAPI.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,28 @@ std::pair<bool, std::string> LuaAPI::MP::RemoveVehicle(int PID, int VID) {
307307
return Result;
308308
}
309309

310-
void LuaAPI::MP::Set(int ConfigID, sol::object NewValue) {
310+
static bool mDisableMPSet = [] {
311311
auto DisableMPSet = Env::Get(Env::Key::PROVIDER_DISABLE_MP_SET).value_or("false");
312-
bool mDisableMPSet = DisableMPSet == "true" || DisableMPSet == "1";
312+
return DisableMPSet == "true" || DisableMPSet == "1";
313+
}();
314+
315+
static auto GetSettingName = [](int id) -> const char* {
316+
switch (id) {
317+
case 0: return "Debug";
318+
case 1: return "Private";
319+
case 2: return "MaxCars";
320+
case 3: return "MaxPlayers";
321+
case 4: return "Map";
322+
case 5: return "Name";
323+
case 6: return "Description";
324+
case 7: return "InformationPacket";
325+
default: return "Unknown";
326+
}
327+
};
328+
329+
void LuaAPI::MP::Set(int ConfigID, sol::object NewValue) {
313330
if (mDisableMPSet) {
314-
beammp_info("This feature has been disabled by your server provider.");
331+
beammp_lua_errorf("A script tried to call MP.Set to change setting '{}' but this was blocked by your server provider.", GetSettingName(ConfigID));
315332
return;
316333
}
317334

0 commit comments

Comments
 (0)