Guest User

Untitled

a guest
Jul 10th, 2022
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.84 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new PlayerText:cWspeedo[MAX_PLAYERS][10];
  4. new carfuel[MAX_VEHICLES] = {100, ...}; // Povrzite ovo sa vasim fuel sistemom ( ako ga imate ) :D
  5. public OnFilterScriptInit()
  6. {
  7. print("\n--------------------------------------");
  8. print("-----Vehicle Speedometer by Clauson-----");
  9. print("--------------------------------------\n");
  10. return 1;
  11. }
  12. new const modelNames[212][] = {
  13. "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster",
  14. "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  15. "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer",
  16. "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Article Trailer", "Previon", "Coach",
  17. "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow",
  18. "Pizzaboy", "Tram", "Article Trailer 2", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair",
  19. "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic",
  20. "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton",
  21. "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher",
  22. "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick",
  23. "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher",
  24. "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stuntplane", "Tanker", "Roadtrain",
  25. "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck",
  26. "Fortune", "Cadrona", "SWAT Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan",
  27. "Blade", "Streak", "Freight", "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder",
  28. "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster", "Monster",
  29. "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  30. "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30",
  31. "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Petrol Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  32. "Freight Box", "Article Trailer 3", "Andromada", "Dodo", "RC Cam", "Launch", "LSPD Car", "SFPD Car", "LVPD Car",
  33. "Police Rancher", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
  34. "Boxville", "Tiller", "Utility Trailer"
  35. };
  36. Float:GetVehicleSpeed(vehicleid)
  37. {
  38. new
  39. Float:x,
  40. Float:y,
  41. Float:z;
  42.  
  43. if(GetVehicleVelocity(vehicleid, x, y, z))
  44. {
  45. return floatsqroot((x * x) + (y * y) + (z * z)) * 181.5;
  46. }
  47.  
  48. return 0.0;
  49. }
  50. IsAbicycle(vehid)
  51. {
  52. switch(GetVehicleModel(vehid))
  53. {
  54. case 481, 509, 510: return true;
  55. }
  56. return false;
  57. }
  58. GetVehicleName(vehicleid)
  59. {
  60. new
  61. modelid = GetVehicleModel(vehicleid),
  62. name[32];
  63.  
  64. if(400 <= modelid <= 611)
  65. strcat(name, modelNames[modelid - 400]);
  66. else
  67. name = "Unknown";
  68.  
  69. return name;
  70. }
  71. public OnPlayerConnect(playerid)
  72. {
  73. //------------------------------------------------------------------------//
  74. cWspeedo[playerid][0] = CreatePlayerTextDraw(playerid, 525.111389, 394.088836, "box");
  75. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][0], 0.000000, -0.044444);
  76. PlayerTextDrawTextSize(playerid, cWspeedo[playerid][0], 623.000000, 0.000000);
  77. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][0], 1);
  78. PlayerTextDrawColor(playerid, cWspeedo[playerid][0], -1);
  79. PlayerTextDrawUseBox(playerid, cWspeedo[playerid][0], 1);
  80. PlayerTextDrawBoxColor(playerid, cWspeedo[playerid][0], 0x000000AA);
  81. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][0], 0);
  82. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][0], 0);
  83. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][0], 255);
  84. PlayerTextDrawFont(playerid, cWspeedo[playerid][0], 1);
  85. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][0], 1);
  86. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][0], 0);
  87.  
  88. cWspeedo[playerid][1] = CreatePlayerTextDraw(playerid, 627.777770, 365.715454, "box");
  89. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][1], 0.000000, 6.133327);
  90. PlayerTextDrawTextSize(playerid, cWspeedo[playerid][1], 621.000000, 0.000000);
  91. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][1], 1);
  92. PlayerTextDrawColor(playerid, cWspeedo[playerid][1], -1);
  93. PlayerTextDrawUseBox(playerid, cWspeedo[playerid][1], 1);
  94. PlayerTextDrawBoxColor(playerid, cWspeedo[playerid][1], 0x000000AA);
  95. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][1], 0);
  96. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][1], 0);
  97. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][1], 255);
  98. PlayerTextDrawFont(playerid, cWspeedo[playerid][1], 1);
  99. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][1], 1);
  100. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][1], 0);
  101.  
  102. cWspeedo[playerid][2] = CreatePlayerTextDraw(playerid, 565.889099, 341.168945, "");
  103. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][2], 0.000000, 0.000000);
  104. PlayerTextDrawTextSize(playerid, cWspeedo[playerid][2], 60.000000, 73.000000);
  105. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][2], 1);
  106. PlayerTextDrawColor(playerid, cWspeedo[playerid][2], -1);
  107. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][2], 0);
  108. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][2], 0);
  109. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][2], 0);
  110. PlayerTextDrawFont(playerid, cWspeedo[playerid][2], 5);
  111. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][2], 0);
  112. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][2], 0);
  113. PlayerTextDrawSetPreviewModel(playerid, cWspeedo[playerid][2], 411);
  114. PlayerTextDrawSetPreviewRot(playerid, cWspeedo[playerid][2], 0.000000, 0.000000, -30.000000, 1.000000);
  115. PlayerTextDrawSetPreviewVehCol(playerid, cWspeedo[playerid][2], 1, 1);
  116.  
  117. cWspeedo[playerid][3] = CreatePlayerTextDraw(playerid, 524.222167, 395.582153, "220");
  118. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][3], 0.342222, 1.316266);
  119. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][3], 1);
  120. PlayerTextDrawColor(playerid, cWspeedo[playerid][3], -1);
  121. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][3], 0);
  122. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][3], 1);
  123. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][3], 255);
  124. PlayerTextDrawFont(playerid, cWspeedo[playerid][3], 3);
  125. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][3], 1);
  126. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][3], 0);
  127.  
  128. cWspeedo[playerid][4] = CreatePlayerTextDraw(playerid, 523.777770, 382.142395, "infernus");
  129. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][4], 0.172888, 0.903111);
  130. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][4], 1);
  131. PlayerTextDrawColor(playerid, cWspeedo[playerid][4], -1);
  132. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][4], 0);
  133. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][4], 1);
  134. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][4], 255);
  135. PlayerTextDrawFont(playerid, cWspeedo[playerid][4], 2);
  136. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][4], 1);
  137. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][4], 0);
  138.  
  139. cWspeedo[playerid][5] = CreatePlayerTextDraw(playerid, 526.000244, 408.026733, "KM/H");
  140. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][5], 0.175555, 0.669155);
  141. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][5], 1);
  142. PlayerTextDrawColor(playerid, cWspeedo[playerid][5], -1378294017);
  143. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][5], 0);
  144. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][5], 0);
  145. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][5], 255);
  146. PlayerTextDrawFont(playerid, cWspeedo[playerid][5], 1);
  147. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][5], 1);
  148. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][5], 0);
  149.  
  150. cWspeedo[playerid][6] = CreatePlayerTextDraw(playerid, 572.933105, 396.080047, "100");
  151. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][6], 0.301333, 1.171911);
  152. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][6], 2);
  153. PlayerTextDrawColor(playerid, cWspeedo[playerid][6], -1);
  154. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][6], 0);
  155. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][6], 1);
  156. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][6], 255);
  157. PlayerTextDrawFont(playerid, cWspeedo[playerid][6], 3);
  158. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][6], 1);
  159. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][6], 0);
  160.  
  161. cWspeedo[playerid][7] = CreatePlayerTextDraw(playerid, 572.509460, 407.528869, "FUEL");
  162. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][7], 0.151111, 0.689067);
  163. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][7], 2);
  164. PlayerTextDrawColor(playerid, cWspeedo[playerid][7], -1378294017);
  165. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][7], 0);
  166. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][7], 0);
  167. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][7], 255);
  168. PlayerTextDrawFont(playerid, cWspeedo[playerid][7], 1);
  169. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][7], 1);
  170. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][7], 0);
  171.  
  172. cWspeedo[playerid][8] = CreatePlayerTextDraw(playerid, 621.111633, 396.080108, "999.0");
  173. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][8], 0.231555, 1.052444);
  174. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][8], 3);
  175. PlayerTextDrawColor(playerid, cWspeedo[playerid][8], -1);
  176. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][8], 0);
  177. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][8], 1);
  178. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][8], 255);
  179. PlayerTextDrawFont(playerid, cWspeedo[playerid][8], 3);
  180. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][8], 1);
  181. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][8], 0);
  182.  
  183. cWspeedo[playerid][9] = CreatePlayerTextDraw(playerid, 618.444335, 406.533325, "HEALTH");
  184. PlayerTextDrawLetterSize(playerid, cWspeedo[playerid][9], 0.145778, 0.699022);
  185. PlayerTextDrawAlignment(playerid, cWspeedo[playerid][9], 3);
  186. PlayerTextDrawColor(playerid, cWspeedo[playerid][9], -1378294017);
  187. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][9], 0);
  188. PlayerTextDrawSetOutline(playerid, cWspeedo[playerid][9], 0);
  189. PlayerTextDrawBackgroundColor(playerid, cWspeedo[playerid][9], 255);
  190. PlayerTextDrawFont(playerid, cWspeedo[playerid][9], 1);
  191. PlayerTextDrawSetProportional(playerid, cWspeedo[playerid][9], 1);
  192. PlayerTextDrawSetShadow(playerid, cWspeedo[playerid][9], 0);
  193.  
  194. //-------------------------------------------------------------------------//
  195.  
  196. return 1;
  197. }
  198.  
  199. public OnPlayerDisconnect(playerid, reason)
  200. {
  201. for(new i = 0; i < 10; i ++) {
  202. PlayerTextDrawDestroy(playerid, cWspeedo[playerid][i]);
  203. cWspeedo[playerid][i] = PlayerText:INVALID_TEXT_DRAW;
  204. }
  205. return 1;
  206. }
  207.  
  208.  
  209. public OnPlayerStateChange(playerid, newstate, oldstate)
  210. {
  211. if(newstate == PLAYER_STATE_DRIVER)
  212. {
  213. new vehicleid = GetPlayerVehicleID(playerid);
  214. new vstr[30];
  215. format(vstr, sizeof(vstr), "%s", GetVehicleName(vehicleid));
  216. PlayerTextDrawSetString(playerid, cWspeedo[playerid][4], vstr);
  217.  
  218. PlayerTextDrawSetPreviewModel(playerid, cWspeedo[playerid][2], GetVehicleModel(GetPlayerVehicleID(playerid)));
  219. PlayerTextDrawShow(playerid, cWspeedo[playerid][2]);
  220. if(!IsAbicycle(vehicleid))
  221. {
  222. for(new i = 0; i < 10; i++) {
  223. PlayerTextDrawShow(playerid, cWspeedo[playerid][i]);
  224. }
  225. }
  226. }
  227. else if(oldstate == PLAYER_STATE_DRIVER)
  228. {
  229. for(new i = 0; i < 10; i++) {
  230. PlayerTextDrawHide(playerid, cWspeedo[playerid][i]);
  231. }
  232. }
  233. return 1;
  234. }
  235.  
  236. public OnPlayerUpdate(playerid)
  237. {
  238. new vehicle = GetPlayerVehicleID(playerid);
  239. if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Making sure the player is in a vehicle as driver
  240. {
  241. new Float:H;
  242. GetVehicleHealth(vehicle, H);
  243. new speed[24];
  244. format(speed, sizeof(speed), "%.0f", GetVehicleSpeed(vehicle));
  245. PlayerTextDrawSetString(playerid, cWspeedo[playerid][3], speed);
  246. new vehfuel[24];
  247. format(vehfuel, sizeof(vehfuel), "%d", carfuel[vehicle]);
  248. PlayerTextDrawSetString(playerid, cWspeedo[playerid][6], vehfuel);
  249. new vehiclehealth[24];
  250. format(vehiclehealth, sizeof(vehiclehealth), "%.1f", H);
  251. PlayerTextDrawSetString(playerid, cWspeedo[playerid][8], vehiclehealth);
  252. }
  253. return 1;
  254. }
Add Comment
Please, Sign In to add comment