bool airbrake_switch_pressed() { bool result = IsKeyJustUp(KeyConfig::KEY_TOGGLE_AIRBRAKE) || IsControllerButtonJustUp(KeyConfig::KEY_TOGGLE_AIRBRAKE); if (result) { //avoid repeat of key press DWORD maxTickCount = GetTickCount() + 200; do { UpdateXInputControlState(); WAIT(0); } while (GetTickCount() < maxTickCount); } return result; }
bool trainer_switch_pressed() { bool result = IsKeyJustUp(KeyConfig::KEY_TOGGLE_MAIN_MENU) || IsControllerButtonJustUp(KeyConfig::KEY_TOGGLE_MAIN_MENU); if (result) { //avoid repeat of key press DWORD maxTickCount = GetTickCount() + 200; do { UpdateXInputControlState(); make_periodic_feature_call(); WAIT(0); } while (GetTickCount() < maxTickCount); } return result; }
// Updates all features that can be turned off by the game, being called each game frame void update_features() { /*int* gp = reinterpret_cast<int *>(getGlobalPtr(0x1801D9)); *gp = 1; gp = reinterpret_cast<int *>(getGlobalPtr(0x187385 + 0x10F18)); *gp = 1; gp = reinterpret_cast<int *>(getGlobalPtr(0x250FDB + 0xf158D)); *gp = 0; int* gp = reinterpret_cast<int *>(getGlobalPtr(0x42CA + 0x9)); *gp = 0xFF; */ everInitialised = true; game_frame_num++; if (game_frame_num >= 100000) { game_frame_num = 0; } if (game_frame_num % 1000 == 0) { DWORD myThreadID; HANDLE myHandle = CreateThread(0, 0, save_settings_thread, 0, 0, &myThreadID); CloseHandle(myHandle); } UpdateXInputControlState(); check_for_hotkey_presses(); if (is_menu_showing() || is_in_airbrake_mode()) { if (is_input_blocked_in_menu() || is_in_airbrake_mode()) { setGameInputToEnabled(false); } else { setGameInputToEnabled(true); } } else { setGameInputToEnabled(true); } if (is_in_airbrake_mode()) { setAirbrakeRelatedInputToBlocked(true); } else { setAirbrakeRelatedInputToBlocked(false); } update_centre_screen_status_text(); update_vehicle_guns(); update_world_features(); check_player_model(); //debug_native_investigation(); // common variables Player player = PLAYER::PLAYER_ID(); Ped playerPed = PLAYER::PLAYER_PED_ID(); BOOL bPlayerExists = ENTITY::DOES_ENTITY_EXIST(playerPed); //PLAYER::DISABLE_PLAYER_FIRING(playerPed, TRUE); // player invincible if (featurePlayerInvincibleUpdated) { if (bPlayerExists && !featurePlayerInvincible) PLAYER::SET_PLAYER_INVINCIBLE(player, FALSE); featurePlayerInvincibleUpdated = false; } if (featurePlayerInvincible) { if (bPlayerExists) PLAYER::SET_PLAYER_INVINCIBLE(player, TRUE); } //Wanted Level Frozen - prevents stars increasing/decreasing if (featureWantedLevelFrozen) { if (featureWantedLevelFrozenUpdated) { frozenWantedLevel = PLAYER::GET_PLAYER_WANTED_LEVEL(player); PLAYER::SET_MAX_WANTED_LEVEL(frozenWantedLevel); featureWantedLevelFrozenUpdated = false; if (frozenWantedLevel > 0) { std::stringstream ss; ss << "Wanted Level Frozen at: " << frozenWantedLevel << " Star"; if (frozenWantedLevel > 1){ ss << "s"; } set_status_text(ss.str()); } } if (frozenWantedLevel > 0) { if (bPlayerExists) { PLAYER::SET_PLAYER_WANTED_LEVEL(player, frozenWantedLevel, 0); PLAYER::SET_PLAYER_WANTED_LEVEL_NOW(player, 0); } } else { featureWantedLevelFrozen = false; set_status_text("You must have a Wanted Level first."); } } if (featureWantedLevelFrozenUpdated) { if (!featureWantedLevelFrozen) { set_status_text("Wanted Level Unfrozen"); PLAYER::SET_MAX_WANTED_LEVEL(5); } featureWantedLevelFrozenUpdated = false; } // player never wanted if (featurePlayerNeverWanted) { if (bPlayerExists) { PLAYER::CLEAR_PLAYER_WANTED_LEVEL(player); PLAYER::SET_MAX_WANTED_LEVEL(0); } } else if (featurePlayerNeverWantedUpdated) { PLAYER::SET_MAX_WANTED_LEVEL(5); } // police ignore player if (featurePlayerIgnoredByPolice) { if (bPlayerExists) { PLAYER::SET_POLICE_IGNORE_PLAYER(player, true); } } else if (featurePlayerIgnoredByPoliceUpdated) { if (bPlayerExists) { PLAYER::SET_POLICE_IGNORE_PLAYER(player, false); } featurePlayerIgnoredByPoliceUpdated = false; } // everyone ignores player if (featurePlayerIgnoredByAll) { update_nearby_peds(playerPed, 50); if (bPlayerExists) { PLAYER::SET_POLICE_IGNORE_PLAYER(player, true); PLAYER::SET_EVERYONE_IGNORE_PLAYER(player, true); PLAYER::SET_PLAYER_CAN_BE_HASSLED_BY_GANGS(player, false); PLAYER::SET_IGNORE_LOW_PRIORITY_SHOCKING_EVENTS(player, true); if (game_frame_num % 5 == 0) { set_all_nearby_peds_to_calm(); } } } else if (featurePlayerIgnoredByAllUpdated) { if (bPlayerExists) { PLAYER::SET_POLICE_IGNORE_PLAYER(player, featurePlayerIgnoredByPolice); PLAYER::SET_EVERYONE_IGNORE_PLAYER(player, false); PLAYER::SET_PLAYER_CAN_BE_HASSLED_BY_GANGS(player, true); PLAYER::SET_IGNORE_LOW_PRIORITY_SHOCKING_EVENTS(player, false); } featurePlayerIgnoredByAllUpdated = false; } // player special ability if (featurePlayerUnlimitedAbility) { if (bPlayerExists) PLAYER::_RECHARGE_SPECIAL_ABILITY(player, 1); } // player no noise if (featurePlayerNoNoiseUpdated) { if (bPlayerExists && !featurePlayerNoNoise) PLAYER::SET_PLAYER_NOISE_MULTIPLIER(player, 1.0); featurePlayerNoNoiseUpdated = false; } if (featurePlayerNoNoise) PLAYER::SET_PLAYER_NOISE_MULTIPLIER(player, 0.0); // player fast swim if (featurePlayerFastSwimUpdated) { if (bPlayerExists && !featurePlayerFastSwim) PLAYER::_SET_SWIM_SPEED_MULTIPLIER(player, 1.0); featurePlayerFastSwimUpdated = false; } if (featurePlayerFastSwim) PLAYER::_SET_SWIM_SPEED_MULTIPLIER(player, 1.49); // player fast run if (featurePlayerFastRunUpdated) { if (bPlayerExists && !featurePlayerFastRun) PLAYER::_SET_MOVE_SPEED_MULTIPLIER(player, 1.0); featurePlayerFastRunUpdated = false; } if (featurePlayerFastRun) PLAYER::_SET_MOVE_SPEED_MULTIPLIER(player, 1.49); // player super jump if (featurePlayerSuperJump) { if (bPlayerExists) GAMEPLAY::SET_SUPER_JUMP_THIS_FRAME(player); } //Player Invisible if (featurePlayerInvisibleUpdated) { featurePlayerInvisibleUpdated = false; if (bPlayerExists && featurePlayerInvisible) ENTITY::SET_ENTITY_VISIBLE(playerPed, false); else if (bPlayerExists){ ENTITY::SET_ENTITY_VISIBLE(playerPed, true); } } if (featurePlayerDrunkUpdated) { featurePlayerDrunkUpdated = false; if (featurePlayerDrunk) { STREAMING::REQUEST_ANIM_SET((char*)CLIPSET_DRUNK); while (!STREAMING::HAS_ANIM_SET_LOADED((char*)CLIPSET_DRUNK)) { make_periodic_feature_call(); WAIT(0); } PED::SET_PED_MOVEMENT_CLIPSET(playerPed, (char*)CLIPSET_DRUNK, 1.0f); CAM::SHAKE_GAMEPLAY_CAM("DRUNK_SHAKE", 1.0f); } else { PED::RESET_PED_MOVEMENT_CLIPSET(playerPed, 1.0f); CAM::STOP_GAMEPLAY_CAM_SHAKING(true); } AUDIO::SET_PED_IS_DRUNK(playerPed, featurePlayerDrunk); } update_weapon_features(bPlayerExists, player); update_vehicle_features(bPlayerExists, playerPed); update_misc_features(bPlayerExists, playerPed); update_time_features(player); //Disable airbrake on death if (ENTITY::IS_ENTITY_DEAD(playerPed)) { exit_airbrake_menu_if_showing(); } //----Hotkeys---- //Move through door (use '-key) //Pushes player through solid door objects. if (bPlayerExists) { bool throughDoorPressed = IsKeyJustUp(KeyConfig::KEY_HOT_AIRBRAKE_THROUGH_DOOR) || IsControllerButtonJustUp(KeyConfig::KEY_HOT_AIRBRAKE_THROUGH_DOOR); //bool disablePolicePressed = IsKeyJustUp(VK_OEM_6); if (throughDoorPressed) { moveThroughDoor(); } } }