From ebb0a26f7e2e8a93a94a3488de8613105b2dbadc Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 27 Mar 2025 00:54:46 +0100 Subject: [PATCH] feat(Self): enter last vehicle, infinite parachutes (#33) * feat(Self): enter last vehicle, infinite parachutes * fix: consistent style --- src/game/features/self/InfiniteParachutes.cpp | 34 +++++++++++++++++++ src/game/features/vehicle/EnterLast.cpp | 32 +++++++++++++++++ src/game/features/vehicle/Spawn.cpp | 2 +- src/game/frontend/submenus/Self.cpp | 4 ++- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/game/features/self/InfiniteParachutes.cpp create mode 100644 src/game/features/vehicle/EnterLast.cpp diff --git a/src/game/features/self/InfiniteParachutes.cpp b/src/game/features/self/InfiniteParachutes.cpp new file mode 100644 index 0000000..a3f0c74 --- /dev/null +++ b/src/game/features/self/InfiniteParachutes.cpp @@ -0,0 +1,34 @@ +#include "core/commands/LoopedCommand.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/Natives.hpp" + +namespace YimMenu::Features +{ + class InfiniteParachutes : public LoopedCommand + { + using LoopedCommand::LoopedCommand; + + virtual void OnTick() override + { + if (auto player = Self::GetPlayer()) + { + PLAYER::SET_PLAYER_HAS_RESERVE_PARACHUTE(player.GetId()); + } + + if (auto ped = Self::GetPed()) + { + if (!WEAPON::HAS_PED_GOT_WEAPON(ped.GetHandle(), "GADGET_PARACHUTE"_J, false)) + { + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(ped.GetHandle(), "GADGET_PARACHUTE"_J, 1, false); + } + } + } + + virtual void OnDisable() override + { + + } + }; + + static InfiniteParachutes _InfiniteParachutes{"infiniteparachutes", "Infinite Parachutes", "Always have a parachute."}; +}; \ No newline at end of file diff --git a/src/game/features/vehicle/EnterLast.cpp b/src/game/features/vehicle/EnterLast.cpp new file mode 100644 index 0000000..5940697 --- /dev/null +++ b/src/game/features/vehicle/EnterLast.cpp @@ -0,0 +1,32 @@ +#include "core/commands/Command.hpp" +#include "game/gta/Vehicle.hpp" +#include "game/backend/Self.hpp" +#include "game/gta/Natives.hpp" +#include "game/gta/data/VehicleValues.hpp" + +namespace YimMenu::Features +{ + class EnterLastVehicle : Command + { + using Command::Command; + + virtual void OnCall() override + { + auto vehicleHandle = PLAYER::GET_PLAYERS_LAST_VEHICLE(); + + if (vehicleHandle != 0 && vehicleHandle != Self::GetVehicle().GetHandle()) { + // TODO This logic should probably be moved into the Vehicle class + for (int seat = (int)SeatPositions::SEAT_DRIVER; seat < (int)SeatPositions::SEAT_BACKPASSENGER; seat++) + { + if (VEHICLE::IS_VEHICLE_SEAT_FREE(vehicleHandle, seat, true)) + { + PED::SET_PED_INTO_VEHICLE(Self::GetPed().GetHandle(), vehicleHandle, seat); + break; + } + } + } + } + }; + + static EnterLastVehicle _EnterLastVehicle{"enterlastvehicle", "Enter last vehicle", "Enters the last vehicle you were in."}; +}; \ No newline at end of file diff --git a/src/game/features/vehicle/Spawn.cpp b/src/game/features/vehicle/Spawn.cpp index 2ffb940..550ad49 100644 --- a/src/game/features/vehicle/Spawn.cpp +++ b/src/game/features/vehicle/Spawn.cpp @@ -39,7 +39,7 @@ namespace YimMenu::Features if (_SpawnInVehicle.GetState()) { - PED::SET_PED_INTO_VEHICLE(Self::GetPed().GetHandle(), vehHandle, -1); + PED::SET_PED_INTO_VEHICLE(Self::GetPed().GetHandle(), vehHandle, (int)SeatPositions::SEAT_DRIVER); } if (_SpawnWithMaximumUpgrades.GetState()) diff --git a/src/game/frontend/submenus/Self.cpp b/src/game/frontend/submenus/Self.cpp index 1ad8fbc..c43764f 100644 --- a/src/game/frontend/submenus/Self.cpp +++ b/src/game/frontend/submenus/Self.cpp @@ -55,6 +55,7 @@ namespace YimMenu::Submenus weaponsGlobalsGroup->AddItem(std::make_shared("infiniteammo"_J)); weaponsGlobalsGroup->AddItem(std::make_shared("infiniteclip"_J)); weaponsGlobalsGroup->AddItem(std::make_shared("rapidfire"_J)); + weaponsGlobalsGroup->AddItem(std::make_shared("infiniteparachutes"_J)); weaponsGlobalsGroup->AddItem(std::make_shared("giveallweapons"_J)); weapons->AddItem(weaponsGlobalsGroup); @@ -68,7 +69,8 @@ namespace YimMenu::Submenus vehicleGlobalsGroup->AddItem(std::make_shared("keepfixed"_J, "Keep Fixed")); vehicleGlobalsGroup->AddItem(std::make_shared("hornboost"_J)); vehicleGlobalsGroup->AddItem(std::make_shared("repairvehicle"_J)); - + vehicleGlobalsGroup->AddItem(std::make_shared("enterlastvehicle"_J)); + vehicleMiscGroup->AddItem(std::make_shared("speedometer"_J)); vehicleMiscGroup->AddItem(std::make_shared("seatbelt"_J));