Skip to content
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
23 changes: 23 additions & 0 deletions code/components/citizen-devtools/src/ResourceTimeWarnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#ifndef IS_FXSERVER
#include <Pool.h>
#include <Streaming.h>
#else
#include <ScriptEngine.h>
#include <ScriptSerialization.h>
#endif

#include <iomanip>
Expand Down Expand Up @@ -463,6 +466,26 @@ static InitFunction initFunction([]()
}
}
}, INT32_MIN);

fx::ScriptEngine::RegisterNativeHandler("GET_RESOURCE_MONITOR_DATA", [](fx::ScriptContext& context)
{
if (gResourceMonitor.get() != nullptr)
{
auto& data = gResourceMonitor->GetResourceDatas();

std::vector<std::tuple<std::string, double, double, std::string, std::string>> arr;
for (const auto& [resourceName, avgTickMs, avgFrameFraction, memorySize, streamingUsage, recentTicks, avgTotalMs, recentTotals] : data)
{
arr.emplace_back(std::tuple(resourceName, avgTickMs, avgFrameFraction, memorySize, streamingUsage));
}

context.SetResult(fx::SerializeObject(arr));
}
else
{
context.SetResult(nullptr);
}
});
});

fx::ResourceMonitor::OnWarning.Connect([](const std::string& warningText)
Expand Down
12 changes: 12 additions & 0 deletions ext/native-decls/server/GetResourceMonitorData.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add proper structure to the documentation?

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
ns: CFX
apiset: server
---
## GET_RESOURCE_MONITOR_DATA

```c
object GET_RESOURCE_MONITOR_DATA();
```

## Return value
An array containing the resource monitor data
Loading