Чтобы добавить активацию/деактивацию в код, вы можете использовать переменную для хранения состояния и проверять эту переменную перед запуском потока. Например, можно создать переменную active типа bool и использовать ее в качестве условия для запуска потока:
[[maybe_unused]] class loader {
public:
bool active = true;
loader() {
test.on_before += [](lemon::hook_cpu &cpu) {
auto old_mode = *reinterpret_cast<std::uint8_t *>(cpu.EAX + cpu.ESI + 0x180);
auto mode = cpu.BP;
if (old_mode == 53 && mode != 53 && active) {
std::thread([&] {
auto ped = *reinterpret_cast<std::uint32_t *>(0xB6F5F0);
if (!ped) return;
auto data = *reinterpret_cast<std::uint32_t *>(ped + 0x480);
std::this_thread::sleep_for(std::chrono::milliseconds(75));
*reinterpret_cast<bool *>(data + 0x84) = true;
std::this_thread::sleep_for(std::chrono::milliseconds(20));
*reinterpret_cast<bool *>(data + 0x84) = false;
}).detach();
}
};
test.install();
}
private:
lemon::hook<> test{ 0x0051565C };
} g_loader;
Чтобы активировать или деактивировать эту логику, вы можете просто изменить значение переменной active, установив его в true для активации или false для деактивации. Например, вы можете добавить команду в консоль, которая будет изменять значение переменной active:
void cmd_active(std::vector<std::string> args) {
if (args.size() != 1) {
console::print("Usage: active <true/false>");
return;
}
if (args[0] == "true") {
g_loader.active = true;
console::print("Active");
} else if (args[0] == "false") {
g_loader.active = false;
console::print("Deactive");
} else {
console::print("Usage: active <true/false>");
}
}
void init() {
console::add_command("active", cmd_active);
}