Advertisement
djhonga2001

Untitled

Jan 29th, 2017
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1.  
  2. // Type: DLCTraffic.Traffic
  3. // Assembly: DLCTraffic, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: 36830B8F-0C94-4A68-85E1-26078AD87B33
  5. // Assembly location: C:\Users\Sudo\Desktop\DLCTraffic.dll
  6.  
  7. using GTA;
  8. using GTA.Math;
  9. using GTA.Native;
  10. using Microsoft.VisualBasic.CompilerServices;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Drawing;
  14. using System.IO;
  15.  
  16. namespace DLCTraffic
  17. {
  18. public class Traffic : Script
  19. {
  20. public static List<string> Vehicles = new List<string>();
  21. public static int SpawnDistance = 100;
  22. public static int Notify = 1;
  23. public static Vehicle DLCVehicle;
  24. public static Ped DLCVehicleDriver;
  25. public static Ped DLCVehiclePassenger;
  26. public static Random DLCVehicleRandom;
  27. public static Random ColorRandom;
  28. public static Random ModRandom;
  29. public string VehicleListFileName;
  30. public StreamReader StreamReader;
  31. public string line;
  32. public string[] ReadResult;
  33. public int WaitTime;
  34. public int UpgradeChance;
  35. public int UpgradeEnable;
  36. public int CruiseSpeed;
  37. public int DriveStyle;
  38. public int ModBlip;
  39.  
  40. public Traffic()
  41. {
  42. base.\u002Ector();
  43. this.add_Tick(new EventHandler(this.OnTick));
  44. this.VehicleListFileName = "scripts\\DLCTraffic.txt";
  45. this.StreamReader = new StreamReader(this.VehicleListFileName);
  46. this.WaitTime = 30;
  47. this.UpgradeChance = 20;
  48. this.UpgradeEnable = 1;
  49. this.CruiseSpeed = 60;
  50. this.DriveStyle = 786603;
  51. this.ModBlip = 1;
  52. this.LoadSettings();
  53. this.LoadVehicles();
  54. }
  55.  
  56. public void LoadVehicles()
  57. {
  58. for (this.line = this.StreamReader.ReadLine(); this.line != null; this.line = this.StreamReader.ReadLine())
  59. {
  60. this.line = this.line.Trim();
  61. this.ReadResult = this.line.Split(',');
  62. int num = checked (this.ReadResult.Length - 1);
  63. int index = 0;
  64. while (index <= num)
  65. {
  66. if (this.ReadResult[index].Length > 0)
  67. Traffic.Vehicles.Add(this.ReadResult[index].Trim().ToString());
  68. checked { ++index; }
  69. }
  70. }
  71. this.StreamReader.Close();
  72. }
  73.  
  74. public void LoadSettings()
  75. {
  76. ScriptSettings scriptSettings = ScriptSettings.Load("scripts\\DLCTraffic.ini");
  77. this.WaitTime = (int) scriptSettings.GetValue<int>("SETTINGS", "WaitTime", (M0) 30);
  78. this.CruiseSpeed = (int) scriptSettings.GetValue<int>("SETTINGS", "CruiseSpeed", (M0) 60);
  79. Traffic.SpawnDistance = (int) scriptSettings.GetValue<int>("SETTINGS", "SpawnDistance", (M0) 100);
  80. this.DriveStyle = (int) scriptSettings.GetValue<int>("SETTINGS", "DrivingStyle", (M0) 786603);
  81. this.UpgradeChance = (int) scriptSettings.GetValue<int>("SETTINGS", "UpgradeChance", (M0) 20);
  82. this.UpgradeEnable = (int) scriptSettings.GetValue<int>("SETTINGS", "EnableUpgrade", (M0) 1);
  83. Traffic.Notify = (int) scriptSettings.GetValue<int>("SETTINGS", "Notify", (M0) 1);
  84. this.ModBlip = (int) scriptSettings.GetValue<int>("SETTINGS", "ShowBlip", (M0) 1);
  85. }
  86.  
  87. public void OnTick(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. string playerZone = Traffic.GetPlayerZone();
  92. // ISSUE: reference to a compiler-generated method
  93. uint stringHash = \u003CPrivateImplementationDetails\u003E.ComputeStringHash(playerZone);
  94. if (stringHash <= 1872058313U)
  95. {
  96. if ((int) stringHash != 26379365)
  97. {
  98. if ((int) stringHash != 992322320)
  99. {
  100. if ((int) stringHash != 1872058313 || Operators.CompareString(playerZone, "MTGORDO", false) != 0)
  101. goto label_16;
  102. }
  103. else if (Operators.CompareString(playerZone, "OCEANA", false) != 0)
  104. goto label_16;
  105. }
  106. else if (Operators.CompareString(playerZone, "AIRP", false) != 0)
  107. goto label_16;
  108. }
  109. else if (stringHash <= 2887547778U)
  110. {
  111. if ((int) stringHash != -1578651182)
  112. {
  113. if ((int) stringHash != -1407419518 || Operators.CompareString(playerZone, "MTCHIL", false) != 0)
  114. goto label_16;
  115. }
  116. else if (Operators.CompareString(playerZone, "ARMYB", false) != 0)
  117. goto label_16;
  118. }
  119. else if ((int) stringHash != -820152173)
  120. {
  121. if ((int) stringHash != -159455887 || Operators.CompareString(playerZone, "JAIL", false) != 0)
  122. goto label_16;
  123. }
  124. else if (Operators.CompareString(playerZone, "MTJOSE", false) != 0)
  125. goto label_16;
  126. Script.Wait(checked (this.WaitTime * 1000));
  127. return;
  128. label_16:
  129. Script.Wait(checked (this.WaitTime * 1000));
  130. Traffic.DLCVehicleRandom = new Random();
  131. if ((uint) Traffic.Vehicles.Count <= 0U)
  132. return;
  133. Model model = Model.op_Implicit(Traffic.Vehicles[Traffic.DLCVehicleRandom.Next(0, Traffic.Vehicles.Count)]);
  134. Vector3 position = ((Entity) Game.get_Player().get_Character()).get_Position();
  135. // ISSUE: explicit reference operation
  136. Vector3 positionOnStreet = World.GetNextPositionOnStreet(((Vector3) @position).Around((float) Traffic.SpawnDistance));
  137. Traffic.DLCVehicle = World.CreateVehicle(model, positionOnStreet);
  138. Traffic.DLCVehicle.set_EngineRunning(true);
  139. ((Entity) Traffic.DLCVehicle).set_IsPersistent(false);
  140. this.PaintVehicle(Traffic.DLCVehicle);
  141. if (this.UpgradeEnable == 1)
  142. {
  143. Traffic.ModRandom = new Random();
  144. int num = Traffic.ModRandom.Next(0, 100);
  145. if (num >= 0 && num <= this.UpgradeChance)
  146. this.FullyUpgradeVehicle(Traffic.DLCVehicle);
  147. }
  148. Traffic.DLCVehicle.CreateRandomPedOnSeat((VehicleSeat) -1);
  149. int num1 = Traffic.ModRandom.Next(0, 100);
  150. if (num1 >= 0 && num1 <= 50)
  151. Traffic.DLCVehicle.CreateRandomPedOnSeat((VehicleSeat) 0);
  152. Traffic.DLCVehicleDriver = Traffic.DLCVehicle.get_Driver();
  153. Traffic.DLCVehicleDriver.get_Task().CruiseWithVehicle(Traffic.DLCVehicleDriver.get_CurrentVehicle(), (float) this.CruiseSpeed, this.DriveStyle);
  154. ((Entity) Traffic.DLCVehicle).AddBlip();
  155. if (this.ModBlip == 1)
  156. ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Alpha((int) byte.MaxValue);
  157. else
  158. ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Alpha(0);
  159. ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Color((BlipColor) 88);
  160. ((Entity) Traffic.DLCVehicle).get_CurrentBlip().set_Name(Traffic.DLCVehicle.get_FriendlyName());
  161. if (Traffic.Notify == 1)
  162. UI.Notify(Traffic.DLCVehicle.get_FriendlyName() + " Spawned.");
  163. }
  164. catch (Exception ex)
  165. {
  166. ProjectData.SetProjectError(ex);
  167. ProjectData.ClearProjectError();
  168. }
  169. }
  170.  
  171. public void PaintVehicle(Vehicle Veh)
  172. {
  173. Traffic.ColorRandom = new Random();
  174. Veh.set_PrimaryColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
  175. Veh.set_SecondaryColor(Veh.get_PrimaryColor());
  176. Veh.set_PearlescentColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
  177. Veh.set_DashboardColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
  178. Veh.set_TrimColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
  179. Veh.set_RimColor((VehicleColor) Traffic.ColorRandom.Next(0, 160));
  180. }
  181.  
  182. public void FullyUpgradeVehicle(Vehicle Veh)
  183. {
  184. Veh.InstallModKit();
  185. Veh.SetMod((VehicleMod) 43, checked (Veh.GetModCount((VehicleMod) 43) - 1), true);
  186. Veh.SetMod((VehicleMod) 40, checked (Veh.GetModCount((VehicleMod) 40) - 1), true);
  187. Veh.SetMod((VehicleMod) 42, checked (Veh.GetModCount((VehicleMod) 42) - 1), true);
  188. Veh.SetMod((VehicleMod) 16, checked (Veh.GetModCount((VehicleMod) 16) - 1), true);
  189. Veh.SetMod((VehicleMod) 24, checked (Veh.GetModCount((VehicleMod) 24) - 1), true);
  190. Veh.SetMod((VehicleMod) 12, checked (Veh.GetModCount((VehicleMod) 12) - 1), true);
  191. Veh.SetMod((VehicleMod) 34, checked (Veh.GetModCount((VehicleMod) 34) - 1), true);
  192. Veh.SetMod((VehicleMod) 29, checked (Veh.GetModCount((VehicleMod) 29) - 1), true);
  193. Veh.SetMod((VehicleMod) 30, checked (Veh.GetModCount((VehicleMod) 30) - 1), true);
  194. Veh.SetMod((VehicleMod) 31, checked (Veh.GetModCount((VehicleMod) 31) - 1), true);
  195. Veh.SetMod((VehicleMod) 11, checked (Veh.GetModCount((VehicleMod) 11) - 1), true);
  196. Veh.SetMod((VehicleMod) 39, checked (Veh.GetModCount((VehicleMod) 39) - 1), true);
  197. Veh.SetMod((VehicleMod) 4, checked (Veh.GetModCount((VehicleMod) 4) - 1), true);
  198. Veh.SetMod((VehicleMod) 8, checked (Veh.GetModCount((VehicleMod) 8) - 1), true);
  199. Veh.SetMod((VehicleMod) 5, checked (Veh.GetModCount((VehicleMod) 5) - 1), true);
  200. Veh.SetMod((VehicleMod) 1, checked (Veh.GetModCount((VehicleMod) 1) - 1), true);
  201. Veh.SetMod((VehicleMod) 23, checked (Veh.GetModCount((VehicleMod) 23) - 1), true);
  202. Veh.SetMod((VehicleMod) 6, checked (Veh.GetModCount((VehicleMod) 6) - 1), true);
  203. Veh.SetMod((VehicleMod) 7, checked (Veh.GetModCount((VehicleMod) 7) - 1), true);
  204. Veh.SetMod((VehicleMod) 14, checked (Veh.GetModCount((VehicleMod) 14) - 1), true);
  205. Veh.SetMod((VehicleMod) 38, checked (Veh.GetModCount((VehicleMod) 38) - 1), true);
  206. Veh.SetMod((VehicleMod) 48, checked (Veh.GetModCount((VehicleMod) 48) - 1), true);
  207. Veh.SetMod((VehicleMod) 28, checked (Veh.GetModCount((VehicleMod) 28) - 1), true);
  208. Veh.SetMod((VehicleMod) 35, checked (Veh.GetModCount((VehicleMod) 35) - 1), true);
  209. Veh.SetMod((VehicleMod) 25, checked (Veh.GetModCount((VehicleMod) 25) - 1), true);
  210. Veh.SetMod((VehicleMod) 2, checked (Veh.GetModCount((VehicleMod) 2) - 1), true);
  211. Veh.SetMod((VehicleMod) 9, checked (Veh.GetModCount((VehicleMod) 9) - 1), true);
  212. Veh.SetMod((VehicleMod) 10, checked (Veh.GetModCount((VehicleMod) 10) - 1), true);
  213. Veh.SetMod((VehicleMod) 32, checked (Veh.GetModCount((VehicleMod) 32) - 1), true);
  214. Veh.SetMod((VehicleMod) 3, checked (Veh.GetModCount((VehicleMod) 3) - 1), true);
  215. Veh.SetMod((VehicleMod) 36, checked (Veh.GetModCount((VehicleMod) 36) - 1), true);
  216. Veh.SetMod((VehicleMod) 0, checked (Veh.GetModCount((VehicleMod) 0) - 1), true);
  217. Veh.SetMod((VehicleMod) 33, checked (Veh.GetModCount((VehicleMod) 33) - 1), true);
  218. Veh.SetMod((VehicleMod) 41, checked (Veh.GetModCount((VehicleMod) 41) - 1), true);
  219. Veh.SetMod((VehicleMod) 15, checked (Veh.GetModCount((VehicleMod) 15) - 1), true);
  220. Veh.SetMod((VehicleMod) 45, checked (Veh.GetModCount((VehicleMod) 45) - 1), true);
  221. Veh.SetMod((VehicleMod) 13, checked (Veh.GetModCount((VehicleMod) 13) - 1), true);
  222. Veh.SetMod((VehicleMod) 44, checked (Veh.GetModCount((VehicleMod) 44) - 1), true);
  223. Veh.SetMod((VehicleMod) 27, checked (Veh.GetModCount((VehicleMod) 27) - 1), true);
  224. Veh.SetMod((VehicleMod) 37, checked (Veh.GetModCount((VehicleMod) 37) - 1), true);
  225. Veh.SetMod((VehicleMod) 26, checked (Veh.GetModCount((VehicleMod) 26) - 1), true);
  226. Veh.SetMod((VehicleMod) 46, checked (Veh.GetModCount((VehicleMod) 46) - 1), true);
  227. Veh.ToggleMod((VehicleToggleMod) 21, true);
  228. Veh.ToggleMod((VehicleToggleMod) 17, true);
  229. Veh.ToggleMod((VehicleToggleMod) 19, true);
  230. Veh.SetNeonLightsOn((VehicleNeonLight) 3, true);
  231. Veh.SetNeonLightsOn((VehicleNeonLight) 2, true);
  232. Veh.SetNeonLightsOn((VehicleNeonLight) 0, true);
  233. Veh.SetNeonLightsOn((VehicleNeonLight) 1, true);
  234. Traffic.ColorRandom = new Random();
  235. 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)));
  236. Veh.set_WindowTint((VehicleWindowTint) 1);
  237. }
  238.  
  239. public static string GetPlayerZone()
  240. {
  241. Ped character = Game.get_Player().get_Character();
  242. return (string) Function.Call<string>((Hash) -3634293310464400950L, new InputArgument[3]
  243. {
  244. InputArgument.op_Implicit((float) ((Entity) character).get_Position().X),
  245. InputArgument.op_Implicit((float) ((Entity) character).get_Position().Y),
  246. InputArgument.op_Implicit((float) ((Entity) character).get_Position().Z)
  247. });
  248. }
  249. }
  250. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement