diff --git a/code/components/extra-natives-five/src/VisualSettingsNatives.cpp b/code/components/extra-natives-five/src/VisualSettingsNatives.cpp index 60b26c4d1a..b116ee7ec0 100644 --- a/code/components/extra-natives-five/src/VisualSettingsNatives.cpp +++ b/code/components/extra-natives-five/src/VisualSettingsNatives.cpp @@ -114,6 +114,25 @@ static InitFunction initFunction([]() } }); + fx::ScriptEngine::RegisterNativeHandler("GET_VISUAL_SETTING_FLOAT", [](fx::ScriptContext& context) + { + const char* settingName = context.CheckArgument(0); + auto settingHash = HashString(settingName); + + for (int i = 0; i < g_visualSettings->entries.GetCount(); ++i) + { + const VisualSettingsEntry& entry = g_visualSettings->entries[i]; + if (entry.entryHash == settingHash) + { + context.SetResult(entry.value); + return; + } + } + + std::string error = va("Visual setting '%s' doesn't exist.", settingName); + throw std::runtime_error(error); + }); + OnMainGameFrame.Connect([=]() { std::function func; diff --git a/ext/native-decls/GetVisualSettingFloat.md b/ext/native-decls/GetVisualSettingFloat.md new file mode 100644 index 0000000000..194c982ef3 --- /dev/null +++ b/ext/native-decls/GetVisualSettingFloat.md @@ -0,0 +1,17 @@ +--- +ns: CFX +apiset: client +--- +## GET_VISUAL_SETTING_FLOAT + +```c +float GET_VISUAL_SETTING_FLOAT(char* name); +``` + +A getter for [SET_VISUAL_SETTING_FLOAT](#_0xD1D31681). + +## Parameters +* **name**: The name of the value to get, such as `pedLight.color.red`. + +## Return value +Returns the floating point value of the specified visual setting on success. \ No newline at end of file