From 464ea2f82b6df58ca1eefc6670632b2bc3c9ecac Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 18 Aug 2016 12:36:18 +0200 Subject: [PATCH] Use toasts for noclip and ufo --- src/Components/Modules/Command.cpp | 52 +++++++++--------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index f514621f..d510f023 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -139,68 +139,48 @@ namespace Components Command::Add("noclip", [] (Command::Params) { - if (!Game::CL_IsCgameInitialized()) + int clientNum = Game::CG_GetClientNum(); + if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client) { - Logger::Print("No game running!\n"); + Logger::Print("You are not hosting a match!\n"); + Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000); return; } + if (!Dvar::Var("sv_cheats").Get()) { Logger::Print("Cheats disabled!\n"); + Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000); return; } - int clientNum = Game::CG_GetClientNum(); - if (clientNum >= 18) - { - Logger::Print("Unable to lookup our clientnum!\n"); - return; - } - - Game::gentity_t* entity = &Game::g_entities[clientNum]; - - if (!entity->client) - { - Logger::Print("Unable to find our client info, we're probably not the host!\n"); - return; - } - - entity->client->flags ^= Game::PLAYER_FLAG_NOCLIP; + Game::g_entities[clientNum].client->flags ^= Game::PLAYER_FLAG_NOCLIP; Logger::Print("Noclip toggled\n"); + Toast::Show("cardicon_abduction", "Success", "Noclip toggled", 3000); }); Command::Add("ufo", [] (Command::Params) { - if (!Game::CL_IsCgameInitialized()) + int clientNum = Game::CG_GetClientNum(); + if (!Game::CL_IsCgameInitialized() || clientNum >= 18 || clientNum < 0 || !Game::g_entities[clientNum].client) { - Logger::Print("No game running!\n"); + Logger::Print("You are not hosting a match!\n"); + Toast::Show("cardicon_stop", "Error", "You are not hosting a match!", 3000); return; } + if (!Dvar::Var("sv_cheats").Get()) { Logger::Print("Cheats disabled!\n"); + Toast::Show("cardicon_stop", "Error", "Cheats disabled!", 3000); return; } - int clientNum = Game::CG_GetClientNum(); - if (clientNum >= 18) - { - Logger::Print("Unable to lookup our clientnum!\n"); - return; - } - - Game::gentity_t* entity = &Game::g_entities[clientNum]; - - if (!entity->client) - { - Logger::Print("Unable to find our client info, we're probably not the host!\n"); - return; - } - - entity->client->flags ^= Game::PLAYER_FLAG_UFO; + Game::g_entities[clientNum].client->flags ^= Game::PLAYER_FLAG_UFO; Logger::Print("UFO toggled\n"); + Toast::Show("cardicon_abduction", "Success", "UFO toggled", 3000); }); }