feat: Allow to spawn ped with me in the vehicle (#589)

* feat: Allow to spawn ped with me in the vehicle

* feat: do not spawn ped in vehicle without free seats

also allow to spawn ped in driver seat if it is free
This commit is contained in:
PlayDay
2025-07-01 21:59:15 +02:00
committed by GitHub
parent b5a0bbbb3f
commit dacfa665f7
@@ -1,6 +1,7 @@
#include "SpawnPed.hpp" #include "SpawnPed.hpp"
#include "core/backend/ScriptMgr.hpp" #include "core/backend/ScriptMgr.hpp"
#include "core/backend/FiberPool.hpp" #include "core/backend/FiberPool.hpp"
#include "core/frontend/Notifications.hpp"
#include "game/backend/Self.hpp" #include "game/backend/Self.hpp"
#include "game/gta/data/PedModels.hpp" #include "game/gta/data/PedModels.hpp"
#include "game/gta/Ped.hpp" #include "game/gta/Ped.hpp"
@@ -20,6 +21,7 @@ namespace YimMenu::Submenus
static bool spawnDead; static bool spawnDead;
static bool spawnAsBodyguard; static bool spawnAsBodyguard;
static bool spawnAsCop; static bool spawnAsCop;
static bool spawnInMyVehicle;
static bool giveAllWeapons; static bool giveAllWeapons;
static bool spawnAsProstitute; static bool spawnAsProstitute;
static bool randomizeOutfit; static bool randomizeOutfit;
@@ -51,6 +53,23 @@ namespace YimMenu::Submenus
{ {
auto set_player = ImGui::GetIO().KeyCtrl; auto set_player = ImGui::GetIO().KeyCtrl;
FiberPool::Push([name, set_player] { FiberPool::Push([name, set_player] {
if (spawnInMyVehicle)
{
auto vehicle = Self::GetVehicle();
if (vehicle)
{
if (!vehicle.IsSeatFree(-2) &&
!vehicle.IsSeatFree(-1))
{
Notifications::Show(
"Spawn Ped",
"Cannot spawn ped in vehicle, all seats are occupied, please free a seat first or disable 'Spawn In My Vehicle' option.",
NotificationType::Warning);
return;
}
}
}
auto hash = Joaat(name); auto hash = Joaat(name);
auto handle = Ped::Create(hash, Self::GetPed().GetPosition(), Self::GetPed().GetHeading()); auto handle = Ped::Create(hash, Self::GetPed().GetPosition(), Self::GetPed().GetHeading());
@@ -95,6 +114,17 @@ namespace YimMenu::Submenus
handle.SetAsCop(); handle.SetAsCop();
} }
if (spawnInMyVehicle)
{
auto vehicle = Self::GetVehicle();
if (vehicle) {
if (vehicle.IsSeatFree(-1))
handle.SetInVehicle(vehicle, -1);
else
handle.SetInVehicle(vehicle, -2);
}
}
if (giveAllWeapons) if (giveAllWeapons)
{ {
for (auto hash : g_WeaponHashes) for (auto hash : g_WeaponHashes)
@@ -172,6 +202,7 @@ namespace YimMenu::Submenus
ImGui::Checkbox("Spawn Dead", &spawnDead); ImGui::Checkbox("Spawn Dead", &spawnDead);
ImGui::Checkbox("Spawn As Bodyguard", &spawnAsBodyguard); ImGui::Checkbox("Spawn As Bodyguard", &spawnAsBodyguard);
ImGui::Checkbox("Spawn As Cop", &spawnAsCop); ImGui::Checkbox("Spawn As Cop", &spawnAsCop);
ImGui::Checkbox("Spawn In My Vehicle", &spawnInMyVehicle);
ImGui::Checkbox("Give All Weapons", &giveAllWeapons); ImGui::Checkbox("Give All Weapons", &giveAllWeapons);
ImGui::Checkbox("Spawn As Prostitute", &spawnAsProstitute); ImGui::Checkbox("Spawn As Prostitute", &spawnAsProstitute);
ImGui::Checkbox("Randomize Outfit", &randomizeOutfit); ImGui::Checkbox("Randomize Outfit", &randomizeOutfit);