diff --git a/src/game/features/teleport/TpToWaypoint.cpp b/src/game/features/teleport/TpToWaypoint.cpp index 22692cc..d6bb1d9 100644 --- a/src/game/features/teleport/TpToWaypoint.cpp +++ b/src/game/features/teleport/TpToWaypoint.cpp @@ -1,4 +1,6 @@ #include "core/commands/Command.hpp" +#include "core/commands/LoopedCommand.hpp" +#include "core/backend/FiberPool.hpp" #include "core/backend/ScriptMgr.hpp" #include "game/backend/Self.hpp" #include "game/gta/Natives.hpp" @@ -57,5 +59,29 @@ namespace YimMenu::Features } }; + class AutoTpToWaypoint : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override + { + if (!Self::GetPed()) + return; + + if (HUD::IS_WAYPOINT_ACTIVE()) + { + auto coords = HUD::GET_BLIP_COORDS(HUD::GET_CLOSEST_BLIP_INFO_ID(HUD::GET_WAYPOINT_BLIP_ENUM_ID())); + FiberPool::Push([coords] { + auto new_coords{coords}; + ResolveZCoordinate(new_coords); + Self::GetPed().TeleportTo(new_coords); + ScriptMgr::Yield(); + }); + HUD::SET_WAYPOINT_OFF(); + } + } + }; + static TpToWaypoint _TpToWaypoint{"tptowaypoint", "Teleport to Waypoint", "Teleports you to the waypoint"}; + static AutoTpToWaypoint _AutoTpToWaypoint{"autotptowaypoint", "Auto Teleport to Waypoint", "Automatically teleports you to the waypoint"}; } \ No newline at end of file diff --git a/src/game/frontend/submenus/Teleport.cpp b/src/game/frontend/submenus/Teleport.cpp index 30bb305..c7b62ee 100644 --- a/src/game/frontend/submenus/Teleport.cpp +++ b/src/game/frontend/submenus/Teleport.cpp @@ -171,8 +171,8 @@ namespace YimMenu::Submenus auto main = std::make_shared("Main"); auto miscGroup = std::make_shared("Misc"); - // miscGroup->AddItem(std::make_shared("autotp"_J)); - miscGroup->AddItem(std::make_shared("tptowaypoint"_J)); + miscGroup->AddItem(std::make_shared("autotptowaypoint"_J, std::make_shared("tptowaypoint"_J), true)); + miscGroup->AddItem(std::make_shared("autotptowaypoint"_J)); // miscGroup->AddItem(std::make_shared("tptomount"_J)); // miscGroup->AddItem(std::make_shared("tptotraintrack"_J)); // miscGroup->AddItem(std::make_shared("tptomoonshineshack"_J));