Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void ReplaceVehicle(Vehicle v, Model target, bool tuning)
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - Replacing"+v.DisplayName +" with "+target.ToString());
- //LivelyWorld.BlacklistedModels.Add(v.Model.ToString());
- if (CanWeUse(v))
- {
- Vector3 pos = v.Position;
- float speed = v.Speed;
- float heading = v.Heading;
- Ped ped = v.Driver;
- bool HadDriver = LivelyWorld.CanWeUse(ped);
- Vehicle possibletrailer = LivelyWorld.GetTrailer(v);
- if (CanWeUse(possibletrailer))
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - truck had trailer");
- Function.Call(Hash.DETACH_VEHICLE_FROM_TRAILER, v);
- possibletrailer.IsPersistent = true;
- Script.Wait(500);
- }
- v.Delete();
- Vehicle veh = World.CreateVehicle(target, pos, heading);
- if (LivelyWorld.CanWeUse(veh))
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - replacer car created");
- veh.Speed = speed;
- if (!veh.CurrentBlip.Exists() && LivelyWorld.DebugBlips)
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - adding blip");
- veh.AddBlip();
- veh.CurrentBlip.Sprite = BlipSprite.PersonalVehicleCar;
- veh.CurrentBlip.Scale = 0.7f;
- veh.CurrentBlip.Color = BlipColor.White;
- veh.CurrentBlip.IsShortRange = true;
- veh.CurrentBlip.Name = veh.FriendlyName;
- }
- if (tuning) LivelyWorld.RandomTuning(veh, LivelyWorld.IsNightTime(), false);
- //LivelyWorld.ReplacerTime = Game.GameTime + 30000;
- if (LivelyWorld.CanWeUse(ped)) ped.SetIntoVehicle(veh, VehicleSeat.Driver);
- else
- if (HadDriver)
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - creating driver for it");
- veh.CreateRandomPedOnSeat(VehicleSeat.Driver);
- veh.Driver.IsPersistent = false;
- veh.EngineRunning = true;
- if (LivelyWorld.IsNightTime()) veh.LightsOn = true;
- }
- if (LivelyWorld.CanWeUse(possibletrailer))
- {
- if(DebugOutput) File.AppendAllText(@"scripts\LivelyWorldDebug.txt", "\n" + DateTime.Now + " - arraching trailer to new car");
- Function.Call(GTA.Native.Hash.ATTACH_VEHICLE_TO_TRAILER, veh, possibletrailer, 10);
- possibletrailer.IsPersistent = false;
- }
- BlacklistedVehicles.Add(veh);
- veh.IsPersistent = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement