GammixSAMP

vehicleplus.inc - By Gammix

Jun 9th, 2015
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.97 KB | None | 0 0
  1. /*
  2. Vehicles Plus Include (vehicleplus.inc)
  3. * Add new features to your vehicles system and have the missing or actually the correct word is needed vehicle functions
  4. * Gives you advantage over ordinary vehicle manager includes, this is compatiable with other scripts (using property function)
  5. * Now EditVehicle avalaible with this include
  6.  
  7. Author: (creator)
  8. * Gammix
  9.  
  10. Contributors:
  11. * Admigo - Petrol cap offsets array
  12. * Emmet_ - random car colors and top speed array
  13.  
  14. (c) Copyright 2015
  15. * This file is provided as is (no warranties).
  16. */
  17.  
  18. /*
  19. FUNCTIONS:
  20. native CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:rotation, color1 = -1, color2 = -1, respawn_delay = -1, addsiren = 0, worldid = 0, interiorid = 0);
  21. native GetVehicleInterior(vehicleid);
  22. native GetVehicleColor(vehicleid, &color1, &color2);
  23. native GetVehiclePaintjob(vehicleid);
  24. native RemoveVehiclePaintjob(vehicleid);
  25. native SetVehicleHorn(vehicleid, soundid);
  26. native GetVehicleHorn(vehicleid);
  27. native ToggleVehicleDamageUpdate(vehicleid, type, bool:toggle);
  28. native IsVehicleDamageToggled(vehicleid, type);
  29. native UpdateVehicleDamageStatusEx(vehicleid, type, update);
  30. native ToggleVehiclePetrolCapDestroy(vehicleid, bool:toggle);
  31. native IsPetrolCapDestroyToggled(vehicleid);
  32. native IsVehicleOccupied(vehicleid);
  33. native EditVehicle(playerid, vehicleid);
  34. native GetVehicleName(vehicleid, string[], len = sizeof(string));
  35. native GetVehicleModelName(modelid, string[], len = sizeof(string));
  36. native GetVehicleParams(vehicleid, type);
  37. native SetVehicleParams(vehicleid, type, set);
  38. native Float:GetVehicleSpeed(vehicleid, bool:kmh = true);
  39. native TeleportVehicle(vehicleid, Float:x, Float:y, Float:z, Float:rotation, worldid = -1, interiorid = -1);
  40. native IsObjectAttachedToVehicle(objectid, vehicleid);
  41. native GetVehicleSlotAttachedObject(vehicleid, slot);
  42. native SetVehicleSpeedCap(vehicleid, maxspeed);
  43. native GetVehicleSpeedCap(vehicleid);
  44. native DisableVehicleSpeedCap(vehicleid);
  45. native GetVehicleTopSpeed(vehicleid);
  46. native GetVehicleModelTopSpeed(modelid);
  47. native CountAllVehicles();
  48. native DestroyAllVehicles();
  49.  
  50. CALLBACKS:
  51. public OnPlayerShootVehiclePetrolCap(playerid, vehicleid)
  52. public OnPlayerEditVehicle(playerid, vehicleid, response, Float:fX, Float:fY, Float:fZ, Float:fRotZ)
  53. public OnPlayerReachSpeedCapLimit(playerid, vehicleid, Float:speed)
  54. */
  55.  
  56. #define VEHICLE_DAMAGE_PANELS 0
  57. #define VEHICLE_DAMAGE_DOORS 1
  58. #define VEHICLE_DAMAGE_LIGHTS 2
  59. #define VEHICLE_DAMAGE_TIRES 3
  60.  
  61. #if ! defined MAX_VEHICLE_ATTACHED_OBJECTS
  62. #define MAX_VEHICLE_ATTACHED_OBJECTS 30
  63. #endif
  64.  
  65. static gPlayerEdit[MAX_PLAYERS] = INVALID_VEHICLE_ID;
  66. static gVehicleAttachedObject[MAX_VEHICLES][MAX_VEHICLE_ATTACHED_OBJECTS];
  67.  
  68. static const gVehicleNames[][] =
  69. {
  70. "Landstalker","Bravura","Buffalo","Linerunner","Perrenial","Sentinel","Dumper",
  71. "Firetruck","Trashmaster","Stretch","Manana","Infernus","Voodoo","Pony","Mule",
  72. "Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington",
  73. "Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar",
  74. "Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer 1","Previon",
  75. "Coach","Cabbie","Stallion","Rumpo","RC Bandit","Romero","Packer","Monster",
  76. "Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer 2","Turismo",
  77. "Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van",
  78. "Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic",
  79. "Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre",
  80. "Rustler","ZR-350","Walton","Regina","Comet","BMX","Burrito","Camper","Marquis",
  81. "Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood",
  82. "Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson",
  83. "Mesa","RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher",
  84. "Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt",
  85. "Tanker", "Roadtrain","Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900",
  86. "NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck",
  87. "Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan",
  88. "Blade","Freight","Streak","Vortex","Vincent","Bullet","Clover","Sadler",
  89. "Firetruck LA","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit",
  90. "Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus","Jester",
  91. "Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna",
  92. "Bandito","Freight Flat","Streak Carriage","Kart","Mower","Duneride","Sweeper",
  93. "Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan",
  94. "Tug","Trailer 3","Emperor","Wayfarer","Euros","Hotdog","Club","Freight Carriage",
  95. "Trailer 3","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)",
  96. "Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale",
  97. "Sadler","Luggage Trailer A","Luggage Trailer B","Stair Trailer","Boxville","Farm Plow",
  98. "Utility Trailer"
  99. };
  100.  
  101. static const Float:gVehiclePetrolCapOffsets[][3] =//thanks to Admigo
  102. {
  103. {-1.06,-2.07,-0.03},
  104. {1.25,-0.91,0.05},
  105. {1.11,-1.92,0.17},
  106. {-1.46,0.02,-0.66},
  107. {-1.03,-2.37,0.06},
  108. {-0.86,-2.16,-0.08},
  109. {0.00,0.00,0.00},
  110. {-1.07,-3.74,-0.42},
  111. {-1.46,1.24,-0.57},
  112. {-1.04,-2.82,0.14},
  113. {-0.96,-1.66,0.23},
  114. {1.06,-2.10,0.09},
  115. {0.00,0.00,0.00},
  116. {-0.46,0.53,-0.79},
  117. {-0.66,-0.71,-0.70},
  118. {-1.07,-2.06,0.05},
  119. {-1.16,-2.72,-0.21},
  120. {0.00,0.00,0.00},
  121. {-1.24,-1.76,0.03},
  122. {-1.09,-1.99,0.06},
  123. {-1.03,-2.14,0.08},
  124. {-1.02,-2.43,-0.14},
  125. {-0.93,-0.41,-0.19},
  126. {-1.13,-1.90,-0.28},
  127. {-1.11,-0.54,-0.10},
  128. {0.00,0.00,0.00},
  129. {-1.00,-2.16,0.06},
  130. {-1.27,-3.18,-0.18},
  131. {-1.01,-2.65,-0.56},
  132. {0.00,0.00,0.00},
  133. {0.00,0.00,0.00},
  134. {-1.32,-5.47,-0.12},
  135. {0.00,0.00,0.00},
  136. {-1.51,0.15,-0.67},
  137. {0.00,0.00,0.00},
  138. {0.00,0.00,0.00},
  139. {-1.02,-1.81,0.16},
  140. {-1.24,-4.98,-0.51},
  141. {-1.06,-1.93,-0.00},
  142. {-1.07,-1.50,0.07},
  143. {-0.89,-0.47,-0.46},
  144. {0.00,0.00,0.00},
  145. {-1.17,-2.20,0.08},
  146. {-1.24,1.25,-0.91},
  147. {0.00,0.00,0.00},
  148. {-1.07,-1.95,0.13},
  149. {0.00,0.00,0.00},
  150. {0.00,0.00,0.00},
  151. {0.00,0.00,0.00},
  152. {0.00,0.00,0.00},
  153. {0.00,0.00,0.00},
  154. {1.08,-1.21,-0.03},
  155. {0.00,0.00,0.00},
  156. {0.00,0.00,0.00},
  157. {0.00,0.00,0.00},
  158. {-1.52,0.00,-0.74},
  159. {0.73,-0.05,-0.59},
  160. {0.00,0.00,0.00},
  161. {-1.11,-2.04,-0.09},
  162. {-0.97,-2.30,0.21},
  163. {0.00,0.00,0.00},
  164. {0.00,0.00,0.00},
  165. {0.00,0.00,0.00},
  166. {-0.25,0.20,-0.17},
  167. {0.00,0.00,0.00},
  168. {0.00,0.00,0.00},
  169. {0.00,0.00,0.00},
  170. {-0.92,-2.30,0.08},
  171. {-0.07,0.17,0.69},
  172. {0.00,0.00,0.00},
  173. {-1.17,-2.37,0.24},
  174. {0.00,0.00,0.00},
  175. {0.00,0.00,0.00},
  176. {0.00,0.00,0.00},
  177. {0.00,0.00,0.00},
  178. {-1.09,-1.60,0.13},
  179. {0.00,0.00,0.00},
  180. {-1.03,-1.52,0.15},
  181. {1.01,-0.33,0.23},
  182. {-1.09,-1.98,0.09},
  183. {-1.12,-0.88,0.14},
  184. {0.00,0.00,0.00},
  185. {1.03,-2.26,0.00},
  186. {0.80,-2.50,-0.05},
  187. {0.00,0.00,0.00},
  188. {-0.88,0.71,0.03},
  189. {-0.66,-3.17,0.58},
  190. {0.00,0.00,0.00},
  191. {0.00,0.00,0.00},
  192. {1.22,-0.74,0.02},
  193. {0.00,0.00,0.00},
  194. {-1.05,-2.18,0.02},
  195. {-1.07,-2.09,0.17},
  196. {0.00,0.00,0.00},
  197. {-1.00,-2.20,0.14},
  198. {1.16,-1.91,-0.11},
  199. {1.08,-1.83,0.15},
  200. {0.00,0.00,0.00},
  201. {-1.21,-0.01,0.09},
  202. {-1.19,-1.09,-0.31},
  203. {-0.91,-1.70,-0.06},
  204. {0.00,0.00,0.00},
  205. {-0.96,-1.88,0.13},
  206. {-0.98,-2.03,0.04},
  207. {-1.14,-1.82,0.13},
  208. {1.22,-0.74,0.00},
  209. {0.96,-1.11,-0.11},
  210. {-1.08,-2.30,0.08},
  211. {-1.35,-3.05,-0.67},
  212. {0.00,0.00,0.00},
  213. {0.00,0.00,0.00},
  214. {0.00,0.00,0.00},
  215. {0.00,0.00,0.00},
  216. {0.00,0.00,0.00},
  217. {-1.50,-0.88,-0.24},
  218. {-1.08,0.51,-1.43},
  219. {-1.13,-2.44,-0.01},
  220. {-1.11,-1.95,0.08},
  221. {1.09,-2.19,-0.08},
  222. {0.00,0.00,0.00},
  223. {0.00,0.00,0.00},
  224. {-0.17,0.13,0.52},
  225. {-0.14,0.18,0.53},
  226. {-0.18,0.24,0.49},
  227. {1.24,0.46,-1.06},
  228. {-1.31,-0.50,-0.07},
  229. {-0.94,-1.94,0.05},
  230. {-1.13,-1.70,0.16},
  231. {-0.51,-2.07,0.01},
  232. {-1.15,-2.20,0.22},
  233. {0.00,0.00,0.00},
  234. {0.00,0.00,0.00},
  235. {0.00,-2.43,-0.91},
  236. {0.91,-1.97,0.11},
  237. {-1.01,-0.83,-0.20},
  238. {-1.13,-0.55,0.28},
  239. {-0.98,-1.69,0.06},
  240. {0.00,0.00,0.00},
  241. {0.00,0.00,0.00},
  242. {0.00,0.00,0.00},
  243. {-1.23,-2.51,-0.03},
  244. {0.00,0.00,0.00},
  245. {-0.97,-1.92,0.31},
  246. {-0.96,-0.94,-0.01},
  247. {-1.15,2.04,0.32},
  248. {0.00,0.00,0.00},
  249. {1.22,-1.99,0.16},
  250. {-1.09,-2.00,0.13},
  251. {0.00,0.00,0.00},
  252. {-0.89,-1.14,0.18},
  253. {-1.10,-2.40,-0.02},
  254. {-1.03,-2.66,0.07},
  255. {-0.95,-0.94,0.45},
  256. {0.00,0.00,0.00},
  257. {1.27,-2.37,0.13},
  258. {-0.80,-1.47,0.17},
  259. {0.00,0.00,0.00},
  260. {0.00,0.00,0.00},
  261. {-0.84,-1.92,0.23},
  262. {-1.01,-1.76,0.25},
  263. {0.98,-1.83,0.20},
  264. {1.13,-2.28,0.11},
  265. {0.93,-0.71,0.05},
  266. {0.00,0.00,0.00},
  267. {0.00,0.00,0.00},
  268. {0.95,-0.86,0.09},
  269. {1.18,-2.26,0.06},
  270. {0.00,0.00,0.00},
  271. {0.00,0.00,0.00},
  272. {0.00,0.00,0.00},
  273. {0.00,0.00,0.00},
  274. {0.62,-0.37,0.46},
  275. {-0.35,-1.03,0.24},
  276. {0.00,0.00,0.00},
  277. {-0.59,-0.94,0.26},
  278. {0.00,0.00,0.00},
  279. {0.00,0.00,0.00},
  280. {0.00,0.00,0.00},
  281. {-1.33,2.89,-0.02},
  282. {1.13,-2.29,0.16},
  283. {1.23,-1.77,0.29},
  284. {-0.22,0.01,0.54},
  285. {-0.90,0.15,-0.32},
  286. {-0.62,0.37,-0.12},
  287. {0.00,0.00,0.00},
  288. {1.07,-2.29,0.20},
  289. {0.00,0.00,0.00},
  290. {-1.22,-1.21,0.12},
  291. {-1.20,-2.12,0.23},
  292. {0.98,-0.89,0.10},
  293. {0.00,0.00,0.00},
  294. {0.00,0.00,0.00},
  295. {0.00,0.00,0.00},
  296. {0.00,0.00,0.00},
  297. {0.00,0.00,0.00},
  298. {0.00,0.00,0.00},
  299. {-0.97,-2.16,0.06},
  300. {-1.02,-2.16,0.07},
  301. {-1.08,-1.95,0.18},
  302. {0.00,0.00,0.00},
  303. {0.95,-2.01,0.06},
  304. {-1.36,-1.69,0.92},
  305. {0.97,-1.95,0.08},
  306. {1.24,-2.20,-0.04},
  307. {0.00,0.00,0.00},
  308. {-0.95,-0.93,-0.02},
  309. {0.00,0.00,0.00},
  310. {0.00,0.00,0.00},
  311. {0.00,0.00,0.00},
  312. {-1.26,-0.03,0.09},
  313. {0.00,0.00,0.00},
  314. {0.00,0.00,0.00}
  315. };
  316.  
  317. static const gVehicleColors[][] = //carcols.dat
  318. {
  319. {16, 004, 001, 123, 001, 113, 001, 101, 001, 075, 001, 062, 001, 040, 001, 036, 001},
  320. {16, 041, 041, 047, 047, 052, 052, 066, 066, 074, 074, 087, 087, 091, 091, 113, 113},
  321. {16, 010, 010, 013, 013, 022, 022, 030, 030, 039, 039, 090, 090, 098, 098, 110, 110},
  322. {16, 036, 001, 037, 001, 030, 001, 028, 001, 025, 001, 040, 001, 101, 001, 113, 001},
  323. {16, 113, 039, 119, 050, 123, 092, 109, 100, 101, 101, 095, 105, 083, 110, 066, 025},
  324. {16, 011, 001, 024, 001, 036, 001, 040, 001, 075, 001, 091, 001, 123, 001, 004, 001},
  325. {2, 001, 001},
  326. {2, 003, 001},
  327. {2, 026, 026},
  328. {2, 001, 001},
  329. {16, 004, 001, 009, 001, 010, 001, 025, 001, 036, 001, 040, 001, 045, 001, 084, 001},
  330. {16, 012, 001, 064, 001, 123, 001, 116, 001, 112, 001, 106, 001, 080, 001, 075, 001},
  331. {16, 009, 001, 010, 008, 011, 001, 025, 008, 027, 001, 029, 008, 030, 001, 037, 008},
  332. {16, 087, 001, 088, 001, 091, 001, 105, 001, 109, 001, 119, 001, 004, 001, 025, 001},
  333. {16, 025, 001, 028, 001, 043, 001, 067, 001, 072, 001, 009, 001, 095, 001, 024, 001},
  334. {16, 020, 001, 025, 001, 036, 001, 040, 001, 062, 001, 075, 001, 092, 001, 000, 001},
  335. {2, 001, 003},
  336. {0, 000, 000},
  337. {16, 119, 119, 117, 227, 114, 114, 108, 108, 095, 095, 081, 081, 061, 061, 041, 041},
  338. {16, 045, 075, 047, 076, 033, 075, 013, 076, 054, 075, 069, 076, 059, 075, 087, 076},
  339. {2, 006, 001},
  340. {16, 004, 001, 013, 001, 025, 001, 030, 001, 036, 001, 040, 001, 075, 001, 095, 001},
  341. {14, 096, 025, 097, 025, 101, 025, 111, 031, 113, 036, 083, 057, 067, 059},
  342. {12, 001, 016, 001, 056, 001, 017, 001, 053, 001, 005, 001, 035},
  343. {16, 001, 000, 002, 002, 003, 002, 003, 006, 006, 016, 015, 030, 024, 053, 035, 061},
  344. {2, 043, 000},
  345. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  346. {2, 000, 001},
  347. {2, 004, 075},
  348. {16, 012, 012, 013, 013, 014, 014, 001, 002, 002, 001, 001, 003, 003, 001, 010, 010},
  349. {2, 046, 026},
  350. {16, 071, 059, 075, 059, 092, 072, 047, 074, 055, 083, 059, 083, 071, 087, 082, 087},
  351. {2, 043, 000},
  352. {2, 043, 000},
  353. {14, 001, 001, 012, 012, 002, 002, 006, 006, 004, 004, 046, 046, 053, 053},
  354. {2, 001, 001},
  355. {14, 083, 001, 087, 001, 092, 001, 095, 001, 109, 001, 119, 045, 011, 001},
  356. {16, 054, 007, 079, 007, 087, 007, 095, 016, 098, 020, 105, 020, 123, 020, 125, 021},
  357. {2, 006, 076},
  358. {16, 057, 008, 008, 017, 043, 021, 054, 038, 067, 008, 037, 078, 065, 079, 025, 078},
  359. {16, 034, 034, 032, 032, 020, 020, 110, 110, 066, 066, 084, 084, 118, 118, 121, 121},
  360. {16, 002, 096, 079, 042, 082, 054, 067, 086, 126, 096, 070, 096, 110, 054, 067, 098},
  361. {16, 000, 000, 011, 105, 025, 109, 036, 000, 040, 036, 075, 036, 000, 036, 000, 109},
  362. {16, 004, 001, 020, 001, 024, 001, 025, 001, 036, 001, 040, 001, 054, 001, 084, 001},
  363. {12, 032, 036, 032, 042, 032, 053, 032, 066, 032, 014, 032, 032},
  364. {16, 034, 034, 035, 035, 037, 037, 039, 039, 041, 041, 043, 043, 045, 045, 047, 047},
  365. {32, 000, 000, 000, 001, 001, 005, 001, 001, 003, 003, 000, 001, 001, 022, 001, 001, 001, 035, 001, 001, 001, 044, 001, 001, 001, 053, 001, 001, 001, 057, 001, 001},
  366. {2, 075, 002},
  367. {2, 001, 003},
  368. {2, 001, 074},
  369. {2, 001, 001},
  370. {16, 123, 123, 125, 125, 036, 036, 016, 016, 018, 018, 046, 046, 061, 061, 075, 075},
  371. {16, 001, 003, 001, 005, 001, 016, 001, 022, 001, 035, 001, 044, 001, 053, 001, 057},
  372. {2, 056, 056},
  373. {2, 026, 026},
  374. {16, 084, 015, 084, 058, 084, 031, 032, 074, 043, 031, 001, 031, 077, 031, 032, 074},
  375. {16, 084, 063, 091, 063, 102, 065, 105, 072, 110, 093, 121, 093, 012, 095, 023, 001},
  376. {16, 058, 001, 002, 001, 063, 001, 018, 001, 032, 001, 045, 001, 013, 001, 034, 001},
  377. {16, 091, 001, 101, 001, 109, 001, 113, 001, 004, 001, 025, 001, 030, 001, 036, 001},
  378. {16, 026, 026, 028, 028, 044, 044, 051, 051, 057, 057, 072, 072, 106, 106, 112, 112},
  379. {16, 001, 003, 001, 009, 001, 018, 001, 030, 017, 023, 046, 023, 046, 032, 057, 034},
  380. {16, 036, 001, 037, 001, 043, 001, 053, 001, 061, 001, 075, 001, 079, 001, 088, 001},
  381. {16, 012, 012, 013, 013, 014, 014, 001, 002, 002, 001, 001, 003, 003, 001, 010, 010},
  382. {16, 079, 079, 084, 084, 007, 007, 011, 011, 019, 019, 022, 022, 036, 036, 053, 053},
  383. {2, 014, 075},
  384. {2, 014, 075},
  385. {16, 067, 076, 068, 076, 078, 076, 002, 076, 016, 076, 018, 076, 025, 076, 045, 088},
  386. {16, 051, 001, 058, 008, 060, 001, 068, 008, 002, 001, 013, 008, 022, 001, 036, 008},
  387. {8, 006, 006, 046, 046, 053, 053, 003, 003},
  388. {0, 000, 000},
  389. {2, 043, 000},
  390. {16, 120, 117, 103, 111, 120, 114, 074, 091, 120, 112, 074, 083, 120, 113, 066, 071},
  391. {4, 056, 015, 056, 053},
  392. {4, 056, 015, 056, 053},
  393. {16, 097, 001, 081, 001, 105, 001, 110, 001, 091, 001, 074, 001, 084, 001, 083, 001},
  394. {16, 002, 039, 009, 039, 017, 001, 021, 001, 033, 000, 037, 000, 041, 029, 056, 029},
  395. {16, 006, 007, 007, 006, 001, 006, 089, 091, 119, 117, 103, 102, 077, 087, 071, 077},
  396. {16, 092, 001, 094, 001, 101, 001, 121, 001, 000, 001, 022, 001, 036, 001, 075, 001},
  397. {16, 072, 001, 066, 001, 059, 001, 045, 001, 040, 001, 039, 001, 035, 001, 020, 001},
  398. {16, 027, 036, 059, 036, 060, 035, 055, 041, 054, 031, 049, 023, 045, 032, 040, 029},
  399. {14, 073, 045, 012, 012, 002, 002, 006, 006, 004, 004, 046, 046, 053, 053},
  400. {16, 001, 001, 003, 003, 006, 006, 046, 046, 065, 009, 014, 001, 012, 009, 026, 001},
  401. {16, 041, 041, 048, 048, 052, 052, 064, 064, 071, 071, 085, 085, 010, 010, 062, 062},
  402. {32, 001, 031, 001, 000, 001, 031, 001, 000, 001, 020, 003, 000, 001, 005, 000, 000, 000, 006, 003, 000, 003, 006, 003, 000, 016, 000, 008, 000, 017, 000, 120, 000},
  403. {8, 012, 035, 050, 032, 040, 026, 066, 036},
  404. {14, 001, 073, 001, 074, 001, 075, 001, 076, 001, 077, 001, 078, 001, 079},
  405. {2, 001, 001},
  406. {16, 026, 014, 029, 042, 026, 057, 054, 029, 026, 003, 003, 029, 012, 039, 074, 035},
  407. {4, 002, 026, 002, 029},
  408. {12, 013, 118, 014, 123, 120, 123, 112, 120, 084, 110, 076, 102},
  409. {2, 000, 000},
  410. {12, 040, 065, 071, 072, 052, 066, 064, 072, 030, 072, 060, 072},
  411. {16, 030, 026, 077, 026, 081, 027, 024, 055, 028, 056, 049, 059, 052, 069, 071, 107},
  412. {2, 036, 013},
  413. {16, 007, 094, 036, 088, 051, 075, 053, 075, 058, 067, 075, 067, 075, 061, 079, 062},
  414. {16, 123, 124, 119, 122, 118, 117, 116, 115, 114, 108, 101, 106, 088, 099, 005, 006},
  415. {16, 074, 072, 066, 072, 053, 056, 037, 019, 022, 022, 020, 020, 009, 014, 000, 000},
  416. {2, 000, 001},
  417. {16, 011, 123, 013, 120, 020, 117, 024, 112, 027, 107, 036, 105, 037, 107, 043, 093},
  418. {16, 109, 025, 109, 032, 112, 032, 010, 032, 030, 044, 032, 052, 084, 066, 084, 069},
  419. {16, 075, 084, 040, 084, 040, 110, 028, 119, 025, 119, 021, 119, 013, 119, 004, 119},
  420. {2, 014, 075},
  421. {16, 083, 066, 087, 074, 087, 075, 098, 083, 101, 100, 103, 101, 117, 116, 123, 036},
  422. {16, 036, 117, 036, 013, 042, 030, 042, 033, 054, 036, 075, 079, 092, 101, 098, 109},
  423. {16, 051, 039, 057, 038, 045, 029, 034, 009, 065, 009, 014, 001, 012, 009, 026, 001},
  424. {12, 013, 118, 014, 123, 120, 123, 112, 120, 084, 110, 076, 102},
  425. {10, 003, 003, 006, 006, 007, 007, 052, 052, 076, 076},
  426. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  427. {2, 001, 001},
  428. {16, 007, 001, 074, 001, 061, 001, 016, 001, 025, 001, 030, 001, 036, 001, 053, 001},
  429. {16, 043, 043, 046, 046, 039, 039, 028, 028, 016, 016, 006, 006, 005, 005, 002, 002},
  430. {16, 003, 090, 004, 090, 007, 068, 008, 066, 012, 060, 027, 097, 034, 051, 037, 051},
  431. {16, 017, 039, 015, 123, 032, 112, 045, 088, 052, 071, 057, 067, 061, 096, 096, 096},
  432. {16, 038, 051, 021, 036, 021, 034, 030, 034, 054, 034, 055, 020, 048, 018, 051, 006},
  433. {16, 010, 001, 025, 001, 028, 001, 036, 001, 040, 001, 054, 001, 075, 001, 113, 001},
  434. {16, 013, 076, 024, 077, 063, 078, 042, 076, 054, 077, 039, 078, 011, 076, 062, 077},
  435. {16, 116, 001, 119, 001, 122, 001, 004, 001, 009, 001, 024, 001, 027, 001, 036, 001},
  436. {16, 037, 036, 036, 036, 040, 036, 043, 041, 047, 041, 051, 072, 054, 075, 055, 084},
  437. {16, 002, 039, 009, 039, 017, 001, 021, 001, 033, 000, 037, 000, 041, 029, 056, 029},
  438. {2, 001, 001},
  439. {0, 000, 000},
  440. {16, 074, 074, 075, 013, 087, 118, 092, 003, 115, 118, 025, 118, 036, 000, 118, 118},
  441. {16, 003, 003, 003, 008, 006, 025, 007, 079, 008, 082, 036, 105, 039, 106, 051, 118},
  442. {0, 000, 000},
  443. {32, 060, 024, 023, 000, 061, 027, 123, 000, 065, 031, 031, 000, 061, 061, 030, 000, 081, 035, 023, 000, 062, 061, 062, 000, 083, 066, 064, 000, 083, 064, 064, 000},
  444. {14, 001, 001, 017, 020, 018, 020, 022, 030, 036, 043, 044, 051, 052, 054},
  445. {16, 002, 039, 009, 039, 017, 001, 021, 001, 033, 000, 037, 000, 041, 029, 056, 029},
  446. {16, 052, 001, 053, 001, 066, 001, 075, 001, 076, 001, 081, 001, 095, 001, 109, 001},
  447. {0, 000, 000},
  448. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  449. {16, 110, 001, 111, 001, 112, 001, 114, 001, 119, 001, 122, 001, 004, 001, 013, 001},
  450. {12, 002, 035, 036, 002, 051, 053, 091, 002, 011, 022, 040, 035},
  451. {0, 000, 000},
  452. {16, 073, 001, 074, 001, 075, 001, 077, 001, 079, 001, 083, 001, 084, 001, 091, 001},
  453. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  454. {16, 003, 001, 028, 001, 031, 001, 055, 001, 066, 001, 097, 001, 123, 001, 118, 001},
  455. {16, 009, 001, 012, 001, 026, 096, 030, 096, 032, 001, 037, 001, 057, 096, 071, 096},
  456. {2, 001, 001},
  457. {2, 001, 001},
  458. {14, 096, 067, 086, 070, 079, 074, 070, 086, 061, 098, 075, 075, 075, 091},
  459. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  460. {16, 051, 001, 058, 008, 060, 001, 068, 008, 002, 001, 013, 008, 022, 001, 036, 008},
  461. {16, 013, 118, 024, 118, 031, 093, 032, 092, 045, 092, 113, 092, 119, 113, 122, 113},
  462. {16, 076, 008, 032, 008, 043, 008, 067, 008, 011, 011, 008, 090, 002, 002, 083, 013},
  463. {2, 003, 001},
  464. {16, 050, 001, 047, 001, 044, 096, 040, 096, 039, 001, 030, 001, 028, 096, 009, 096},
  465. {16, 062, 037, 078, 038, 002, 062, 003, 087, 002, 078, 113, 078, 119, 062, 007, 078},
  466. {16, 122, 001, 123, 001, 125, 001, 010, 001, 024, 001, 037, 001, 055, 001, 066, 001},
  467. {2, 001, 001},
  468. {16, 074, 039, 072, 039, 075, 039, 079, 039, 083, 036, 084, 036, 089, 035, 091, 035},
  469. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  470. {16, 067, 001, 072, 001, 075, 001, 083, 001, 091, 001, 101, 001, 109, 001, 020, 001},
  471. {6, 056, 056, 049, 049, 026, 124},
  472. {16, 038, 009, 055, 023, 061, 074, 071, 087, 091, 087, 098, 114, 102, 119, 111, 003},
  473. {16, 053, 032, 015, 032, 045, 032, 034, 030, 065, 032, 014, 032, 012, 032, 043, 032},
  474. {16, 051, 001, 058, 001, 060, 001, 068, 001, 002, 001, 013, 001, 022, 001, 036, 001},
  475. {2, 001, 001},
  476. {2, 001, 001},
  477. {16, 112, 001, 116, 001, 117, 001, 024, 001, 030, 001, 035, 001, 036, 001, 040, 001},
  478. {16, 051, 001, 058, 008, 060, 001, 068, 008, 002, 001, 013, 008, 022, 001, 036, 008},
  479. {16, 052, 039, 009, 039, 017, 001, 021, 001, 033, 000, 037, 000, 041, 029, 056, 029},
  480. {16, 057, 008, 008, 017, 043, 021, 054, 038, 067, 008, 037, 078, 065, 079, 025, 078},
  481. {16, 036, 001, 035, 001, 017, 001, 011, 001, 116, 001, 113, 001, 101, 001, 092, 001},
  482. {2, 001, 006},
  483. {0, 000, 000},
  484. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  485. {16, 109, 001, 030, 008, 095, 001, 084, 008, 083, 001, 072, 008, 071, 001, 052, 008},
  486. {16, 097, 096, 088, 064, 090, 096, 093, 064, 097, 096, 099, 081, 102, 114, 114, 001},
  487. {16, 002, 039, 009, 039, 017, 001, 021, 001, 033, 000, 037, 000, 041, 029, 056, 029},
  488. {0, 000, 000},
  489. {2, 001, 001},
  490. {12, 002, 035, 036, 002, 051, 053, 091, 002, 011, 022, 040, 035},
  491. {16, 094, 001, 101, 001, 116, 001, 117, 001, 004, 001, 025, 001, 030, 001, 037, 001},
  492. {16, 091, 038, 115, 043, 085, 006, 079, 007, 078, 008, 077, 018, 079, 018, 086, 024},
  493. {2, 026, 026},
  494. {16, 012, 001, 019, 096, 031, 064, 025, 096, 038, 001, 051, 096, 057, 001, 066, 096},
  495. {16, 067, 001, 068, 096, 072, 001, 074, 008, 075, 096, 076, 008, 079, 001, 084, 096},
  496. {12, 001, 003, 008, 007, 008, 010, 008, 016, 023, 031, 040, 044},
  497. {2, 001, 001},
  498. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  499. {18, 092, 092, 081, 081, 067, 067, 066, 066, 061, 061, 053, 053, 051, 051, 047, 047, 043, 043},
  500. {16, 054, 001, 058, 001, 066, 001, 072, 001, 075, 001, 087, 001, 101, 001, 036, 001},
  501. {16, 041, 010, 041, 020, 049, 011, 056, 123, 110, 113, 112, 116, 114, 118, 119, 101},
  502. {2, 001, 001},
  503. {2, 001, 001},
  504. {16, 037, 037, 042, 042, 053, 053, 062, 062, 007, 007, 010, 010, 011, 011, 015, 015},
  505. {16, 119, 001, 122, 001, 008, 001, 010, 001, 013, 001, 025, 001, 027, 001, 032, 001},
  506. {16, 036, 001, 040, 001, 043, 001, 053, 001, 072, 001, 075, 001, 095, 001, 101, 001},
  507. {2, 001, 001},
  508. {16, 037, 037, 031, 031, 023, 023, 022, 022, 007, 007, 124, 124, 114, 114, 112, 112},
  509. {0, 000, 000},
  510. {2, 001, 001},
  511. {2, 001, 001},
  512. {16, 051, 001, 058, 008, 060, 001, 068, 008, 002, 001, 013, 008, 022, 001, 036, 008},
  513. {0, 000, 000},
  514. {2, 112, 020},
  515. {2, 000, 001},
  516. {2, 000, 001},
  517. {2, 000, 001},
  518. {2, 000, 001},
  519. {16, 081, 008, 032, 008, 043, 008, 067, 008, 011, 011, 008, 090, 002, 002, 083, 013},
  520. {2, 001, 001},
  521. {16, 058, 001, 069, 001, 075, 077, 018, 001, 032, 001, 045, 045, 013, 001, 034, 001},
  522. {16, 058, 001, 069, 001, 075, 077, 018, 001, 032, 001, 045, 045, 013, 001, 034, 001},
  523. {16, 067, 076, 068, 076, 078, 076, 002, 076, 016, 076, 018, 076, 025, 076, 045, 088},
  524. {16, 061, 008, 032, 008, 043, 008, 067, 008, 011, 011, 008, 090, 002, 002, 083, 013},
  525. {0, 000, 000},
  526. {0, 000, 000},
  527. {2, 001, 001},
  528. {2, 036, 036},
  529. {0, 000, 000},
  530. {0, 000, 000}
  531. };
  532.  
  533. static const gVehicleTopSpeed[] =
  534. {
  535. 157, 147, 186, 110, 133, 164, 110, 148, 100, 158, 129, 221, 168, 110, 105, 192, 154, 270,
  536. 115, 149, 145, 154, 140, 99, 135, 270, 173, 165, 157, 201, 190, 130, 94, 110, 167, 0, 149,
  537. 158, 142, 168, 136, 145, 139, 126, 110, 164, 270, 270, 111, 0, 0, 193, 270, 60, 135, 157,
  538. 106, 95, 157, 136, 270, 160, 111, 142, 145, 145, 147, 140, 144, 270, 157, 110, 190, 190,
  539. 149, 173, 270, 186, 117, 140, 184, 73, 156, 122, 190, 99, 64, 270, 270, 139, 157, 149, 140,
  540. 270, 214, 176, 162, 270, 108, 123, 140, 145, 216, 216, 173, 140, 179, 166, 108, 79, 101, 270,
  541. 270, 270, 120, 142, 157, 157, 164, 270, 270, 160, 176, 151, 130, 160, 158, 149, 176, 149, 60,
  542. 70, 110, 167, 168, 158, 173, 0, 0, 270, 149, 203, 164, 151, 150, 147, 149, 142, 270, 153, 145,
  543. 157, 121, 270, 144, 158, 113, 113, 156, 178, 169, 154, 178, 270, 145, 165, 160, 173, 146, 0, 0,
  544. 93, 60, 110, 60, 158, 158, 270, 130, 158, 153, 151, 136, 85, 0, 153, 142, 165, 108, 162, 0, 0,
  545. 270, 270, 130, 190, 175, 175, 175, 158, 151, 110, 169, 171, 148, 152, 0, 0, 0, 108, 0, 0
  546. };
  547.  
  548. #define v_interior 0
  549. #define v_color<%1> (%1 + 1)
  550. #define v_paintjob 3
  551. #define v_horn 4
  552. #define v_damage<%1> (%1 + 5)
  553. #define v_petrolcap 9
  554. #define v_editor 10
  555. #define v_speedcap 11
  556.  
  557. stock static Vehicle_SetPropertyInt(vehicleid, type, set)
  558. {
  559. new string[35];
  560. switch(type)
  561. {
  562. case v_interior: format(string, sizeof(string), "%i_v_interior", vehicleid);
  563. case v_color<0>: format(string, sizeof(string), "%i_v_color_1", vehicleid);
  564. case v_color<1>: format(string, sizeof(string), "%i_v_color_2", vehicleid);
  565. case v_paintjob: format(string, sizeof(string), "%i_v_paintjob", vehicleid);
  566. case v_horn: format(string, sizeof(string), "%i_v_horn", vehicleid);
  567. case v_damage<0>: format(string, sizeof(string), "%i_v_damage_1", vehicleid);
  568. case v_damage<1>: format(string, sizeof(string), "%i_v_damage_2", vehicleid);
  569. case v_damage<2>: format(string, sizeof(string), "%i_v_damage_3", vehicleid);
  570. case v_damage<3>: format(string, sizeof(string), "%i_v_damage_4", vehicleid);
  571. case v_petrolcap: format(string, sizeof(string), "%i_v_petrolcap", vehicleid);
  572. case v_editor: format(string, sizeof(string), "%i_v_editor", vehicleid);
  573. case v_speedcap: format(string, sizeof(string), "%i_v_speedcap", vehicleid);
  574. }
  575.  
  576. return setproperty(.name = string, .value = set);
  577. }
  578.  
  579. stock static Vehicle_GetPropertyInt(vehicleid, type)
  580. {
  581. new string[35];
  582. switch(type)
  583. {
  584. case v_interior: format(string, sizeof(string), "%i_v_interior", vehicleid);
  585. case v_color<0>: format(string, sizeof(string), "%i_v_color_1", vehicleid);
  586. case v_color<1>: format(string, sizeof(string), "%i_v_color_2", vehicleid);
  587. case v_paintjob: format(string, sizeof(string), "%i_v_paintjob", vehicleid);
  588. case v_horn: format(string, sizeof(string), "%i_v_horn", vehicleid);
  589. case v_damage<0>: format(string, sizeof(string), "%i_v_damage_1", vehicleid);
  590. case v_damage<1>: format(string, sizeof(string), "%i_v_damage_2", vehicleid);
  591. case v_damage<2>: format(string, sizeof(string), "%i_v_damage_3", vehicleid);
  592. case v_damage<3>: format(string, sizeof(string), "%i_v_damage_4", vehicleid);
  593. case v_petrolcap: format(string, sizeof(string), "%i_v_petrolcap", vehicleid);
  594. case v_editor: format(string, sizeof(string), "%i_v_editor", vehicleid);
  595. case v_speedcap: format(string, sizeof(string), "%i_v_speedcap", vehicleid);
  596. }
  597.  
  598. return getproperty(.name = string);
  599. }
  600.  
  601. stock static Vehicle_DeleteProperties(vehicleid, type)
  602. {
  603. new string[35];
  604. switch(type)
  605. {
  606. case v_interior: format(string, sizeof(string), "%i_v_interior", vehicleid);
  607. case v_color<0>: format(string, sizeof(string), "%i_v_color_1", vehicleid);
  608. case v_color<1>: format(string, sizeof(string), "%i_v_color_2", vehicleid);
  609. case v_paintjob: format(string, sizeof(string), "%i_v_paintjob", vehicleid);
  610. case v_horn: format(string, sizeof(string), "%i_v_horn", vehicleid);
  611. case v_damage<0>: format(string, sizeof(string), "%i_v_damage_1", vehicleid);
  612. case v_damage<1>: format(string, sizeof(string), "%i_v_damage_2", vehicleid);
  613. case v_damage<2>: format(string, sizeof(string), "%i_v_damage_3", vehicleid);
  614. case v_damage<3>: format(string, sizeof(string), "%i_v_damage_4", vehicleid);
  615. case v_petrolcap: format(string, sizeof(string), "%i_v_petrolcap", vehicleid);
  616. case v_editor: format(string, sizeof(string), "%i_v_editor", vehicleid);
  617. case v_speedcap: format(string, sizeof(string), "%i_v_speedcap", vehicleid);
  618. }
  619.  
  620. return deleteproperty(.name = string);
  621. }
  622.  
  623. stock Vehicle_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:rotation, color1 = -1, color2 = -1, respawn_delay = -1, addsiren = 0, worldid = 0, interiorid = 0)
  624. {
  625. if(modelid < 400 || modelid > 610) return false;
  626.  
  627. if( (color1 == -1 || color2 == -1) &&
  628. gVehicleColors[(modelid - 400)][0])
  629. {
  630. if(gVehicleColors[(modelid - 400)][0] == 2)
  631. {
  632. color1 = gVehicleColors[(modelid - 400)][1];
  633. color2 = gVehicleColors[(modelid - 400)][2];
  634. }
  635. else
  636. {
  637. new index = random(gVehicleColors[(modelid - 400)][0]) & -2;
  638.  
  639. color1 = gVehicleColors[(modelid - 400)][++index];
  640. color2 = gVehicleColors[(modelid - 400)][++index];
  641. }
  642. }
  643.  
  644. new vehicleid;
  645. switch(modelid)
  646. {
  647. case 569, 570, 537, 538: vehicleid = AddStaticVehicleEx(modelid, x, y, z, rotation, color1, color2, respawn_delay, addsiren);
  648. default: vehicleid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, addsiren);
  649. }
  650.  
  651. LinkVehicleToInterior(vehicleid, interiorid);
  652. SetVehicleVirtualWorld(vehicleid, worldid);
  653.  
  654. Vehicle_SetPropertyInt(vehicleid, v_interior, interiorid);
  655.  
  656. Vehicle_SetPropertyInt(vehicleid, v_color<0>, color1);
  657. Vehicle_SetPropertyInt(vehicleid, v_color<1>, color2);
  658.  
  659. Vehicle_SetPropertyInt(vehicleid, v_paintjob, 3);
  660.  
  661. Vehicle_SetPropertyInt(vehicleid, v_horn, 0);
  662.  
  663. for(new i; i < 4; i++)
  664. {
  665. Vehicle_SetPropertyInt(vehicleid, v_damage<i>, 0);
  666. }
  667.  
  668. Vehicle_SetPropertyInt(vehicleid, v_petrolcap, 0);
  669.  
  670. Vehicle_SetPropertyInt(vehicleid, v_editor, INVALID_OBJECT_ID);
  671.  
  672. for(new i; i < MAX_VEHICLE_ATTACHED_OBJECTS; i++)
  673. {
  674. gVehicleAttachedObject[vehicleid][i] = INVALID_OBJECT_ID;
  675. }
  676.  
  677. Vehicle_SetPropertyInt(vehicleid, v_speedcap, 0);
  678.  
  679. return vehicleid;
  680. }
  681. #if defined _ALS_CreateVehicle
  682. #undef CreateVehicle
  683. #else
  684. #define _ALS_CreateVehicle
  685. #endif
  686. #define CreateVehicle Vehicle_CreateVehicle
  687. //
  688. #if defined _ALS_AddStaticVehicleEx
  689. #undef AddStaticVehicleEx
  690. #else
  691. #define _ALS_AddStaticVehicleEx
  692. #endif
  693. #define AddStaticVehicleEx Vehicle_CreateVehicle
  694. //
  695. #if defined _ALS_AddStaticVehicle
  696. #undef AddStaticVehicle
  697. #else
  698. #define _ALS_AddStaticVehicle
  699. #endif
  700. #define AddStaticVehicle Vehicle_CreateVehicle
  701. //
  702.  
  703. stock Vehicle_DestroyVehicle(vehicleid)
  704. {
  705. if(DestroyVehicle(vehicleid))
  706. {
  707. for(new i; i <= GetPlayerPoolSize(); i++)
  708. {
  709. if(IsPlayerConnected(i))
  710. {
  711. if(gPlayerEdit[i] == Vehicle_GetPropertyInt(vehicleid, v_editor))
  712. {
  713. CancelEdit(i);
  714. }
  715. }
  716. }
  717. DestroyObject(Vehicle_GetPropertyInt(vehicleid, v_editor));
  718.  
  719. Vehicle_DeleteProperties(vehicleid, v_interior);
  720.  
  721. Vehicle_DeleteProperties(vehicleid, v_color<0>);
  722. Vehicle_DeleteProperties(vehicleid, v_color<1>);
  723.  
  724. Vehicle_DeleteProperties(vehicleid, v_paintjob);
  725.  
  726. Vehicle_DeleteProperties(vehicleid, v_horn);
  727.  
  728. Vehicle_DeleteProperties(vehicleid, v_damage<0>);
  729. Vehicle_DeleteProperties(vehicleid, v_damage<1>);
  730. Vehicle_DeleteProperties(vehicleid, v_damage<2>);
  731. Vehicle_DeleteProperties(vehicleid, v_damage<3>);
  732.  
  733. Vehicle_DeleteProperties(vehicleid, v_petrolcap);
  734.  
  735. Vehicle_DeleteProperties(vehicleid, v_editor);
  736.  
  737. for(new i; i < MAX_VEHICLE_ATTACHED_OBJECTS; i++)
  738. {
  739. if(IsValidObject(gVehicleAttachedObject[vehicleid][i]))
  740. {
  741. DestroyObject(gVehicleAttachedObject[vehicleid][i]);
  742. gVehicleAttachedObject[vehicleid][i] = INVALID_OBJECT_ID;
  743. }
  744. }
  745.  
  746. Vehicle_DeleteProperties(vehicleid, v_speedcap);
  747.  
  748. vehicleid = INVALID_VEHICLE_ID;
  749. }
  750. return true;
  751. }
  752. #if defined _ALS_DestroyVehicle
  753. #undef DestroyVehicle
  754. #else
  755. #define _ALS_DestroyVehicle
  756. #endif
  757. #define DestroyVehicle Vehicle_DestroyVehicle
  758.  
  759. stock Vehicle_LinkVehicleToInterior(vehicleid, interiorid)
  760. {
  761. if(LinkVehicleToInterior(vehicleid, interiorid))
  762. {
  763. Vehicle_SetPropertyInt(vehicleid, v_interior, interiorid);
  764. return true;
  765. }
  766. return false;
  767. }
  768. #if defined _ALS_LinkVehicleToInterior
  769. #undef LinkVehicleToInterior
  770. #else
  771. #define _ALS_LinkVehicleToInterior
  772. #endif
  773. #define LinkVehicleToInterior Vehicle_LinkVehicleToInterior
  774. //
  775. #if ! defined SetVehicleInterior
  776. #define SetVehicleInterior Vehicle_LinkVehicleToInterior
  777. #endif
  778. //
  779.  
  780. stock GetVehicleInterior(vehicleid)
  781. {
  782. return Vehicle_GetPropertyInt(vehicleid, v_interior);
  783. }
  784.  
  785. stock Vehicle_ChangeVehicleColor(vehicleid, color1, color2)
  786. {
  787. new modelid = GetVehicleModel(vehicleid);
  788.  
  789. if( (color1 == -1 || color2 == -1) &&
  790. gVehicleColors[(modelid - 400)][0])
  791. {
  792. if(gVehicleColors[(modelid - 400)][0] == 2)
  793. {
  794. color1 = gVehicleColors[(modelid - 400)][1];
  795. color2 = gVehicleColors[(modelid - 400)][2];
  796. }
  797. else
  798. {
  799. new index = random(gVehicleColors[(modelid - 400)][0]) & -2;
  800.  
  801. color1 = gVehicleColors[(modelid - 400)][++index];
  802. color2 = gVehicleColors[(modelid - 400)][++index];
  803. }
  804. }
  805.  
  806. if(ChangeVehicleColor(vehicleid, color1, color2))
  807. {
  808. Vehicle_SetPropertyInt(vehicleid, v_color<0>, color1);
  809. Vehicle_SetPropertyInt(vehicleid, v_color<1>, color2);
  810. return true;
  811. }
  812. return false;
  813. }
  814. #if defined _ALS_ChangeVehicleColor
  815. #undef ChangeVehicleColor
  816. #else
  817. #define _ALS_ChangeVehicleColor
  818. #endif
  819. #define ChangeVehicleColor Vehicle_ChangeVehicleColor
  820.  
  821. stock GetVehicleColor(vehicleid, &color1, &color2)
  822. {
  823. color1 = Vehicle_GetPropertyInt(vehicleid, v_color<0>);
  824. color2 = Vehicle_GetPropertyInt(vehicleid, v_color<1>);
  825. return true;
  826. }
  827.  
  828. stock Vehicle_ChangeVehiclePaintjob(vehicleid, paintjobid)
  829. {
  830. if(ChangeVehiclePaintjob(vehicleid, paintjobid))
  831. {
  832. Vehicle_SetPropertyInt(vehicleid, v_paintjob, paintjobid);
  833.  
  834. if(paintjobid == 3)
  835. {
  836. new colors[2];
  837. GetVehicleColor(vehicleid, colors[0], colors[1]);
  838. SetVehicleColor(vehicleid, colors[0], colors[1]);
  839. }
  840. return true;
  841. }
  842. return false;
  843. }
  844. #if defined _ALS_ChangeVehiclePaintjob
  845. #undef ChangeVehiclePaintjob
  846. #else
  847. #define _ALS_ChangeVehiclePaintjob
  848. #endif
  849. #define ChangeVehiclePaintjob Vehicle_ChangeVehiclePaintjob
  850.  
  851. stock GetVehiclePaintjob(vehicleid)
  852. {
  853. return Vehicle_GetPropertyInt(vehicleid, v_paintjob);
  854. }
  855.  
  856. stock RemoveVehiclePaintjob(vehicleid)
  857. {
  858. return ChangeVehiclePaintjob(vehicleid, 3);
  859. }
  860.  
  861. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  862. {
  863. Vehicle_SetPropertyInt(vehicleid, v_paintjob, paintjobid);
  864.  
  865. #if defined Vehicle_OnVehiclePaintjob
  866. return Vehicle_OnVehiclePaintjob(playerid, vehicleid, paintjobid);
  867. #else
  868. return 1;
  869. #endif
  870. }
  871. #if defined Vehicle_OnVehiclePaintjob
  872. forward Vehicle_OnVehiclePaintjob(playerid, vehicleid, paintjobid);
  873. #endif
  874. #if defined Vehicle_OnVehiclePaintjob
  875. #undef OnVehiclePaintjob
  876. #else
  877. #define _ALS_OnVehiclePaintjob
  878. #endif
  879. #define OnVehiclePaintjob Vehicle_OnVehiclePaintjob
  880.  
  881. public OnVehicleSpawn(vehicleid)
  882. {
  883. Vehicle_SetPropertyInt(vehicleid, v_paintjob, 3);
  884.  
  885. new colors[2];
  886. colors[0] = Vehicle_GetPropertyInt(vehicleid, v_color<0>);
  887. colors[1] = Vehicle_GetPropertyInt(vehicleid, v_color<1>);
  888. ChangeVehicleColor(vehicleid, colors[0], colors[1]);
  889.  
  890. #if defined Vehicle_OnVehicleSpawn
  891. return Vehicle_OnVehicleSpawn(vehicleid);
  892. #else
  893. return 1;
  894. #endif
  895. }
  896. #if defined Vehicle_OnVehicleSpawn
  897. forward Vehicle_OnVehicleSpawn(vehicleid);
  898. #endif
  899. #if defined _ALS_OnVehicleSpawn
  900. #undef OnVehicleSpawn
  901. #else
  902. #define _ALS_OnVehicleSpawn
  903. #endif
  904. #define OnVehicleSpawn Vehicle_OnVehicleSpawn
  905.  
  906. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  907. {
  908. Vehicle_SetPropertyInt(vehicleid, v_color<0>, color1);
  909. Vehicle_SetPropertyInt(vehicleid, v_color<1>, color2);
  910.  
  911. #if defined Vehicle_OnVehicleRespray
  912. return Vehicle_OnVehicleRespray(playerid, vehicleid, color1, color2);
  913. #else
  914. return 1;
  915. #endif
  916. }
  917. #if defined Vehicle_OnVehicleRespray
  918. forward Vehicle_OnVehicleRespray(playerid, vehicleid, color1, color2);
  919. #endif
  920. #if defined _ALS_OnVehicleRespray
  921. #undef OnVehicleRespray
  922. #else
  923. #define _ALS_OnVehicleRespray
  924. #endif
  925. #define OnVehicleRespray Vehicle_OnVehicleRespray
  926.  
  927. stock SetVehicleHorn(vehicleid, soundid)
  928. {
  929. Vehicle_SetPropertyInt(vehicleid, v_horn, soundid);
  930. return true;
  931. }
  932.  
  933. stock GetVehicleHorn(vehicleid)
  934. {
  935. return Vehicle_GetPropertyInt(vehicleid, v_horn);
  936. }
  937.  
  938. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  939. {
  940. if(newkeys & KEY_CROUCH)
  941. {
  942. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  943. {
  944. new horn = Vehicle_GetPropertyInt(GetPlayerVehicleID(playerid), v_horn);
  945. if(horn != 0)
  946. {
  947. new Float:pos[3];
  948. GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  949.  
  950. for(new i; i < MAX_PLAYERS; i++)
  951. {
  952. if(IsPlayerConnected(i))
  953. {
  954. if(IsPlayerInRangeOfPoint(i, 35.0, pos[0], pos[1], pos[2]))
  955. {
  956. PlayerPlaySound(playerid, horn, pos[0], pos[1], pos[2]);
  957. }
  958. }
  959. }
  960. }
  961. }
  962. }
  963.  
  964. #if defined Vehicle_OnPlayerKeyStateChange
  965. return Vehicle_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  966. #else
  967. return 1;
  968. #endif
  969. }
  970. #if defined Vehicle_OnPlayerKeyStateChange
  971. forward Vehicle_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  972. #endif
  973. #if defined _ALS_OnPlayerKeyStateChange
  974. #undef OnPlayerKeyStateChange
  975. #else
  976. #define _ALS_OnPlayerKeyStateChange
  977. #endif
  978. #define OnPlayerKeyStateChange Vehicle_OnPlayerKeyStateChange
  979.  
  980. stock ToggleVehicleDamageUpdate(vehicleid, type, bool:toggle)
  981. {
  982. new set = 0;
  983. if(toggle) set = 1;
  984.  
  985. return Vehicle_SetPropertyInt(vehicleid, v_damage<type>, set);
  986. }
  987.  
  988. stock IsVehicleDamageToggled(vehicleid, type)
  989. {
  990. return Vehicle_GetPropertyInt(vehicleid, v_damage<type>);
  991. }
  992.  
  993. stock UpdateVehicleDamageStatusEx(vehicleid, type, update)
  994. {
  995. new panels, doors, lights, tires;
  996. GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  997.  
  998. switch(type)
  999. {
  1000. case VEHICLE_DAMAGE_PANELS: return UpdateVehicleDamageStatus(vehicleid, update, doors, lights, tires);
  1001. case VEHICLE_DAMAGE_DOORS: return UpdateVehicleDamageStatus(vehicleid, panels, update, lights, tires);
  1002. case VEHICLE_DAMAGE_LIGHTS: return UpdateVehicleDamageStatus(vehicleid, panels, doors, update, tires);
  1003. case VEHICLE_DAMAGE_TIRES: return UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, update);
  1004. }
  1005. return false;
  1006. }
  1007.  
  1008. public OnVehicleDamageStatusUpdate(vehicleid, playerid)
  1009. {
  1010. new panels, doors, lights, tires;
  1011. GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  1012.  
  1013. if(! IsVehicleDamageToggled(vehicleid, VEHICLE_DAMAGE_PANELS)) UpdateVehicleDamageStatusEx(vehicleid, VEHICLE_DAMAGE_PANELS, 0);
  1014. if(! IsVehicleDamageToggled(vehicleid, VEHICLE_DAMAGE_DOORS)) UpdateVehicleDamageStatusEx(vehicleid, VEHICLE_DAMAGE_DOORS, 0);
  1015. if(! IsVehicleDamageToggled(vehicleid, VEHICLE_DAMAGE_LIGHTS)) UpdateVehicleDamageStatusEx(vehicleid, VEHICLE_DAMAGE_LIGHTS, 0);
  1016. if(! IsVehicleDamageToggled(vehicleid, VEHICLE_DAMAGE_TIRES)) UpdateVehicleDamageStatusEx(vehicleid, VEHICLE_DAMAGE_TIRES, 0);
  1017.  
  1018. #if defined Vehicle_OnPlayerKeyStateChange
  1019. return Vehicle_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  1020. #else
  1021. return 1;
  1022. #endif
  1023. }
  1024. #if defined Vehicle_OnPlayerKeyStateChange
  1025. forward Vehicle_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
  1026. #endif
  1027. #if defined _ALS_OnPlayerKeyStateChange
  1028. #undef OnPlayerKeyStateChange
  1029. #else
  1030. #define _ALS_OnPlayerKeyStateChange
  1031. #endif
  1032. #define OnPlayerKeyStateChange Vehicle_OnPlayerKeyStateChange
  1033.  
  1034. stock ToggleVehiclePetrolCapDestroy(vehicleid, bool:toggle)
  1035. {
  1036. new set = 0;
  1037. if(toggle) set = 1;
  1038.  
  1039. return Vehicle_SetPropertyInt(vehicleid, v_petrolcap, set);
  1040. }
  1041.  
  1042. stock IsPetrolCapDestroyToggled(vehicleid)
  1043. {
  1044. return Vehicle_GetPropertyInt(vehicleid, v_petrolcap);
  1045. }
  1046.  
  1047. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  1048. {
  1049. if(hittype == BULLET_HIT_TYPE_VEHICLE)
  1050. {
  1051. new index = (GetVehicleModel(hitid) - 400);
  1052. if( fX >= gVehiclePetrolCapOffsets[index][0] - 0.15 &&
  1053. fX <= gVehiclePetrolCapOffsets[index][0] + 0.15 &&
  1054. fY >= gVehiclePetrolCapOffsets[index][1] - 0.15 &&
  1055. fY <= gVehiclePetrolCapOffsets[index][1] + 0.15 &&
  1056. fZ >= gVehiclePetrolCapOffsets[index][2] - 0.15 &&
  1057. fZ <= gVehiclePetrolCapOffsets[index][2] + 0.15)
  1058. {
  1059. if(IsPetrolCapDestroyToggled(hitid))
  1060. {
  1061. if( CallLocalFunction("OnPlayerShootVehiclePetrolCap", "ii", playerid, hitid) ||
  1062. funcidx("OnPlayerShootVehiclePetrolCap") == -1)
  1063. {
  1064. new Float:health;
  1065. GetVehicleHealth(hitid, health);
  1066. if(health > (250 - 1))
  1067. {
  1068. new Float:pos[3];
  1069. GetVehiclePos(hitid, pos[0], pos[1], pos[2]);
  1070. CreateExplosion(pos[0], pos[1], pos[2], 3, 30.0);
  1071. SetVehicleHealth(hitid, 0.0);
  1072. }
  1073. }
  1074. }
  1075. }
  1076. }
  1077.  
  1078. #if defined Vehicle_OnPlayerWeaponShot
  1079. return Vehicle_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  1080. #else
  1081. return 1;
  1082. #endif
  1083. }
  1084. #if defined Vehicle_OnPlayerWeaponShot
  1085. forward Vehicle_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  1086. #endif
  1087. #if defined _ALS_OnPlayerWeaponShot
  1088. #undef OnPlayerWeaponShot
  1089. #else
  1090. #define _ALS_OnPlayerWeaponShot
  1091. #endif
  1092. #define OnPlayerWeaponShot Vehicle_OnPlayerWeaponShot
  1093.  
  1094. forward OnPlayerShootVehiclePetrolCap(playerid, vehicleid);
  1095.  
  1096. stock IsVehicleOccupied(vehicleid)
  1097. {
  1098. for(new i; i < MAX_PLAYERS; i++)
  1099. {
  1100. if(IsPlayerConnected(i))
  1101. {
  1102. if(IsPlayerInVehicle(i, vehicleid)) return true;
  1103. }
  1104. }
  1105. return false;
  1106. }
  1107.  
  1108. stock EditVehicle(playerid, vehicleid)
  1109. {
  1110. if(IsValidObject(Vehicle_GetPropertyInt(vehicleid, v_editor))) return false;
  1111.  
  1112. new Float:pos[3];
  1113. GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
  1114. Vehicle_SetPropertyInt(vehicleid, v_editor, CreateObject(19300, pos[0], pos[1], pos[2], 0.0, 0.0, 0.0));
  1115.  
  1116. EditObject(playerid, Vehicle_GetPropertyInt(vehicleid, v_editor));
  1117.  
  1118. gPlayerEdit[playerid] = vehicleid;
  1119. return true;
  1120. }
  1121.  
  1122. #if ! defined IsValidVehicle
  1123. native IsValidVehicle(vehicleid);
  1124. #endif
  1125.  
  1126. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  1127. {
  1128. if(IsValidVehicle(gPlayerEdit[playerid]))
  1129. {
  1130. if(Vehicle_GetPropertyInt(gPlayerEdit[playerid], v_editor) == objectid)
  1131. {
  1132. SetVehiclePos(gPlayerEdit[playerid], fX, fY, fZ);
  1133. SetVehicleZAngle(gPlayerEdit[playerid], fRotZ);
  1134.  
  1135. CallLocalFunction("OnPlayerEditVehicle", "iiiffff", playerid, gPlayerEdit[playerid], response, fX, fY, fZ, fRotZ);
  1136.  
  1137. switch(response)
  1138. {
  1139. case EDIT_RESPONSE_CANCEL, EDIT_RESPONSE_FINAL:
  1140. {
  1141. DestroyObject(objectid);
  1142. Vehicle_SetPropertyInt(gPlayerEdit[playerid], v_editor, INVALID_OBJECT_ID);
  1143.  
  1144. SetVehicleVelocity(gPlayerEdit[playerid], 0.0, 0.0, 0.0);
  1145.  
  1146. gPlayerEdit[playerid] = INVALID_VEHICLE_ID;
  1147. }
  1148. }
  1149. }
  1150. }
  1151.  
  1152. #if defined Vehicle_OnPlayerEditObject
  1153. return Vehicle_OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ);
  1154. #else
  1155. return 1;
  1156. #endif
  1157. }
  1158. #if defined Vehicle_OnPlayerEditObject
  1159. forward Vehicle_OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ);
  1160. #endif
  1161. #if defined _ALS_OnPlayerEditObject
  1162. #undef OnPlayerEditObject
  1163. #else
  1164. #define _ALS_OnPlayerEditObject
  1165. #endif
  1166. #define OnPlayerEditObject Vehicle_OnPlayerEditObject
  1167.  
  1168. forward OnPlayerEditVehicle(playerid, vehicleid, response, Float:fX, Float:fY, Float:fZ, Float:fRotZ);
  1169.  
  1170. stock GetVehicleName(vehicleid, string[], len = sizeof(string))
  1171. {
  1172. format(string, len, "%s", gVehicleNames[GetVehicleModel(vehicleid) - 400]);
  1173. return true;
  1174. }
  1175.  
  1176. stock GetVehicleModelName(modelid, string[], len = sizeof(string))
  1177. {
  1178.  
  1179. format(string, len, "%s", gVehicleNames[modelid - 400]);
  1180. return true;
  1181. }
  1182.  
  1183. stock GetVehicleParams(vehicleid, type)
  1184. {
  1185. new params[7];
  1186. GetVehicleParamsEx(vehicleid, params[0], params[1], params[2], params[3], params[4], params[5], params[6]);
  1187. return params[type];
  1188. }
  1189.  
  1190. stock SetVehicleParams(vehicleid, type, set)
  1191. {
  1192. new params[7];
  1193.  
  1194. if(GetVehicleParamsEx(vehicleid, params[0], params[1], params[2], params[3], params[4], params[5], params[6]))
  1195. {
  1196. params[type] = set;
  1197. SetVehicleParamsEx(vehicleid, params[0], params[1], params[2], params[3], params[4], params[5], params[6]);
  1198. return true;
  1199. }
  1200. return false;
  1201. }
  1202.  
  1203. stock Float:GetVehicleSpeed(vehicleid, bool:kmh = true)
  1204. {
  1205. new Float:vel[3], Float:speed;
  1206. GetVehicleVelocity(vehicleid, vel[0], vel[1], vel[2]);
  1207.  
  1208. if(kmh) speed = floatsqroot(((vel[0] * vel[0]) + (vel[1] * vel[1])) + (vel[2] * vel[2])) * 180.5;
  1209. else speed = floatsqroot(((vel[0] * vel[0]) + (vel[1] * vel[1])) + (vel[2] * vel[2])) * 112.0;
  1210.  
  1211. floatround(speed, floatround_round);
  1212. return speed;
  1213. }
  1214.  
  1215. stock Vehicle_AttachObjectToVehicle(objectid, vehicleid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:RotX, Float:RotY, Float:RotZ)
  1216. {
  1217. for(new i; i < MAX_VEHICLE_ATTACHED_OBJECTS; i++)
  1218. {
  1219. if(! IsValidObject(gVehicleAttachedObject[vehicleid][i]))
  1220. {
  1221. if(AttachObjectToVehicle(objectid, vehicleid, OffsetX, OffsetY, OffsetZ, RotX, RotY, RotZ))
  1222. {
  1223. gVehicleAttachedObject[vehicleid][i] = objectid;
  1224. return true;
  1225. }
  1226. }
  1227. }
  1228.  
  1229. printf("WARNING: The object wasn't attached to the vehicle (id: %i), This may occur because the MAX_VEHICLE_ATTACHED_OBJECT limit was exceeded or the vehicle wasn't created. <vehicleplus.inc>", vehicleid);
  1230. return false;
  1231. }
  1232. #if defined _ALS_AttachObjectToVehicle
  1233. #undef AttachObjectToVehicle
  1234. #else
  1235. #define _ALS_AttachObjectToVehicle
  1236. #endif
  1237. #define AttachObjectToVehicle Vehicle_AttachObjectToVehicle
  1238.  
  1239. stock IsObjectAttachedToVehicle(objectid, vehicleid)
  1240. {
  1241. for(new i; i < MAX_VEHICLE_ATTACHED_OBJECTS; i++)
  1242. {
  1243. if(IsValidObject(gVehicleAttachedObject[vehicleid][i]))
  1244. {
  1245. if(gVehicleAttachedObject[vehicleid][i] == objectid) return true;
  1246. }
  1247. }
  1248. return false;
  1249. }
  1250.  
  1251. stock GetVehicleSlotAttachedObject(vehicleid, slot)
  1252. {
  1253. if(! IsValidObject(gVehicleAttachedObject[vehicleid][slot])) return -1;
  1254.  
  1255. return gVehicleAttachedObject[vehicleid][slot];
  1256.  
  1257. }
  1258.  
  1259. stock TeleportVehicle(vehicleid, Float:x, Float:y, Float:z, Float:rotation, worldid = -1, interiorid = -1)
  1260. {
  1261. for(new i; i <= GetPlayerPoolSize(); i++)
  1262. {
  1263. if(IsPlayerConnected(i))
  1264. {
  1265. if(GetPlayerVehicleID(i) == vehicleid)
  1266. {
  1267. if(worldid != -1)
  1268. {
  1269. SetPlayerVirtualWorld(i, worldid);
  1270. }
  1271. if(interiorid != -1)
  1272. {
  1273. SetPlayerInterior(i, interiorid);
  1274. }
  1275. }
  1276. }
  1277. }
  1278.  
  1279. if(worldid != -1)
  1280. {
  1281. SetVehicleVirtualWorld(vehicleid, worldid);
  1282. }
  1283. if(interiorid != -1)
  1284. {
  1285. SetVehicleInterior(vehicleid, interiorid);
  1286. }
  1287.  
  1288. SetVehiclePos(vehicleid, x, y, z);
  1289. SetVehicleZAngle(vehicleid, rotation);
  1290. return true;
  1291. }
  1292.  
  1293. stock CountAllVehicles()
  1294. {
  1295. new count;
  1296. for(new i; i <= GetVehiclePoolSize(); i++)
  1297. {
  1298. if(IsValidVehicle(i))
  1299. {
  1300. count += 1;
  1301. }
  1302. }
  1303. return count;
  1304. }
  1305.  
  1306. stock DestroyAllVehicles()
  1307. {
  1308. for(new i; i <= GetVehiclePoolSize(); i++)
  1309. {
  1310. if(IsValidVehicle(i))
  1311. {
  1312. DestroyVehicle(i);
  1313. }
  1314. }
  1315. return true;
  1316. }
  1317.  
  1318. stock SetVehicleSpeedCap(vehicleid, maxspeed)
  1319. {
  1320. return Vehicle_SetPropertyInt(vehicleid, v_speedcap, maxspeed);
  1321. }
  1322.  
  1323. stock GetVehicleSpeedCap(vehicleid)
  1324. {
  1325. return Vehicle_GetPropertyInt(vehicleid, v_speedcap);
  1326. }
  1327.  
  1328. stock DisableVehicleSpeedCap(vehicleid)
  1329. {
  1330. return SetVehicleSpeedCap(vehicleid, 0);
  1331. }
  1332.  
  1333. public OnPlayerUpdate(playerid)
  1334. {
  1335. if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  1336. {
  1337. new vehicleid = GetPlayerVehicleID(playerid);
  1338. new speedcap = GetVehicleSpeedCap(vehicleid);
  1339. new Float:vehicle_speed = GetVehicleSpeed(vehicleid);
  1340.  
  1341. if(speedcap != 0.0)
  1342. {
  1343. if(vehicle_speed > speedcap)
  1344. {
  1345. if( funcidx("OnPlayerReachSpeedCapLimit") == -1 ||
  1346. CallLocalFunction("OnPlayerReachSpeedCapLimit", "iif", playerid, vehicleid, vehicle_speed))
  1347. {
  1348. new Float:vel[3];
  1349. GetVehicleVelocity(vehicleid, vel[0], vel[1], vel[2]);
  1350.  
  1351. vel[0] = (vel[0] / vehicle_speed) * speedcap;
  1352. vel[1] = (vel[1] / vehicle_speed) * speedcap;
  1353. vel[2] = (vel[2] / vehicle_speed) * speedcap;
  1354.  
  1355. SetVehicleVelocity(vehicleid, vel[0], vel[1], vel[2]);
  1356. }
  1357. }
  1358. }
  1359. }
  1360.  
  1361. #if defined Vehicle_OnPlayerUpdate
  1362. return Vehicle_OnPlayerUpdate(playerid);
  1363. #else
  1364. return 1;
  1365. #endif
  1366. }
  1367. #if defined Vehicle_OnPlayerUpdate
  1368. forward Vehicle_OnPlayerUpdate(playerid);
  1369. #endif
  1370. #if defined _ALS_OnPlayerUpdate
  1371. #undef OnPlayerUpdate
  1372. #else
  1373. #define _ALS_OnPlayerUpdate
  1374. #endif
  1375. #define OnPlayerUpdate Vehicle_OnPlayerUpdate
  1376.  
  1377. forward OnPlayerReachSpeedCapLimit(playerid, vehicleid, Float:speed);
  1378.  
  1379. stock GetVehicleTopSpeed(vehicleid)
  1380. {
  1381. return gVehicleTopSpeed[GetVehicleModel(vehicleid) - 400];
  1382. }
  1383.  
  1384. stock GetVehicleModelTopSpeed(modelid)
  1385. {
  1386. return gVehicleTopSpeed[modelid - 400];
  1387. }
Advertisement
Add Comment
Please, Sign In to add comment