Skip to content

Commit

Permalink
feat(extra-natives/five): visual settings getter native
Browse files Browse the repository at this point in the history
  • Loading branch information
d22tny committed Nov 20, 2024
1 parent 8a6a363 commit 7cbf688
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions code/components/extra-natives-five/src/VisualSettingsNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ static InitFunction initFunction([]()
}
});

fx::ScriptEngine::RegisterNativeHandler("GET_VISUAL_SETTING_FLOAT", [](fx::ScriptContext& context)
{
const char* settingName = context.CheckArgument<const char*>(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<float>(entry.value);
return;
}
}

std::string error = va("Visual setting '%s' doesn't exist.", settingName);
throw std::runtime_error(error);
});

OnMainGameFrame.Connect([=]()
{
std::function<void()> func;
Expand Down
17 changes: 17 additions & 0 deletions ext/native-decls/GetVisualSettingFloat.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 7cbf688

Please sign in to comment.