Advertisement
Frost12

Speedo Meter System

Sep 12th, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.54 KB | None | 0 0
  1. #include <a_samp>
  2. forward CheckSpeed();
  3. new Text:KMH[MAX_PLAYERS];
  4. new Text:Name[MAX_PLAYERS];
  5. new Text:CarH[MAX_PLAYERS];
  6. new Text:Type[MAX_PLAYERS];
  7. new Text:Out1[MAX_PLAYERS],Text:Out2[MAX_PLAYERS],Text:Out3[MAX_PLAYERS];
  8. new Text:Out4[MAX_PLAYERS],Text:Out5[MAX_PLAYERS],Text:Out6[MAX_PLAYERS];
  9. new Text:Out7[MAX_PLAYERS],Text:Out8[MAX_PLAYERS],Text:Out9[MAX_PLAYERS];
  10. new CarsName[][] = {
  11. "Landstalker",
  12. "Bravura",
  13. "Buffalo",
  14. "Linerunner",
  15. "Pereniel",
  16. "Sentinel",
  17. "Dumper",
  18. "Firetruck",
  19. "Trashmaster",
  20. "Stretch",
  21. "Manana",
  22. "Infernus",
  23. "Voodoo",
  24. "Pony",
  25. "Mule",
  26. "Cheetah",
  27. "Ambulance",
  28. "Leviathan",
  29. "Moonbeam",
  30. "Esperanto",
  31. "Taxi",
  32. "Washington",
  33. "Bobcat",
  34. "Mr Whoopee",
  35. "BF Injection",
  36. "Hunter",
  37. "Premier",
  38. "Enforcer",
  39. "Securicar",
  40. "Banshee",
  41. "Predator",
  42. "Bus",
  43. "Rhino",
  44. "Barracks",
  45. "Hotknife",
  46. "Trailer",
  47. "Previon",
  48. "Coach",
  49. "Cabbie",
  50. "Stallion",
  51. "Rumpo",
  52. "RC Bandit",
  53. "Romero",
  54. "Packer",
  55. "Monster",
  56. "Admiral",
  57. "Squalo",
  58. "Seasparrow",
  59. "Pizzaboy",
  60. "Tram",
  61. "Trailer",
  62. "Turismo",
  63. "Speeder",
  64. "Reefer",
  65. "Tropic",
  66. "Flatbed",
  67. "Yankee",
  68. "Caddy",
  69. "Solair",
  70. "RC Van",
  71. "Skimmer",
  72. "PCJ-600",
  73. "Faggio",
  74. "Freeway",
  75. "RC Baron",
  76. "RC Raider",
  77. "Glendale",
  78. "Oceanic",
  79. "Sanchez",
  80. "Sparrow",
  81. "Patriot",
  82. "Quad",
  83. "Coastguard",
  84. "Dinghy",
  85. "Hermes",
  86. "Sabre",
  87. "Rustler",
  88. "ZR-350",
  89. "Walton",
  90. "Regina",
  91. "Comet",
  92. "BMX",
  93. "Burrito",
  94. "Camper",
  95. "Marquis",
  96. "Baggage",
  97. "Dozer",
  98. "Maverick",
  99. "News Chopper",
  100. "Rancher",
  101. "FBI Rancher",
  102. "Virgo",
  103. "Greenwood",
  104. "Jetmax",
  105. "Hotring",
  106. "Sandking",
  107. "Blista Compact",
  108. "PD Maverick",
  109. "Boxville",
  110. "Benson",
  111. "Mesa",
  112. "RC Goblin",
  113. "Hotring",
  114. "Hotring",
  115. "Bloodring",
  116. "Rancher",
  117. "Super GT",
  118. "Elegant",
  119. "Journey",
  120. "Bike",
  121. "Mountain Bike",
  122. "Beagle",
  123. "Cropdust",
  124. "Stunt",
  125. "Tanker",
  126. "RoadTrain",
  127. "Nebula",
  128. "Majestic",
  129. "Buccaneer",
  130. "Shamal",
  131. "Hydra",
  132. "FCR-900",
  133. "NRG-500",
  134. "HPV1000",
  135. "Cement",
  136. "Tow Truck",
  137. "Fortune",
  138. "Cadrona",
  139. "FBI Truck",
  140. "Willard",
  141. "Forklift",
  142. "Tractor",
  143. "Combine",
  144. "Feltzer",
  145. "Remington",
  146. "Slamvan",
  147. "Blade",
  148. "Freight",
  149. "Streak",
  150. "Vortex",
  151. "Vincent",
  152. "Bullet",
  153. "Clover",
  154. "Sadler",
  155. "Firetruck",
  156. "Hustler",
  157. "Intruder",
  158. "Primo",
  159. "Cargobob",
  160. "Tampa",
  161. "Sunrise",
  162. "Merit",
  163. "Utility",
  164. "Nevada",
  165. "Yosemite",
  166. "Windsor",
  167. "Monster",
  168. "Monster",
  169. "Uranus",
  170. "Jester",
  171. "Sultan",
  172. "Stratum",
  173. "Elegy",
  174. "Raindance",
  175. "RC Tiger",
  176. "Flash",
  177. "Tahoma",
  178. "Savanna",
  179. "Bandito",
  180. "Freight",
  181. "Trailer",
  182. "Kart",
  183. "Mower",
  184. "Duneride",
  185. "Sweeper",
  186. "Broadway",
  187. "Tornado",
  188. "AT-400",
  189. "DFT-30",
  190. "Huntley",
  191. "Stafford",
  192. "BF-400",
  193. "Newsvan",
  194. "Tug",
  195. "Trailer",
  196. "Emperor",
  197. "Wayfarer",
  198. "Euros",
  199. "Hotdog",
  200. "Club",
  201. "Trailer",
  202. "Trailer",
  203. "Andromada",
  204. "Dodo",
  205. "RC Cam",
  206. "Launch",
  207. "Police Car",
  208. "Police Car",
  209. "Police Car",
  210. "Police Ranger",
  211. "Picador",
  212. "S.W.A.T",
  213. "Alpha",
  214. "Phoenix",
  215. "Glendale",
  216. "Sadler",
  217. "Luggage Trailer",
  218. "Luggage Trailer",
  219. "Stair Trailer",
  220. "Boxville",
  221. "Farm Plow",
  222. "Utility Trailer"
  223. };
  224. public OnFilterScriptInit()
  225. {
  226. print("***********************************");
  227. print("* SA-MP Speedometer by Frost *");
  228. print("* FILTERSCRIPT:LOADED *");
  229. print("***********************************");
  230. SetTimer("CheckSpeed",150,1);
  231. for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  232. {
  233. KMH[playerid] = TextDrawCreate(501.000000, 414.000000, "KM/H:");
  234. TextDrawBackgroundColor(KMH[playerid], 255);
  235. TextDrawFont(KMH[playerid], 1);
  236. TextDrawLetterSize(KMH[playerid], 0.400000, 1.0000000);
  237. TextDrawColor(KMH[playerid], -1);
  238. TextDrawSetOutline(KMH[playerid], 1);
  239. TextDrawSetProportional(KMH[playerid], 1);
  240. TextDrawUseBox(KMH[playerid], 1);
  241. TextDrawBoxColor(KMH[playerid], -2139062187);
  242. TextDrawTextSize(KMH[playerid], 636.000000, 0.000000);
  243.  
  244. Type[playerid] = TextDrawCreate(501.000000, 431.000000, "Type:");
  245. TextDrawBackgroundColor(Type[playerid], 255);
  246. TextDrawFont(Type[playerid], 1);
  247. TextDrawLetterSize(Type[playerid], 0.400000, 1.000000);
  248. TextDrawColor(Type[playerid], -1);
  249. TextDrawSetOutline(Type[playerid], 1);
  250. TextDrawSetProportional(Type[playerid], 1);
  251. TextDrawUseBox(Type[playerid], 1);
  252. TextDrawBoxColor(Type[playerid], -2139062187);
  253. TextDrawTextSize(Type[playerid], 636.000000, 0.000000);
  254.  
  255. CarH[playerid] = TextDrawCreate(501.000000, 398.000000, "Health:");
  256. TextDrawBackgroundColor(CarH[playerid], 255);
  257. TextDrawFont(CarH[playerid], 1);
  258. TextDrawLetterSize(CarH[playerid], 0.400000, 1.0000000);
  259. TextDrawColor(CarH[playerid], -1);
  260. TextDrawSetOutline(CarH[playerid], 1);
  261. TextDrawSetProportional(CarH[playerid], 1);
  262. TextDrawUseBox(CarH[playerid], 1);
  263. TextDrawBoxColor(CarH[playerid], -2139062187);
  264. TextDrawTextSize(CarH[playerid], 636.000000, 0.000000);
  265.  
  266. Name[playerid] = TextDrawCreate(501.000000, 382.000000, "Name:");
  267. TextDrawBackgroundColor(Name[playerid], 255);
  268. TextDrawFont(Name[playerid], 1);
  269. TextDrawLetterSize(Name[playerid], 0.400000, 1.000000);
  270. TextDrawColor(Name[playerid], -1);
  271. TextDrawSetOutline(Name[playerid], 1);
  272. TextDrawSetProportional(Name[playerid], 1);
  273. TextDrawUseBox(Name[playerid], 1);
  274. TextDrawBoxColor(Name[playerid], -2139062187);
  275. TextDrawTextSize(Name[playerid], 636.000000, 0.000000);
  276.  
  277. Out1[playerid] = TextDrawCreate(501.000000, 434.000000, "_");
  278. TextDrawBackgroundColor(Out1[playerid], 255);
  279. TextDrawFont(Out1[playerid], 1);
  280. TextDrawLetterSize(Out1[playerid], 0.500000, 1.000000);
  281. TextDrawColor(Out1[playerid], -1);
  282. TextDrawSetOutline(Out1[playerid], 0);
  283. TextDrawSetProportional(Out1[playerid], 1);
  284. TextDrawSetShadow(Out1[playerid], 1);
  285. TextDrawUseBox(Out1[playerid], 1);
  286. TextDrawBoxColor(Out1[playerid], 255);
  287. TextDrawTextSize(Out1[playerid], 489.000000, 0.000000);
  288.  
  289. Out2[playerid] = TextDrawCreate(501.000000, 419.000000, "_");
  290. TextDrawBackgroundColor(Out2[playerid], 255);
  291. TextDrawFont(Out2[playerid], 1);
  292. TextDrawLetterSize(Out2[playerid], 0.500000, 1.000000);
  293. TextDrawColor(Out2[playerid], -1);
  294. TextDrawSetOutline(Out2[playerid], 0);
  295. TextDrawSetProportional(Out2[playerid], 1);
  296. TextDrawSetShadow(Out2[playerid], 1);
  297. TextDrawUseBox(Out2[playerid], 1);
  298. TextDrawBoxColor(Out2[playerid], 255);
  299. TextDrawTextSize(Out2[playerid], 489.000000, 0.000000);
  300.  
  301. Out3[playerid] = TextDrawCreate(501.000000, 402.000000, "_");
  302. TextDrawBackgroundColor(Out3[playerid], 255);
  303. TextDrawFont(Out3[playerid], 1);
  304. TextDrawLetterSize(Out3[playerid], 0.500000, 1.000000);
  305. TextDrawColor(Out3[playerid], -1);
  306. TextDrawSetOutline(Out3[playerid], 0);
  307. TextDrawSetProportional(Out3[playerid], 1);
  308. TextDrawSetShadow(Out3[playerid], 1);
  309. TextDrawUseBox(Out3[playerid], 1);
  310. TextDrawBoxColor(Out3[playerid], 255);
  311. TextDrawTextSize(Out3[playerid], 489.000000, 0.000000);
  312.  
  313. Out4[playerid] = TextDrawCreate(501.000000, 386.000000, "_");
  314. TextDrawBackgroundColor(Out4[playerid], 255);
  315. TextDrawFont(Out4[playerid], 1);
  316. TextDrawLetterSize(Out4[playerid], 0.500000, 1.000000);
  317. TextDrawColor(Out4[playerid], -1);
  318. TextDrawSetOutline(Out4[playerid], 0);
  319. TextDrawSetProportional(Out4[playerid], 1);
  320. TextDrawSetShadow(Out4[playerid], 1);
  321. TextDrawUseBox(Out4[playerid], 1);
  322. TextDrawBoxColor(Out4[playerid], 255);
  323. TextDrawTextSize(Out4[playerid], 489.000000, 0.000000);
  324.  
  325. Out5[playerid] = TextDrawCreate(501.000000, 386.000000, "_");
  326. TextDrawBackgroundColor(Out5[playerid], 255);
  327. TextDrawFont(Out5[playerid], 1);
  328. TextDrawLetterSize(Out5[playerid], 0.500000, 1.000000);
  329. TextDrawColor(Out5[playerid], -1);
  330. TextDrawSetOutline(Out5[playerid], 0);
  331. TextDrawSetProportional(Out5[playerid], 1);
  332. TextDrawSetShadow(Out5[playerid], 1);
  333. TextDrawUseBox(Out5[playerid], 1);
  334. TextDrawBoxColor(Out5[playerid], 255);
  335. TextDrawTextSize(Out5[playerid], 489.000000, 0.000000);
  336.  
  337. Out6[playerid] = TextDrawCreate(501.000000, 382.000000, "_");
  338. TextDrawBackgroundColor(Out6[playerid], 255);
  339. TextDrawFont(Out6[playerid], 1);
  340. TextDrawLetterSize(Out6[playerid], 0.500000, 1.000000);
  341. TextDrawColor(Out6[playerid], -1);
  342. TextDrawSetOutline(Out6[playerid], 0);
  343. TextDrawSetProportional(Out6[playerid], 1);
  344. TextDrawSetShadow(Out6[playerid], 1);
  345. TextDrawUseBox(Out6[playerid], 1);
  346. TextDrawBoxColor(Out6[playerid], 255);
  347. TextDrawTextSize(Out6[playerid], 489.000000, 0.000000);
  348.  
  349. Out7[playerid] = TextDrawCreate(653.000000, 377.000000, "_");
  350. TextDrawBackgroundColor(Out7[playerid], 255);
  351. TextDrawFont(Out7[playerid], 1);
  352. TextDrawLetterSize(Out7[playerid], 0.500000, -0.199999);
  353. TextDrawColor(Out7[playerid], -1);
  354. TextDrawSetOutline(Out7[playerid], 0);
  355. TextDrawSetProportional(Out7[playerid], 1);
  356. TextDrawSetShadow(Out7[playerid], 1);
  357. TextDrawUseBox(Out7[playerid], 1);
  358. TextDrawBoxColor(Out7[playerid], 255);
  359. TextDrawTextSize(Out7[playerid], 489.000000, 0.000000);
  360.  
  361. Out8[playerid] = TextDrawCreate(653.000000, 447.000000, "_");
  362. TextDrawBackgroundColor(Out8[playerid], 255);
  363. TextDrawFont(Out8[playerid], 1);
  364. TextDrawLetterSize(Out8[playerid], 0.500000, -0.199999);
  365. TextDrawColor(Out8[playerid], -1);
  366. TextDrawSetOutline(Out8[playerid], 0);
  367. TextDrawSetProportional(Out8[playerid], 1);
  368. TextDrawSetShadow(Out8[playerid], 1);
  369. TextDrawUseBox(Out8[playerid], 1);
  370. TextDrawBoxColor(Out8[playerid], 255);
  371. TextDrawTextSize(Out8[playerid], 489.000000, 0.000000);
  372.  
  373. Out9[playerid] = TextDrawCreate(644.000000, 447.000000, "_");
  374. TextDrawBackgroundColor(Out9[playerid], 255);
  375. TextDrawFont(Out9[playerid], 1);
  376. TextDrawLetterSize(Out9[playerid], 0.500000, -7.999998);
  377. TextDrawColor(Out9[playerid], -1);
  378. TextDrawSetOutline(Out9[playerid], 0);
  379. TextDrawSetProportional(Out9[playerid], 1);
  380. TextDrawSetShadow(Out9[playerid], 1);
  381. TextDrawUseBox(Out9[playerid], 1);
  382. TextDrawBoxColor(Out9[playerid], 255);
  383. TextDrawTextSize(Out9[playerid], 632.000000, 1.000000);
  384. }
  385. return 1;
  386. }
  387. public OnFilterScriptExit()
  388. {
  389. for(new i = 0;i < MAX_PLAYERS; i++)
  390. {
  391. TextDrawHideForPlayer(i,Name[i]);
  392. TextDrawHideForPlayer(i,KMH[i]);
  393. TextDrawHideForPlayer(i,Type[i]);
  394. TextDrawHideForPlayer(i,CarH[i]);
  395. TextDrawHideForPlayer(i,Out1[i]);
  396. TextDrawHideForPlayer(i,Out2[i]);
  397. TextDrawHideForPlayer(i,Out3[i]);
  398. TextDrawHideForPlayer(i,Out4[i]);
  399. TextDrawHideForPlayer(i,Out5[i]);
  400. TextDrawHideForPlayer(i,Out6[i]);
  401. TextDrawHideForPlayer(i,Out7[i]);
  402. TextDrawHideForPlayer(i,Out8[i]);
  403. TextDrawHideForPlayer(i,Out9[i]);
  404. }
  405. return 1;
  406. }
  407.  
  408. public CheckSpeed()
  409. {
  410. for(new i=0;i<MAX_PLAYERS;i++)
  411. {
  412. if (IsPlayerInAnyVehicle(i) && IsPlayerConnected(i))
  413. {
  414. new Float:h,str[167],str3[167],str4[167],v,sp;
  415. v = GetPlayerVehicleID(i);
  416. GetVehicleHealth(v,h);
  417. sp = GetPlayerSpeed(i);
  418. format(str,sizeof(str),"KM/H: %d",sp);
  419. if(IsInAnyBike(v))
  420. {
  421. TextDrawSetString(Type[i],"Type: Bike");
  422. }
  423. else if(IsInAirplane(v))
  424. {
  425. TextDrawSetString(Type[i],"Type: Airplane");
  426. }
  427. else if(IsInHeli(v))
  428. {
  429. TextDrawSetString(Type[i],"Type: Helicopter");
  430. }
  431. else if(IsInBoat(v))
  432. {
  433. TextDrawSetString(Type[i],"Type: Boat");
  434. }
  435. else
  436. {
  437. TextDrawSetString(Type[i],"Type: Car");
  438. }
  439. format(str3,sizeof(str3),"Health: %.0f",h);
  440. format(str4,167,"Name: %s",CarsName[GetVehicleModel(v)-400]);
  441. TextDrawSetString(KMH[i],str);
  442. TextDrawSetString(CarH[i],str3);
  443. TextDrawSetString(Name[i],str4);
  444. }
  445. }
  446. return 1;
  447. }
  448. public OnPlayerStateChange(playerid, newstate, oldstate)
  449. {
  450. if (newstate == PLAYER_STATE_DRIVER)
  451. {
  452.  
  453. TextDrawShowForPlayer(playerid,KMH[playerid]);
  454. TextDrawShowForPlayer(playerid,Name[playerid]);
  455. TextDrawShowForPlayer(playerid,Type[playerid]);
  456. TextDrawShowForPlayer(playerid,CarH[playerid]);
  457. TextDrawShowForPlayer(playerid,Out1[playerid]);
  458. TextDrawShowForPlayer(playerid,Out2[playerid]);
  459. TextDrawShowForPlayer(playerid,Out3[playerid]);
  460. TextDrawShowForPlayer(playerid,Out4[playerid]);
  461. TextDrawShowForPlayer(playerid,Out5[playerid]);
  462. TextDrawShowForPlayer(playerid,Out6[playerid]);
  463. TextDrawShowForPlayer(playerid,Out7[playerid]);
  464. TextDrawShowForPlayer(playerid,Out8[playerid]);
  465. TextDrawShowForPlayer(playerid,Out9[playerid]);
  466. }
  467. else if (newstate == PLAYER_STATE_ONFOOT)
  468. {
  469. TextDrawHideForPlayer(playerid,KMH[playerid]);
  470. TextDrawHideForPlayer(playerid,Name[playerid]);
  471. TextDrawHideForPlayer(playerid,Type[playerid]);
  472. TextDrawHideForPlayer(playerid,CarH[playerid]);
  473. TextDrawHideForPlayer(playerid,Out1[playerid]);
  474. TextDrawHideForPlayer(playerid,Out2[playerid]);
  475. TextDrawHideForPlayer(playerid,Out3[playerid]);
  476. TextDrawHideForPlayer(playerid,Out4[playerid]);
  477. TextDrawHideForPlayer(playerid,Out5[playerid]);
  478. TextDrawHideForPlayer(playerid,Out6[playerid]);
  479. TextDrawHideForPlayer(playerid,Out7[playerid]);
  480. TextDrawHideForPlayer(playerid,Out8[playerid]);
  481. TextDrawHideForPlayer(playerid,Out9[playerid]);
  482. }
  483. return 1;
  484. }
  485. stock GetPlayerSpeed(playerid)
  486. {
  487. new Float:ST[4];
  488. if(IsPlayerInAnyVehicle(playerid))
  489. GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
  490. else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
  491. ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
  492. return floatround(ST[3]);
  493. }
  494. stock IsInAnyBike(bikeid)
  495. {
  496. new Bikes[] = { 509,510,481,581, 462, 521, 463, 522, 461, 448, 471, 468, 586 };
  497. for(new i = 0; i < sizeof(Bikes); i++)
  498. {
  499. if(GetVehicleModel(bikeid) == Bikes[i]) return 1;
  500. }
  501. return 0;
  502. }
  503. stock IsInAirplane(airplaneid)
  504. {
  505. new Airplanes[] = { 460,476,511,512,513,519,520,553,577,563,592,593 };
  506. for(new i = 0; i < sizeof(Airplanes); i++)
  507. {
  508. if(GetVehicleModel(airplaneid) == Airplanes[i]) return 1;
  509. }
  510. return 0;
  511. }
  512. stock IsInHeli(heliid)
  513. {
  514. new Helis[] = { 417,425,447,469,487,488,497,548,563 };
  515. for(new i = 0; i < sizeof(Helis); i++)
  516. {
  517. if(GetVehicleModel(heliid) == Helis[i]) return 1;
  518. }
  519. return 0;
  520. }
  521. stock IsInBoat(boatid)
  522. {
  523. new Boats[] = { 472, 473, 493, 495, 484, 430, 454, 453, 452, 446 };
  524. for(new i = 0; i < sizeof(Boats); i++)
  525. {
  526. if(GetVehicleModel(boatid) == Boats[i]) return 1;
  527. }
  528. return 0;
  529. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement