SHARE
TWEET

aVelocimetro 2.0

a guest Jun 3rd, 2014 250 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include a_samp
  2. #include zcmd
  3. #include sscanf2
  4.  
  5. new fuel;
  6.  
  7. new VehicleNames[][] = {
  8.     "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  9.     "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  10.     "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  11.     "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  12.     "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  13.     "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  14.     "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  15.     "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  16.     "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  17.     "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  18.     "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  19.     "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  20.     "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  21.     "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  22.     "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin",
  23.     "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  24.     "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  25.     "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  26.     "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  27.     "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  28.     "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  29.     "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  30.     "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  31.     "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
  32.     "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  33.     "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  34.     "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  35.     "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  36.     "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  37.     "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  38.     "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
  39.     "Tiller", "Utility Trailer"
  40. };
  41.  
  42. //Player Textdraws:
  43.  
  44. new PlayerText:v_velocidade [MAX_PLAYERS];
  45. new PlayerText:v_gasolina[MAX_PLAYERS];
  46. new PlayerText:v_nome[MAX_PLAYERS];
  47. new PlayerText:v_progress_branco_gas[MAX_PLAYERS];
  48. new PlayerText:v_progress_branco_velo[MAX_PLAYERS];
  49. new PlayerText:v_progress_azul_velo[MAX_PLAYERS];
  50. new PlayerText:v_progress_ver_velo[MAX_PLAYERS];
  51. new PlayerText:v_progress_cinza_velo[MAX_PLAYERS];
  52. new PlayerText:v_progress_cinza_gas[MAX_PLAYERS];
  53.  
  54. public OnFilterScriptInit() {
  55.     SetTimer("a_velocimetro", 100, true);
  56.     return true;
  57. }
  58.  
  59. public OnPlayerConnect(playerid) {
  60.     v_velocidade[playerid] = CreatePlayerTextDraw(playerid, 603.581237, 332.749847, "100");
  61.     PlayerTextDrawLetterSize(playerid, v_velocidade[playerid], 0.439222, 1.424997);
  62.     PlayerTextDrawAlignment(playerid, v_velocidade[playerid], 1);
  63.     PlayerTextDrawColor(playerid, v_velocidade[playerid], -1138808065);
  64.     PlayerTextDrawSetShadow(playerid, v_velocidade[playerid], 1);
  65.     PlayerTextDrawSetOutline(playerid, v_velocidade[playerid], 0);
  66.     PlayerTextDrawBackgroundColor(playerid, v_velocidade[playerid], -1);
  67.     PlayerTextDrawFont(playerid, v_velocidade[playerid], 3);
  68.     PlayerTextDrawSetProportional(playerid, v_velocidade[playerid], 1);
  69.  
  70.     v_gasolina[playerid] = CreatePlayerTextDraw(playerid, 603.644226, 347.750000, "100");
  71.     PlayerTextDrawLetterSize(playerid, v_gasolina[playerid], 0.439222, 1.424997);
  72.     PlayerTextDrawAlignment(playerid, v_gasolina[playerid], 1);
  73.     PlayerTextDrawColor(playerid, v_gasolina[playerid], 121335295);
  74.     PlayerTextDrawSetShadow(playerid, v_gasolina[playerid], 1);
  75.     PlayerTextDrawSetOutline(playerid, v_gasolina[playerid], 0);
  76.     PlayerTextDrawBackgroundColor(playerid, v_gasolina[playerid], -1);
  77.     PlayerTextDrawFont(playerid, v_gasolina[playerid], 3);
  78.     PlayerTextDrawSetProportional(playerid, v_gasolina[playerid], 1);
  79.  
  80.     v_nome[playerid] = CreatePlayerTextDraw(playerid, 507.939697, 305.499786, "Sultan");
  81.     PlayerTextDrawLetterSize(playerid, v_nome[playerid], 0.398461, 2.090001);
  82.     PlayerTextDrawAlignment(playerid, v_nome[playerid], 1);
  83.     PlayerTextDrawColor(playerid, v_nome[playerid], -1);
  84.     PlayerTextDrawSetShadow(playerid, v_nome[playerid], 0);
  85.     PlayerTextDrawSetOutline(playerid, v_nome[playerid], 256);
  86.     PlayerTextDrawBackgroundColor(playerid, v_nome[playerid], 51);
  87.     PlayerTextDrawFont(playerid, v_nome[playerid], 3);
  88.     PlayerTextDrawSetProportional(playerid, v_nome[playerid], 1);
  89.     PlayerTextDrawSetSelectable(playerid, v_nome[playerid], true);
  90.  
  91.     v_progress_branco_gas[playerid] = CreatePlayerTextDraw(playerid, 603.176086, 350.749877, "usebox");//progres fundo gas
  92.     PlayerTextDrawLetterSize(playerid, v_progress_branco_gas[playerid], 0.000000, 0.967953);
  93.     PlayerTextDrawTextSize(playerid, v_progress_branco_gas[playerid], 506.345458, 0.000000);
  94.     PlayerTextDrawUseBox(playerid, v_progress_branco_gas[playerid], true);
  95.     PlayerTextDrawBoxColor(playerid, v_progress_branco_gas[playerid], -1);
  96.  
  97.     v_progress_branco_velo[playerid] = CreatePlayerTextDraw(playerid, 603.113037, 327.583374, "usebox");//progress fundo velo
  98.     PlayerTextDrawLetterSize(playerid, v_progress_branco_velo[playerid], 0.000000, 1.858143);
  99.     PlayerTextDrawTextSize(playerid, v_progress_branco_velo[playerid], 506.345520, 0.000000);
  100.     PlayerTextDrawUseBox(playerid, v_progress_branco_velo[playerid], true);
  101.     PlayerTextDrawBoxColor(playerid, v_progress_branco_velo[playerid], -1);
  102.  
  103.     v_progress_azul_velo[playerid] = CreatePlayerTextDraw(playerid, 602.770507, 351.749847, "usebox"); //progress azul
  104.     PlayerTextDrawLetterSize(playerid, v_progress_azul_velo[playerid], 0.000000, 0.827396);
  105.     PlayerTextDrawTextSize(playerid, v_progress_azul_velo[playerid], 506.813995, 0.000000);
  106.     PlayerTextDrawUseBox(playerid, v_progress_azul_velo[playerid], true);
  107.     PlayerTextDrawBoxColor(playerid, v_progress_azul_velo[playerid], 121335295);
  108.  
  109.     v_progress_ver_velo[playerid] = CreatePlayerTextDraw(playerid, 602.833435, 328.249816, "usebox"); //progress vermelho
  110.     PlayerTextDrawLetterSize(playerid, v_progress_ver_velo[playerid], 0.000000, 1.717586);
  111.     PlayerTextDrawTextSize(playerid, v_progress_ver_velo[playerid], 506.833435, 0.000000);
  112.     PlayerTextDrawUseBox(playerid, v_progress_ver_velo[playerid], true);
  113.     PlayerTextDrawBoxColor(playerid, v_progress_ver_velo[playerid], -1138808065);
  114.    
  115.     v_progress_cinza_velo[playerid] = CreatePlayerTextDraw(playerid, 602.833435, 328.249816, "usebox"); //progress velocidade
  116.     PlayerTextDrawLetterSize(playerid, v_progress_cinza_velo[playerid], 0.000000, 1.717586);
  117.     PlayerTextDrawTextSize(playerid, v_progress_cinza_velo[playerid], 506.833435, 0.000000);
  118.     PlayerTextDrawUseBox(playerid, v_progress_cinza_velo[playerid], true);
  119.     PlayerTextDrawBoxColor(playerid, v_progress_cinza_velo[playerid], 0x707170FF);
  120.  
  121.     v_progress_cinza_gas[playerid] = CreatePlayerTextDraw(playerid, 602.770507, 351.749847, "usebox"); //progress gasolina
  122.     PlayerTextDrawLetterSize(playerid, v_progress_cinza_gas[playerid], 0.000000, 0.827396);
  123.     PlayerTextDrawTextSize(playerid, v_progress_cinza_gas[playerid], 506.813995, 0.000000);
  124.     PlayerTextDrawUseBox(playerid, v_progress_cinza_gas[playerid], true);
  125.     PlayerTextDrawBoxColor(playerid, v_progress_cinza_gas[playerid], 0x707170FF);
  126.     return true;
  127. }
  128.  
  129. forward a_velocimetro();
  130. public a_velocimetro() {
  131.     for(new i; i < MAX_PLAYERS; i++) {
  132.         if(GetPlayerState(i) == PLAYER_STATE_DRIVER) {
  133.             new fVelocidade = floatround(GetVehicleSpeed(GetPlayerVehicleID(i), 1)), v_index = GetPlayerVehicleID(i);
  134.             new string_velocidade[32], string_gasolina[32];
  135.  
  136.             PlayerTextDrawShow(i, v_velocidade[i]);
  137.             PlayerTextDrawShow(i, v_gasolina[i]);
  138.             PlayerTextDrawShow(i, v_nome[i]);
  139.             PlayerTextDrawShow(i, v_progress_branco_gas[i]);
  140.             PlayerTextDrawShow(i, v_progress_branco_velo[i]);
  141.             PlayerTextDrawShow(i, v_progress_azul_velo[i]);
  142.             PlayerTextDrawShow(i, v_progress_ver_velo[i]);
  143.             PlayerTextDrawShow(i, v_progress_cinza_velo[i]);
  144.             PlayerTextDrawShow(i, v_progress_cinza_gas[i]);
  145.            
  146.             format(string_gasolina, sizeof(string_gasolina), "%d", fuel), PlayerTextDrawSetString(i, v_gasolina[i], string_gasolina);
  147.             format(string_velocidade, sizeof(string_velocidade), "%i", fVelocidade), PlayerTextDrawSetString(i, v_velocidade[i], string_velocidade);
  148.             PlayerTextDrawSetString(i, v_nome[i], GetVehicleName(v_index));
  149.             //
  150.             PlayerTextDrawTextSize(i, v_progress_cinza_velo[i], (507.00 + ((97.0 * fVelocidade) / 160)), 0.0);
  151.             //
  152.             switch(fuel) {
  153.                 case 94 .. 100: PlayerTextDrawTextSize(i, v_progress_cinza_gas[i], (507.00 + ((97.0 * 100) / 100 -5.5)), 0.0);
  154.                 default: PlayerTextDrawTextSize(i, v_progress_cinza_gas[i], (507.00 + ((97.0 * fuel) / 100 )), 0.0);
  155.             }
  156.         }
  157.         else {
  158.             PlayerTextDrawHide(i, v_velocidade[i]);
  159.             PlayerTextDrawHide(i, v_gasolina[i]);
  160.             PlayerTextDrawHide(i, v_nome[i]);
  161.             PlayerTextDrawHide(i, v_progress_branco_gas[i]);
  162.             PlayerTextDrawHide(i, v_progress_branco_velo[i]);
  163.             PlayerTextDrawHide(i, v_progress_azul_velo[i]);
  164.             PlayerTextDrawHide(i, v_progress_ver_velo[i]);
  165.             PlayerTextDrawHide(i, v_progress_cinza_velo[i]);
  166.             PlayerTextDrawHide(i, v_progress_cinza_gas[i]);
  167.         }
  168.     }
  169.     return 1;
  170. }
  171.  
  172. forward Float:GetVehicleSpeed(vehicleid, UseMPH = 0);
  173. stock Float:GetVehicleSpeed(vehicleid, UseMPH = 0) {
  174.     new Float:speed_x, Float:speed_y, Float:speed_z, Float:temp_speed;
  175.     GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
  176.     if(UseMPH == 0) temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
  177.     else temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
  178.     floatround(temp_speed,floatround_round);
  179.     return temp_speed;
  180. }
  181.  
  182. stock GetVehicleName(vehicleid) {
  183.     new String[128];
  184.     format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
  185.     return String;
  186. }
  187.  
  188. command(criarcarro, playerid, params []) { //debud
  189.     new index, Float:pl_x, Float:pl_y, Float:pl_z;
  190.     GetPlayerPos(playerid, pl_x, pl_y, pl_z);
  191.     if(sscanf(params, "d", index)) return CreateVehicle(411, pl_x, pl_y, pl_z, 0.0, 6, 6, 99999999);
  192.     return CreateVehicle(index, pl_x, pl_y, pl_z, 0.0, 6, 6, 99999999);
  193. }
  194.  
  195. command(setfuel, playerid, params []) { //debud
  196.     new index;
  197.     if(sscanf(params, "d", index)) return false;
  198.     fuel = index;
  199.     return true;
  200. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top