Advertisement
Guest User

SpeedMeter

a guest
Aug 15th, 2012
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. //Créditos:Feito por Bruno Alves
  2. #include <a_samp>
  3.  
  4. new Text:Textdraw0;
  5. new Text:Textdraw1;
  6. new Text:Textdraw2;
  7. new Float:Velocidade [3];
  8.  
  9. new Vehicles[][] ={
  10. "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
  11. "Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
  12. "Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
  13. "Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
  14. "RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
  15. "Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
  16. "PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
  17. "Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina","Comet","BMX",
  18. "Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
  19. "Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa",
  20. "RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
  21. "Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
  22. "Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
  23. "FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
  24. "Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
  25. "Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
  26. "Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
  27. "Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
  28. "BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
  29. "Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
  30. "Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
  31. "Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
  32.  
  33. public OnFilterScriptInit()
  34. {
  35.  
  36. Textdraw0 = TextDrawCreate(39.000000, 134.000000, "--");//text draw do veiculo
  37. TextDrawBackgroundColor(Textdraw0, 255);
  38. TextDrawFont(Textdraw0, 3);
  39. TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
  40. TextDrawColor(Textdraw0, 16711935);
  41. TextDrawSetOutline(Textdraw0, 1);
  42. TextDrawSetProportional(Textdraw0, 1);
  43. TextDrawTextSize(Textdraw0, 187.000000, 549.000000);
  44.  
  45. Textdraw1 = TextDrawCreate(39.000000, 149.000000, "--");//velocidade
  46. TextDrawBackgroundColor(Textdraw1, 255);
  47. TextDrawFont(Textdraw1, 3);
  48. TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
  49. TextDrawColor(Textdraw1, 16711935);
  50. TextDrawSetOutline(Textdraw1, 1);
  51. TextDrawSetProportional(Textdraw1, 1);
  52. TextDrawTextSize(Textdraw1, 187.000000, 272.000000);
  53. SetTimer("Speed", 1000, true);
  54.  
  55. Textdraw2 = TextDrawCreate(39.000000, 164.000000, "--");//Hp (vida)
  56. TextDrawBackgroundColor(Textdraw2, 255);
  57. TextDrawFont(Textdraw2, 3);
  58. TextDrawLetterSize(Textdraw2, 0.500000, 1.000000);
  59. TextDrawColor(Textdraw2, 16711935);
  60. TextDrawSetOutline(Textdraw2, 1);
  61. TextDrawSetProportional(Textdraw2, 1);
  62. TextDrawTextSize(Textdraw2, 187.000000, 272.000000);
  63. return 1;
  64. }
  65.  
  66. public OnFilterScriptExit()
  67. {
  68. TextDrawHideForAll(Textdraw2);
  69. TextDrawDestroy(Textdraw2);
  70. TextDrawHideForAll(Textdraw0);
  71. TextDrawDestroy(Textdraw0);
  72. TextDrawHideForAll(Textdraw1);
  73. TextDrawDestroy(Textdraw1);
  74. return 1;
  75. }
  76.  
  77. public OnPlayerStateChange(playerid, newstate, oldstate)
  78. {
  79. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  80. {
  81. Speed(playerid);
  82. }
  83. else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  84. {
  85. TextDrawHideForPlayer(playerid, Textdraw0);
  86. TextDrawHideForPlayer(playerid, Textdraw1);
  87. TextDrawHideForPlayer(playerid, Textdraw2);
  88. }
  89. return 1;
  90. }
  91.  
  92. forward Speed(playerid);
  93. public Speed(playerid)
  94. {
  95. new MySpeed[48];
  96. new MyCar[48];
  97. new MySaude[48];
  98. new Float:Speedo_HP;
  99. new vehicle = GetPlayerVehicleID(playerid);
  100. GetVehicleHealth(vehicle, Speedo_HP);
  101. format(MySpeed,sizeof(MySpeed),"~p~Speed:~y~%d Km/h",GetSpeed(playerid));
  102. format(MyCar,sizeof(MyCar),"~r~Veiculo:~b~%s",Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
  103. format(MySaude,sizeof(MySaude),"~p~Saude:~y~%0.0f%%",Speedo_HP/10);
  104. TextDrawSetString(Textdraw2, MySaude);
  105. TextDrawSetString(Textdraw1, MySpeed);
  106. TextDrawSetString(Textdraw0, MyCar);
  107. TextDrawShowForPlayer(playerid, Textdraw0);
  108. TextDrawShowForPlayer(playerid, Textdraw1);
  109. TextDrawShowForPlayer(playerid, Textdraw2);
  110. return 1;
  111. }
  112. stock
  113. GetSpeed ( playerid , mode = 1 )// stock by:SlashPT
  114. {
  115. GetVehicleVelocity ( GetPlayerVehicleID ( playerid ) , Velocidade [ 0 ] , Velocidade [ 1 ] , Velocidade [ 2 ] ) ;
  116. return IsPlayerInAnyVehicle ( playerid ) ? floatround ( ( ( floatsqroot ( ( ( Velocidade [ 0 ] * Velocidade [ 0 ] ) + ( Velocidade [ 1 ] * Velocidade [ 1 ] ) + ( Velocidade [ 2 ] * Velocidade [ 2 ] ) ) ) * ( !mode ? 105.0 : 170.0 ) ) ) * 1 ) : 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement