Skip to content

Commit

Permalink
re-set speed & rpm on vehicle spawn
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TomGrobbe committed May 23, 2018
1 parent 93c8c8d commit c391fc4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vMenu/CommonFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,17 @@ public async void SpawnVehicle(string vehicleName = "custom", bool spawnInside =
/// <param name="saveName">Used to get/set info about the saved vehicle data.</param>
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])
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c391fc4

Please sign in to comment.