mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-23 04:27:25 +08:00
Redesigned Persist Car to check if the player is already in the car they want to spawn, and just forward self::veh as if it was the vehicle spawned. (#2418)
This commit is contained in:
parent
e56a6fd38f
commit
bc58716118
@ -191,13 +191,17 @@ namespace big
|
||||
Vehicle persist_car_service::spawn_vehicle_json(nlohmann::json vehicle_json, Ped ped, const std::optional<Vector3>& spawn_coords)
|
||||
{
|
||||
const Hash vehicle_hash = vehicle_json[vehicle_model_hash_key];
|
||||
Vector3 spawn_location = spawn_coords.has_value() ? spawn_coords.value() : vehicle::get_spawn_location(g.persist_car.spawn_inside, vehicle_hash);
|
||||
const Vector3& spawn_location = spawn_coords.has_value() ? spawn_coords.value() : vehicle::get_spawn_location(g.persist_car.spawn_inside, vehicle_hash);
|
||||
const float spawn_heading = ENTITY::GET_ENTITY_HEADING(self::ped);
|
||||
|
||||
const auto vehicle = big::vehicle::spawn(vehicle_hash, spawn_location, spawn_heading);
|
||||
Vehicle vehicle = self::veh;
|
||||
if (spawn_coords.has_value() || (!spawn_coords.has_value() && ENTITY::GET_ENTITY_MODEL(vehicle) != vehicle_hash))
|
||||
{
|
||||
vehicle = big::vehicle::spawn(vehicle_hash, spawn_location, spawn_heading);
|
||||
|
||||
if (spawn_location.x + spawn_location.y + spawn_location.z != 0)
|
||||
script::get_current()->yield(); //This is needed to wait for the engine to instantiate things like the radio station so it won't overwrite it on the next frame.
|
||||
}
|
||||
|
||||
VEHICLE::SET_VEHICLE_DIRT_LEVEL(vehicle, 0.0f);
|
||||
VEHICLE::SET_VEHICLE_MOD_KIT(vehicle, 0);
|
||||
|
@ -28,7 +28,7 @@ namespace big
|
||||
{
|
||||
g_notification_service->push_warning("PERSIST_CAR"_T.data(), "PERSIST_CAR_TO_MANY_SPAWNED"_T.data());
|
||||
}
|
||||
else if (g.persist_car.spawn_inside)
|
||||
else if (g.persist_car.spawn_inside && self::veh != vehicle)
|
||||
{
|
||||
teleport::into_vehicle(vehicle);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user