add auto teleport to waypoint (#102)

* add auto teleport to waypoint

* run auto tp inside fiber pool

* put only z-finder and the teleport commands inside fiber pool
This commit is contained in:
kurumimeow
2025-04-07 14:04:14 +05:30
committed by GitHub
parent b22b1bc695
commit 802c75b270
2 changed files with 28 additions and 2 deletions
@@ -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"};
}
+2 -2
View File
@@ -171,8 +171,8 @@ namespace YimMenu::Submenus
auto main = std::make_shared<Category>("Main");
auto miscGroup = std::make_shared<Group>("Misc");
// miscGroup->AddItem(std::make_shared<BoolCommandItem>("autotp"_J));
miscGroup->AddItem(std::make_shared<CommandItem>("tptowaypoint"_J));
miscGroup->AddItem(std::make_shared<ConditionalItem>("autotptowaypoint"_J, std::make_shared<CommandItem>("tptowaypoint"_J), true));
miscGroup->AddItem(std::make_shared<BoolCommandItem>("autotptowaypoint"_J));
// miscGroup->AddItem(std::make_shared<CommandItem>("tptomount"_J));
// miscGroup->AddItem(std::make_shared<CommandItem>("tptotraintrack"_J));
// miscGroup->AddItem(std::make_shared<CommandItem>("tptomoonshineshack"_J));