feat: add is_host check to getinfo

This commit is contained in:
Lierrmm 2023-02-27 11:32:29 +00:00
parent 7d4f89b264
commit c3386b5258
3 changed files with 20 additions and 6 deletions

View File

@ -8,6 +8,7 @@
#include <utils/string.hpp> #include <utils/string.hpp>
#include <game/game.hpp> #include <game/game.hpp>
#include "getinfo.hpp"
namespace bots namespace bots
{ {
@ -126,14 +127,10 @@ namespace bots
command::add("spawnBot", [](const command::params& params) command::add("spawnBot", [](const command::params& params)
{ {
if (!game::is_server()) if (!getinfo::is_host())
{
const auto client_states = *reinterpret_cast<uint64_t*>(0x1576FB318_g);
if (!client_states)
{ {
return; return;
} }
}
size_t count = 1; size_t count = 1;
if (params.size() > 1) if (params.size() > 1)

View File

@ -78,6 +78,22 @@ namespace getinfo
return (rand() % 2) + 1; return (rand() % 2) + 1;
} }
bool is_host()
{
if (game::is_server())
{
return true;
}
const auto client_states = *reinterpret_cast<uint64_t*>(0x1576FB318_g);
if (!client_states)
{
return false;
}
return true;
}
struct component final : generic_component struct component final : generic_component
{ {
void post_unpack() override void post_unpack() override

View File

@ -5,4 +5,5 @@ namespace getinfo
int get_max_client_count(); int get_max_client_count();
int get_client_count(); int get_client_count();
int get_bot_count(); int get_bot_count();
bool is_host();
} }