diff --git a/src/game/features/world/TimeControl.cpp b/src/game/features/world/TimeControl.cpp new file mode 100644 index 0000000..aab26c1 --- /dev/null +++ b/src/game/features/world/TimeControl.cpp @@ -0,0 +1,44 @@ +#include "core/commands/Command.hpp" +#include "core/commands/IntCommand.hpp" +#include "core/commands/LoopedCommand.hpp" +#include "game/gta/Natives.hpp" + +namespace YimMenu::Features +{ + static IntCommand _NetworkTimeHour{"networktimehour", "Hour", "Set hour (0–23)", 0, 23, 12}; + static IntCommand _NetworkTimeMinute{"networktimeminute", "Minute", "Set minute (0–59)", 0, 59, 0}; + static IntCommand _NetworkTimeSecond{"networktimesecond", "Second", "Set second (0–59)", 0, 59, 0}; + + + class SetNetworkTime : public Command + { + using Command::Command; + + virtual void OnCall() override + { + NETWORK::NETWORK_OVERRIDE_CLOCK_TIME(_NetworkTimeHour.GetState(), + _NetworkTimeMinute.GetState(), + _NetworkTimeSecond.GetState()); + } + }; + + class FreezeNetworkTime : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override + { + NETWORK::NETWORK_OVERRIDE_CLOCK_TIME(_NetworkTimeHour.GetState(), + _NetworkTimeMinute.GetState(), + _NetworkTimeSecond.GetState()); + } + + virtual void OnDisable() override + { + NETWORK::NETWORK_CLEAR_CLOCK_TIME_OVERRIDE(); + } + }; + + static SetNetworkTime _SetTime{"setnetworktime", "Set Time", "Sets the current online time"}; + static FreezeNetworkTime _FreezeTime{"freezenetworktime", "Freeze Time", "Freezes the online clock at the selected time"}; +} diff --git a/src/game/frontend/submenus/World.cpp b/src/game/frontend/submenus/World.cpp index 08fdad5..fe93c78 100644 --- a/src/game/frontend/submenus/World.cpp +++ b/src/game/frontend/submenus/World.cpp @@ -27,6 +27,15 @@ namespace YimMenu::Submenus weatherOpts->AddItem(std::make_shared("forceweather"_J, std::make_shared("setweather"_J), true)); weatherOpts->AddItem(std::make_shared("forceweather"_J)); + auto timeGroup = std::make_shared("Time Control"); + + timeGroup->AddItem(std::make_shared("networktimehour"_J, "Hour")); + timeGroup->AddItem(std::make_shared("networktimeminute"_J, "Minute")); + timeGroup->AddItem(std::make_shared("networktimesecond"_J, "Second")); + + timeGroup->AddItem(std::make_shared("setnetworktime"_J, "Set")); + timeGroup->AddItem(std::make_shared("freezenetworktime"_J, "Freeze")); + auto otherOpts = std::make_shared("Other", 1); otherOpts->AddItem(std::make_shared("pedsignore"_J)); otherOpts->AddItem(std::make_shared("PedRiotMode"_J)); @@ -37,6 +46,7 @@ namespace YimMenu::Submenus main->AddItem(std::move(bringOpts)); main->AddItem(std::move(weatherOpts)); main->AddItem(std::move(otherOpts)); + main->AddItem(timeGroup); auto spawnVehicle = std::make_shared("Vehicle"); spawnVehicle->AddItem(std::make_shared("vehmodelname"_J));