From a4c28025bc9b91fea2aa11092d00030cb49166e2 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sun, 11 Jul 2021 15:43:41 +0600 Subject: [PATCH] Fix weird glitches with hud & radar flags --- CheatMenu/Game.cpp | 20 +++++++++++++------- CheatMenu/Game.h | 4 ++-- CheatMenu/Visual.cpp | 12 +++++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CheatMenu/Game.cpp b/CheatMenu/Game.cpp index 23f9a6a..f600d31 100644 --- a/CheatMenu/Game.cpp +++ b/CheatMenu/Game.cpp @@ -135,10 +135,16 @@ Game::Game() m_Freecam::m_bEnabled = false; ClearFreecamStuff(); } - else m_Freecam::m_bEnabled = true; + else + { + m_Freecam::m_bEnabled = true; + } } + if (m_Freecam::m_bEnabled) + { FreeCam(); + } }; } @@ -167,10 +173,10 @@ void Game::FreeCam() { CPlayerPed* player = FindPlayerPed(-1); Command(0, true); - m_Freecam::m_bHudState = CHud::m_Wants_To_Draw_Hud; - m_Freecam::m_bRadarState = CHud::bScriptDontDisplayRadar; - CHud::bScriptDontDisplayRadar = true; - CHud::m_Wants_To_Draw_Hud = false; + m_Freecam::m_bHudState = patch::Get(0xBA6769); // hud + m_Freecam::m_bRadarState = patch::Get(0xBA676C); // radar + patch::Set(0xBA6769, 0); // hud + patch::Set(0xBA676C, 2); // radar CVector player_pos = player->GetPosition(); CPad::GetPad(0)->DisablePlayerControls = true; @@ -278,8 +284,8 @@ void Game::ClearFreecamStuff() { m_Freecam::m_bInitDone = false; Command(0, false); - CHud::bScriptDontDisplayRadar = m_Freecam::m_bRadarState; - CHud::m_Wants_To_Draw_Hud = m_Freecam::m_bHudState; + patch::Set(0xBA6769, m_Freecam::m_bHudState); // hud + patch::Set(0xBA676C, m_Freecam::m_bRadarState); // radar CPad::GetPad(0)->DisablePlayerControls = false; Command(m_Freecam::m_nPed); diff --git a/CheatMenu/Game.h b/CheatMenu/Game.h index e1ff570..bb5ee9e 100644 --- a/CheatMenu/Game.h +++ b/CheatMenu/Game.h @@ -25,8 +25,8 @@ public: inline static int m_nPed = -1; inline static CVector m_fMouse; inline static CVector m_fTotalMouse; - inline static bool m_bHudState; - inline static bool m_bRadarState; + inline static BYTE m_bHudState; + inline static BYTE m_bRadarState; }; struct m_HardMode { diff --git a/CheatMenu/Visual.cpp b/CheatMenu/Visual.cpp index c67f956..4001abf 100644 --- a/CheatMenu/Visual.cpp +++ b/CheatMenu/Visual.cpp @@ -213,15 +213,17 @@ void Visual::Draw() if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName)) Command(!CHud::bScriptDontDisplayVehicleName); - if (Ui::CheckboxWithHint("Hide radar", &CHud::bScriptDontDisplayRadar)) - Command(!CHud::bScriptDontDisplayRadar); - Ui::CheckboxAddressEx("Hide wanted level", 0x58DD1B, 0x90, 1); if (Ui::CheckboxWithHint("Lock weather", &m_bLockWeather)) m_nBacWeatherType = CWeather::OldWeatherType; - if (Ui::CheckboxWithHint("Show hud", &CHud::m_Wants_To_Draw_Hud)) - Command(CHud::m_Wants_To_Draw_Hud); + bool radar_state = (patch::Get(0xBA676C) != 2); + if (Ui::CheckboxWithHint("Show radar", &radar_state)) + { + patch::Set(0xBA676C, radar_state == true ? 0 : 2); + } + + Ui::CheckboxAddress("Show hud", 0xBA6769); ImGui::Columns(1); ImGui::EndTabItem();