Advertisement
Guest User

Brzinometar

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