From 590804506af60625b49181674b2777da6174394f Mon Sep 17 00:00:00 2001 From: Diavolo Date: Thu, 11 Aug 2022 23:13:04 +0200 Subject: [PATCH] basic sv_cheats --- src/module/client_command.cpp | 11 ++++++++++- src/module/command.cpp | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/module/client_command.cpp b/src/module/client_command.cpp index cf00786..459b689 100644 --- a/src/module/client_command.cpp +++ b/src/module/client_command.cpp @@ -6,6 +6,8 @@ #include "command.hpp" #include "scheduler.hpp" +static const game::native::dvar_t* g_cheats; + class client_command final : public module { public: @@ -13,14 +15,21 @@ public: { if (game::is_mp()) { + g_cheats = game::native::Dvar_RegisterBool("sv_cheats", true, game::native::DVAR_CODINFO, "Enable cheats"); add_mp_client_commands(); } } private: - // I know this is supposed to check sv_cheats but it's not even a registered dvar so why bother static bool cheats_ok(game::native::gentity_s* ent) { + if (!g_cheats->current.enabled) + { + game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE, + utils::string::va("%c \"GAME_CHEATSNOTENABLED\"", 0x65)); + return false; + } + if (ent->health < 1) { game::native::mp::SV_GameSendServerCommand(ent->s.number, game::native::SV_CMD_CAN_IGNORE, diff --git a/src/module/command.cpp b/src/module/command.cpp index 6639d9c..b5cff57 100644 --- a/src/module/command.cpp +++ b/src/module/command.cpp @@ -330,7 +330,7 @@ void command::add_sp_commands() assert(ent->s.eType == game::native::ET_PLAYER); assert(ent->client); - game::native::vec3_t origin, angles{ 0.f, 0.f, 0.f }; + game::native::vec3_t origin, angles{0.f, 0.f, 0.f}; if (params.size() < 4 || params.size() > 6) {