From c391fc410a825d6cd8d9d3379d21175c5b2c0d76 Mon Sep 17 00:00:00 2001 From: Vespura <31419184+TomGrobbe@users.noreply.github.com> Date: Wed, 23 May 2018 22:18:38 +0200 Subject: [PATCH] re-set speed & rpm on vehicle spawn spawning a vehicle while in-motion will now set the speed of the vehicle you just spawned to the original speed, allowing you to "swap on the go" and keep racing your sweet ride --- vMenu/CommonFunctions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vMenu/CommonFunctions.cs b/vMenu/CommonFunctions.cs index bc2e6a14..836a19b6 100644 --- a/vMenu/CommonFunctions.cs +++ b/vMenu/CommonFunctions.cs @@ -629,6 +629,17 @@ public async void SpawnVehicle(string vehicleName = "custom", bool spawnInside = /// Used to get/set info about the saved vehicle data. public async void SpawnVehicle(uint vehicleHash, bool spawnInside, bool replacePrevious, bool skipLoad, VehicleInfo vehicleInfo, string saveName = null) { + float speed = 0f; + float rpm = 0f; + if (IsPedInAnyVehicle(PlayerPedId(), false)) + { + Vehicle tmpOldVehicle = new Vehicle(GetVehicle()); + speed = tmpOldVehicle.Speed; + rpm = tmpOldVehicle.CurrentRPM; + tmpOldVehicle = null; + } + + var vehClass = GetVehicleClassFromName(vehicleHash); int modelClass = GetVehicleClassFromName(vehicleHash); if (!MainMenu.VehicleSpawnerMenu.allowedCategories[modelClass]) @@ -783,6 +794,8 @@ public async void SpawnVehicle(uint vehicleHash, bool spawnInside, bool replaceP // Set the previous vehicle to the new vehicle. previousVehicle = vehicle; + vehicle.Speed = speed; + vehicle.CurrentRPM = rpm; // Discard the model. SetModelAsNoLongerNeeded(vehicleHash);