From 2b7dd50711f50efe35d478c4e8b07c29fe852457 Mon Sep 17 00:00:00 2001 From: Brentdevent Date: Wed, 25 Aug 2021 18:29:02 +0200 Subject: [PATCH 1/3] added notarget command --- src/client/component/command.cpp | 37 ++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index de54fd9..8784e35 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -430,6 +430,20 @@ namespace command : "^1off")); }); + add("notarget", []() + { + if (!game::SV_Loaded()) + { + return; + } + + game::sp::g_entities[0].flags ^= 4; + game::CG_GameMessage(0, utils::string::va("notarget %s", + game::sp::g_entities[0].flags & 4 + ? "^2on" + : "^1off")); + }); + add("noclip", []() { if (!game::SV_Loaded()) @@ -452,8 +466,10 @@ namespace command } game::sp::g_entities[0].client->flags ^= 2; - game::CG_GameMessage( - 0, utils::string::va("ufo %s", game::sp::g_entities[0].client->flags & 2 ? "^2on" : "^1off")); + game::CG_GameMessage(0, utils::string::va("ufo %s", + game::sp::g_entities[0].client->flags & 2 + ? "^2on" + : "^1off")); }); add("give", [](const params& params) @@ -524,6 +540,23 @@ namespace command : "^1off")); }); + add_sv("notarget", [](const int client_num, const params_sv&) + { + if (!game::Dvar_FindVar("sv_cheats")->current.enabled) + { + game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, + "f \"Cheats are not enabled on this server\""); + return; + } + + game::mp::g_entities[client_num].flags ^= 4; + game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, + utils::string::va("f \"notarget %s\"", + game::mp::g_entities[client_num].flags & 4 + ? "^2on" + : "^1off")); + }); + add_sv("demigod", [](const int client_num, const params_sv&) { if (!game::Dvar_FindVar("sv_cheats")->current.enabled) From d5bcb3d22f7f83e339962aeba65306301f63627d Mon Sep 17 00:00:00 2001 From: Brentdevent Date: Wed, 25 Aug 2021 18:44:02 +0200 Subject: [PATCH 2/3] small refactor --- src/client/component/command.cpp | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 8784e35..6426ccb 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -540,23 +540,6 @@ namespace command : "^1off")); }); - add_sv("notarget", [](const int client_num, const params_sv&) - { - if (!game::Dvar_FindVar("sv_cheats")->current.enabled) - { - game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, - "f \"Cheats are not enabled on this server\""); - return; - } - - game::mp::g_entities[client_num].flags ^= 4; - game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, - utils::string::va("f \"notarget %s\"", - game::mp::g_entities[client_num].flags & 4 - ? "^2on" - : "^1off")); - }); - add_sv("demigod", [](const int client_num, const params_sv&) { if (!game::Dvar_FindVar("sv_cheats")->current.enabled) @@ -574,6 +557,23 @@ namespace command : "^1off")); }); + add_sv("notarget", [](const int client_num, const params_sv&) + { + if (!game::Dvar_FindVar("sv_cheats")->current.enabled) + { + game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, + "f \"Cheats are not enabled on this server\""); + return; + } + + game::mp::g_entities[client_num].flags ^= 4; + game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, + utils::string::va("f \"notarget %s\"", + game::mp::g_entities[client_num].flags & 4 + ? "^2on" + : "^1off")); + }); + add_sv("noclip", [](const int client_num, const params_sv&) { if (!game::Dvar_FindVar("sv_cheats")->current.enabled) From 065bdf1a1804e3198610fd2f5fd0bb4c4e5027b8 Mon Sep 17 00:00:00 2001 From: Brentdevent Date: Wed, 25 Aug 2021 19:29:01 +0200 Subject: [PATCH 3/3] fix indentation --- src/client/component/command.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 6426ccb..e88e05c 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -439,7 +439,7 @@ namespace command game::sp::g_entities[0].flags ^= 4; game::CG_GameMessage(0, utils::string::va("notarget %s", - game::sp::g_entities[0].flags & 4 + game::sp::g_entities[0].flags & 4 ? "^2on" : "^1off")); }); @@ -467,7 +467,7 @@ namespace command game::sp::g_entities[0].client->flags ^= 2; game::CG_GameMessage(0, utils::string::va("ufo %s", - game::sp::g_entities[0].client->flags & 2 + game::sp::g_entities[0].client->flags & 2 ? "^2on" : "^1off")); }); @@ -562,16 +562,16 @@ namespace command if (!game::Dvar_FindVar("sv_cheats")->current.enabled) { game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, - "f \"Cheats are not enabled on this server\""); + "f \"Cheats are not enabled on this server\""); return; } game::mp::g_entities[client_num].flags ^= 4; - game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, - utils::string::va("f \"notarget %s\"", - game::mp::g_entities[client_num].flags & 4 - ? "^2on" - : "^1off")); + game::SV_GameSendServerCommand(client_num, game::SV_CMD_RELIABLE, + utils::string::va("f \"notarget %s\"", + game::mp::g_entities[client_num].flags & 4 + ? "^2on" + : "^1off")); }); add_sv("noclip", [](const int client_num, const params_sv&)