Improve hotkeys

This commit is contained in:
Grinch_ 2021-01-29 00:57:37 +06:00
parent 29669f7fea
commit fc7fb0c8f8
7 changed files with 25 additions and 21 deletions

View File

@ -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;
}

View File

@ -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++)
{

View File

@ -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 ")"

View File

@ -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)

View File

@ -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);

View File

@ -200,9 +200,6 @@ void Visual::Main()
if (Ui::CheckboxWithHint("Hide area names", &CHud::bScriptDontDisplayAreaName))
Command<Commands::DISPLAY_ZONE_NAMES>(!CHud::bScriptDontDisplayAreaName);
if (Ui::CheckboxWithHint("Hide hud", &CHud::m_Wants_To_Draw_Hud))
Command<Commands::DISPLAY_HUD>(!CHud::m_Wants_To_Draw_Hud);
if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName))
Command<Commands::DISPLAY_CAR_NAMES>(!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<Commands::DISPLAY_HUD>(CHud::m_Wants_To_Draw_Hud);
ImGui::Columns(1);
ImGui::EndTabItem();
}

View File

@ -100,7 +100,7 @@ struct HotKeyData
{
int key1;
int key2;
uint timer = 0;
bool is_down = false;
};
extern CJson config;