VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
NetChannel.cpp
Go to the documentation of this file.
4#include <inetchannelinfo.h>
5#include <string>
6
7namespace VoltMod
8{
9
11{
12 auto* engine = IsValidSlot(slot) ? _interfaces.Engine : nullptr;
13 return engine ? engine->GetPlayerNetInfo(CPlayerSlot(slot)) : nullptr;
14}
15
17{
18 auto* info = GetNetInfo(slot);
19 return info ? info->GetEngineLatency() : 0.0f;
20}
21
22std::string_view NetChannels::GetUserInfoCvar(int slot, std::string_view name) const
23{
24 auto* engine = IsValidSlot(slot) ? _interfaces.Engine : nullptr;
25 if (!engine || name.empty())
26 {
27 return {};
28 }
29
30 const char* value = engine->GetClientConVarValue(CPlayerSlot(slot), std::string(name).c_str());
31 return value ? std::string_view(value) : std::string_view{};
32}
33
34} // namespace VoltMod
std::string_view GetUserInfoCvar(int slot, std::string_view name) const
float EngineLatency(int slot) const
INetChannelInfo * GetNetInfo(int slot) const
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
constexpr bool IsValidSlot(int slot)
Definition Slot.hpp:13
IVEngineServer2 * Engine