Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extra-natives/five): visual settings getter native #2951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading