Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Type: DLCTraffic.Traffic
- // Assembly: DLCTraffic, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 36830B8F-0C94-4A68-85E1-26078AD87B33
- // Assembly location: C:\Users\Sudo\Desktop\DLCTraffic.dll
- using GTA;
- using GTA.Math;
- using GTA.Native;
- using Microsoft.VisualBasic.CompilerServices;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- namespace DLCTraffic
- {
- public class Traffic : Script
- {
- public static List<string> Vehicles = new List<string>();
- public static int SpawnDistance = 100;
- public static int Notify = 1;
- public static Vehicle DLCVehicle;
- public static Ped DLCVehicleDriver;
- public static Ped DLCVehiclePassenger;
- public static Random DLCVehicleRandom;
- public static Random ColorRandom;
- public static Random ModRandom;
- public string VehicleListFileName;
- public StreamReader StreamReader;
- public string line;
- public string[] ReadResult;
- public int WaitTime;
- public int UpgradeChance;
- public int UpgradeEnable;
- public int CruiseSpeed;
- public int DriveStyle;
- public int ModBlip;
- public Traffic()
- {
- base.\u002Ector();
- this.add_Tick(new EventHandler(this.OnTick));
- this.VehicleListFileName = "scripts\\DLCTraffic.txt";
- this.StreamReader = new StreamReader(this.VehicleListFileName);
- this.WaitTime = 30;
- this.UpgradeChance = 20;
- this.UpgradeEnable = 1;
- this.CruiseSpeed = 60;
- this.DriveStyle = 786603;
- this.ModBlip = 1;
- this.LoadSettings();
- this.LoadVehicles();
- }
- public void LoadVehicles()
- {
- for (this.line = this.StreamReader.ReadLine(); this.line != null; this.line = this.StreamReader.ReadLine())
- {
- this.line = this.line.Trim();
- this.ReadResult = this.line.Split(',');
- int num = checked (this.ReadResult.Length - 1);
- int index = 0;
- while (index <= num)
- {
- if (this.ReadResult[index].Length > 0)
- Traffic.Vehicles.Add(this.ReadResult[index].Trim().ToString());
- checked { ++index; }
- }
- }
- this.StreamReader.Close();
- }
- public void LoadSettings()
- {
- ScriptSettings scriptSettings = ScriptSettings.Load("scripts\\DLCTraffic.ini");
- this.WaitTime = (int) scriptSettings.GetValue<int>("SETTINGS", "WaitTime", (M0) 30);
- this.CruiseSpeed = (int) scriptSettings.GetValue<int>("SETTINGS", "CruiseSpeed", (M0) 60);
- Traffic.SpawnDistance = (int) scriptSettings.GetValue<int>("SETTINGS", "SpawnDistance", (M0) 100);
- this.DriveStyle = (int) scriptSettings.GetValue<int>("SETTINGS", "DrivingStyle", (M0) 786603);
- this.UpgradeChance = (int) scriptSettings.GetValue<int>("SETTINGS", "UpgradeChance", (M0) 20);
- this.UpgradeEnable = (int) scriptSettings.GetValue<int>("SETTINGS", "EnableUpgrade", (M0) 1);
- Traffic.Notify = (int) scriptSettings.GetValue<int>("SETTINGS", "Notify", (M0) 1);
- this.ModBlip = (int) scriptSettings.GetValue<int>("SETTINGS", "ShowBlip", (M0) 1);
- }
- public void OnTick(object sender, EventArgs e)
- {
- try
- {
- string playerZone = Traffic.GetPlayerZone();
- // ISSUE: reference to a compiler-generated method
- uint stringHash = \u003CPrivateImplementationDetails\u003E.ComputeStringHash(playerZone);
- if (stringHash <= 1872058313U)
- {
- if ((int) stringHash != 26379365)
- {
- if ((int) stringHash != 992322320)
- {
- if ((int) stringHash != 1872058313 || Operators.CompareString(playerZone, "MTGORDO", false) != 0)
- goto label_16;
- }
- else if (Operators.CompareString(playerZone, "OCEANA", false) != 0)
- goto label_16;
- }
- else if (Operators.CompareString(playerZone, "AIRP", false) != 0)
- goto label_16;
- }
- else if (stringHash <= 2887547778U)
- {
- if ((int) stringHash != -1578651182)
- {
- if ((int) stringHash != -1407419518 || Operators.CompareString(playerZone, "MTCHIL", false) != 0)
- goto label_16;
- }
- else if (Operators.CompareString(playerZone, "ARMYB", false) != 0)
- goto label_16;
- }
- else if ((int) stringHash != -820152173)
- {
- if ((int) stringHash != -159455887 || Operators.CompareString(playerZone, "JAIL", false) != 0)
- goto label_16;
- }
- else if (Operators.CompareString(playerZone, "MTJOSE", false) != 0)
- goto label_16;
- Script.Wait(checked (this.WaitTime * 1000));
- return;
- label_16:
- Script.Wait(checked (this.WaitTime * 1000));
- Traffic.DLCVehicleRandom = new Random();
- if ((uint) Traffic.Vehicles.Count <= 0U)
- return;
- Model model = Model.op_Implicit(Traffic.Vehicles[Traffic.DLCVehicleRandom.Next(0, Traffic.Vehicles.Count)]);
- Vector3 position = ((Entity) Game.get_Player().get_Character()).get_Position();
- // ISSUE: explicit reference operation
- Vector3 positionOnStreet = World.GetNextPositionOnStreet(((Vector3) @position).Around((float) Traffic.SpawnDistance));
- Traffic.DLCVehicle = World.CreateVehicle(model, positionOnStreet);
- Traffic.DLCVehicle.set_EngineRunning(true);
- ((Entity) Traffic.DLCVehicle).set_IsPersistent(false);
- this.PaintVehicle(Traffic.DLCVehicle);
- if (this.UpgradeEnable == 1)
- {
- Traffic.ModRandom = new Random();
- int num = Traffic.ModRandom.Next(0, 100);
- if (num >= 0 && num <= this.UpgradeChance)
- this.FullyUpgradeVehicle(Traffic.DLCVehicle);
- }
- Traffic.DLCVehicle.CreateRandomPedOnSeat((VehicleSeat) -1);
- int num1 = Traffic.ModRandom.Next(0, 100);
- if (num1 >= 0 && num1 <= 50)
- Traffic.DLCVehicle.CreateRandomPedOnSeat((VehicleSeat) 0);
- Traffic.DLCVehicleDriver = Traffic.DLCVehicle.get_Driver();
- Traffic.DLCVehicleDriver.get_Task().CruiseWithVehicle(Traffic.DLCVehicleDriver.get_CurrentVehicle(), (float) this.CruiseSpeed, this.DriveStyle);
- ((Entity) Traffic.DLCVehicle).AddBlip();
- if (this.ModBlip == 1)
- ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Alpha((int) byte.MaxValue);
- else
- ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Alpha(0);
- ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Color((BlipColor) 88);
- ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Name(Traffic.DLCVehicle.get_FriendlyName());
- if (Traffic.Notify == 1)
- UI.Notify(Traffic.DLCVehicle.get_FriendlyName() + " Spawned.");
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- }
- public void PaintVehicle(Vehicle Veh)
- {
- Traffic.ColorRandom = new Random();
- Veh.set_PrimaryColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
- Veh.set_SecondaryColor(Veh.get_PrimaryColor());
- Veh.set_PearlescentColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
- Veh.set_DashboardColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
- Veh.set_TrimColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
- Veh.set_RimColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
- }
- public void FullyUpgradeVehicle(Vehicle Veh)
- {
- Veh.InstallModKit();
- Veh.SetMod((VehicleMod) 43, checked (Veh.GetModCount((VehicleMod) 43) - 1), true);
- Veh.SetMod((VehicleMod) 40, checked (Veh.GetModCount((VehicleMod) 40) - 1), true);
- Veh.SetMod((VehicleMod) 42, checked (Veh.GetModCount((VehicleMod) 42) - 1), true);
- Veh.SetMod((VehicleMod) 16, checked (Veh.GetModCount((VehicleMod) 16) - 1), true);
- Veh.SetMod((VehicleMod) 24, checked (Veh.GetModCount((VehicleMod) 24) - 1), true);
- Veh.SetMod((VehicleMod) 12, checked (Veh.GetModCount((VehicleMod) 12) - 1), true);
- Veh.SetMod((VehicleMod) 34, checked (Veh.GetModCount((VehicleMod) 34) - 1), true);
- Veh.SetMod((VehicleMod) 29, checked (Veh.GetModCount((VehicleMod) 29) - 1), true);
- Veh.SetMod((VehicleMod) 30, checked (Veh.GetModCount((VehicleMod) 30) - 1), true);
- Veh.SetMod((VehicleMod) 31, checked (Veh.GetModCount((VehicleMod) 31) - 1), true);
- Veh.SetMod((VehicleMod) 11, checked (Veh.GetModCount((VehicleMod) 11) - 1), true);
- Veh.SetMod((VehicleMod) 39, checked (Veh.GetModCount((VehicleMod) 39) - 1), true);
- Veh.SetMod((VehicleMod) 4, checked (Veh.GetModCount((VehicleMod) 4) - 1), true);
- Veh.SetMod((VehicleMod) 8, checked (Veh.GetModCount((VehicleMod) 8) - 1), true);
- Veh.SetMod((VehicleMod) 5, checked (Veh.GetModCount((VehicleMod) 5) - 1), true);
- Veh.SetMod((VehicleMod) 1, checked (Veh.GetModCount((VehicleMod) 1) - 1), true);
- Veh.SetMod((VehicleMod) 23, checked (Veh.GetModCount((VehicleMod) 23) - 1), true);
- Veh.SetMod((VehicleMod) 6, checked (Veh.GetModCount((VehicleMod) 6) - 1), true);
- Veh.SetMod((VehicleMod) 7, checked (Veh.GetModCount((VehicleMod) 7) - 1), true);
- Veh.SetMod((VehicleMod) 14, checked (Veh.GetModCount((VehicleMod) 14) - 1), true);
- Veh.SetMod((VehicleMod) 38, checked (Veh.GetModCount((VehicleMod) 38) - 1), true);
- Veh.SetMod((VehicleMod) 48, checked (Veh.GetModCount((VehicleMod) 48) - 1), true);
- Veh.SetMod((VehicleMod) 28, checked (Veh.GetModCount((VehicleMod) 28) - 1), true);
- Veh.SetMod((VehicleMod) 35, checked (Veh.GetModCount((VehicleMod) 35) - 1), true);
- Veh.SetMod((VehicleMod) 25, checked (Veh.GetModCount((VehicleMod) 25) - 1), true);
- Veh.SetMod((VehicleMod) 2, checked (Veh.GetModCount((VehicleMod) 2) - 1), true);
- Veh.SetMod((VehicleMod) 9, checked (Veh.GetModCount((VehicleMod) 9) - 1), true);
- Veh.SetMod((VehicleMod) 10, checked (Veh.GetModCount((VehicleMod) 10) - 1), true);
- Veh.SetMod((VehicleMod) 32, checked (Veh.GetModCount((VehicleMod) 32) - 1), true);
- Veh.SetMod((VehicleMod) 3, checked (Veh.GetModCount((VehicleMod) 3) - 1), true);
- Veh.SetMod((VehicleMod) 36, checked (Veh.GetModCount((VehicleMod) 36) - 1), true);
- Veh.SetMod((VehicleMod) 0, checked (Veh.GetModCount((VehicleMod) 0) - 1), true);
- Veh.SetMod((VehicleMod) 33, checked (Veh.GetModCount((VehicleMod) 33) - 1), true);
- Veh.SetMod((VehicleMod) 41, checked (Veh.GetModCount((VehicleMod) 41) - 1), true);
- Veh.SetMod((VehicleMod) 15, checked (Veh.GetModCount((VehicleMod) 15) - 1), true);
- Veh.SetMod((VehicleMod) 45, checked (Veh.GetModCount((VehicleMod) 45) - 1), true);
- Veh.SetMod((VehicleMod) 13, checked (Veh.GetModCount((VehicleMod) 13) - 1), true);
- Veh.SetMod((VehicleMod) 44, checked (Veh.GetModCount((VehicleMod) 44) - 1), true);
- Veh.SetMod((VehicleMod) 27, checked (Veh.GetModCount((VehicleMod) 27) - 1), true);
- Veh.SetMod((VehicleMod) 37, checked (Veh.GetModCount((VehicleMod) 37) - 1), true);
- Veh.SetMod((VehicleMod) 26, checked (Veh.GetModCount((VehicleMod) 26) - 1), true);
- Veh.SetMod((VehicleMod) 46, checked (Veh.GetModCount((VehicleMod) 46) - 1), true);
- Veh.ToggleMod((VehicleToggleMod) 21, true);
- Veh.ToggleMod((VehicleToggleMod) 17, true);
- Veh.ToggleMod((VehicleToggleMod) 19, true);
- Veh.SetNeonLightsOn((VehicleNeonLight) 3, true);
- Veh.SetNeonLightsOn((VehicleNeonLight) 2, true);
- Veh.SetNeonLightsOn((VehicleNeonLight) 0, true);
- Veh.SetNeonLightsOn((VehicleNeonLight) 1, true);
- Traffic.ColorRandom = new Random();
- Veh.set_NeonLightsColor(Color.FromArgb(Traffic.ColorRandom.Next(0, (int) byte.MaxValue), Traffic.ColorRandom.Next(0, (int) byte.MaxValue), Traffic.ColorRandom.Next(0, (int) byte.MaxValue)));
- Veh.set_WindowTint((VehicleWindowTint) 1);
- }
- public static string GetPlayerZone()
- {
- Ped character = Game.get_Player().get_Character();
- return (string) Function.Call<string>((Hash) -3634293310464400950L, new InputArgument[3]
- {
- InputArgument.op_Implicit((float) ((Entity) character).get_Position().X),
- InputArgument.op_Implicit((float) ((Entity) character).get_Position().Y),
- InputArgument.op_Implicit((float) ((Entity) character).get_Position().Z)
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement