diff --git a/src/CheatMenu.h b/src/CheatMenu.h index 8653efc..7e567f7 100644 --- a/src/CheatMenu.h +++ b/src/CheatMenu.h @@ -45,7 +45,7 @@ public: launch = false; } - if (GetModuleHandleA("SAMP.dll")) { + if (IsPluginInstalled("SAMP.dll")) { MessageBox(HWND_DESKTOP, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); launch = false; } @@ -55,7 +55,7 @@ public: Should have a better fix for this but everyone should have SilentPatch installed so mehh... */ - if (!GetModuleHandleA("SilentPatchSA.asi")) { + if (!IsPluginInstalled("SilentPatchSA.asi")) { MessageBox(HWND_DESKTOP, "SilentPatch isn't installed. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); launch = false; } diff --git a/src/Game.cpp b/src/Game.cpp index 7600889..63eeed7 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -149,7 +149,7 @@ Game::Game() if (random_cheats::enable && (timer - random_cheats::timer) > (uint(random_cheats::enable_wait_time)*1000)) { - int id = rand() % 92; + int id = Random(0,91); for (int i = 0; i < 92; i++) { diff --git a/src/MenuInfo.h b/src/MenuInfo.h index 433668d..6d3aaea 100644 --- a/src/MenuInfo.h +++ b/src/MenuInfo.h @@ -1,5 +1,5 @@ #pragma once #define MENU_NAME "Cheat Menu" #define MENU_VERSION "2.6-beta" -#define BUILD_NUMBER "20210125" +#define BUILD_NUMBER "20210129" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/src/Ui.cpp b/src/Ui.cpp index 59de81a..63e0eb0 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -853,13 +853,17 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data) bool Ui::HotKeyPressed(HotKeyData& hotkey) { - if (CTimer::m_snTimeInMilliseconds - hotkey.timer > 150*CTimer::ms_fTimeScale) - { - hotkey.timer = CTimer::m_snTimeInMilliseconds; - return current_hotkey == "" && KeyPressed(hotkey.key1) && KeyPressed(hotkey.key2); - } + if (KeyPressed(hotkey.key1) && KeyPressed(hotkey.key2)) + hotkey.is_down = true; else - return false; + { + if (hotkey.is_down) + { + hotkey.is_down = false; + return current_hotkey == ""; + } + } + return false; } std::string Ui::GetHotKeyNameString(HotKeyData& hotkey) diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index 62a68ca..a0d90b0 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -165,16 +165,16 @@ Vehicle::Vehicle() int chance = 0; if (veh->m_nVehicleClass == CLASS_NORMAL) // Normal - chance = rand() % 21 + 1; + chance = Random(1,20); if (veh->m_nVehicleClass == CLASS_RICHFAMILY) // Rich family - chance = rand() % 5 + 1; + chance = Random(1,4); if (veh->m_nVehicleClass == CLASS_EXECUTIVE) // Executive - chance = rand() % 3 + 1; + chance = Random(1,3); if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != player) - InstallNeon(veh, rand() % 255, rand() % 255, rand() % 255); + InstallNeon(veh, Random(0,255), Random(0,255), Random(0,255)); } neon::traffic_timer = timer; } @@ -264,7 +264,7 @@ int Vehicle::GetRandomTrainIdForModel(int model) CHud::SetHelpMessage("Invalid train model", false, false, false); return -1; } - int id = rand() % (_end + 1 - _start) + _start; + int id = Random(_start,_end); return train_ids[id]; } @@ -472,9 +472,9 @@ void Vehicle::SpawnVehicle(std::string &smodel) CTrain *train = nullptr; CTrain *carraige = nullptr; - int track = rand() % 2; + int track = Random(0,1); int node = CTrain::FindClosestTrackNode(pos,&track); - CTrain::CreateMissionTrain(pos,(rand() % 2) == 1 ? true : false,train_id,&train,&carraige,node,track,false); + CTrain::CreateMissionTrain(pos,(Random(0,1)) == 1 ? true : false,train_id,&train,&carraige,node,track,false); veh = (CVehicle*)train; hveh = CPools::GetVehicleRef(veh); diff --git a/src/Visual.cpp b/src/Visual.cpp index 24816ee..db9997c 100644 --- a/src/Visual.cpp +++ b/src/Visual.cpp @@ -200,9 +200,6 @@ void Visual::Main() if (Ui::CheckboxWithHint("Hide area names", &CHud::bScriptDontDisplayAreaName)) Command(!CHud::bScriptDontDisplayAreaName); - if (Ui::CheckboxWithHint("Hide hud", &CHud::m_Wants_To_Draw_Hud)) - Command(!CHud::m_Wants_To_Draw_Hud); - if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName)) Command(!CHud::bScriptDontDisplayVehicleName); @@ -213,6 +210,9 @@ void Visual::Main() if (Ui::CheckboxWithHint("Lock weather", &lock_weather)) weather_type_backup = CWeather::OldWeatherType; + if (Ui::CheckboxWithHint("Show hud", &CHud::m_Wants_To_Draw_Hud)) + Command(CHud::m_Wants_To_Draw_Hud); + ImGui::Columns(1); ImGui::EndTabItem(); } diff --git a/src/pch.h b/src/pch.h index 2f954ef..5b1d705 100644 --- a/src/pch.h +++ b/src/pch.h @@ -100,7 +100,7 @@ struct HotKeyData { int key1; int key2; - uint timer = 0; + bool is_down = false; }; extern CJson config;