Advertisement
Guest User

Velocimetro/Speedometer

a guest
Aug 12th, 2013
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.61 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. new Text:velocimetro[MAX_PLAYERS],
  4.     Text:BoxVelcimetro[MAX_PLAYERS],
  5.     Text:Velocidade[MAX_PLAYERS],
  6.     Text:Foto[MAX_PLAYERS],
  7.     Text:Veiculo[MAX_PLAYERS],
  8.     Text:ModeloCarro[MAX_PLAYERS],
  9.     PlayerText:FotoCarro;
  10.  
  11. forward Velocimetro();
  12.  
  13. new NomeCarro[212][] =
  14. {
  15.     "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
  16.     "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat",
  17.     "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife",
  18.     "Trailer 1", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo",
  19.     "Seasparrow", "Pizzaboy", "Tram", "Trailer 2", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair",
  20.     "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic", "Sanchez", "Sparrow",
  21.     "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX", "Burrito",
  22.     "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring",
  23.     "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B",
  24.     "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster","Stunt",  "Tanker",
  25.     "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  26.     "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak",
  27.     "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck LA", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit",
  28.     "Utility", "Nevada", "Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance",
  29.     "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito", "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway",
  30.     "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros", "Hotdog",
  31.     "Club", "Freight Carriage", "Trailer 4", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
  32.     "Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer A",
  33.     "Luggage Trailer B", "Stairs", "BoxVille", "Tiller", "Utility Trailer"
  34. };
  35.  
  36. public OnGameModeInit()
  37. {
  38.     print("==================================================");
  39.     print("======== VELOCIMETRO CARREGADO COM SUCESSO =======");
  40.     print("===== BY: [RoXx]Okiinho_. e Cantiliano_. ========");
  41.     print("==================================================");
  42.     SetTimer("Velocimetro", 1, 1);
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerConnect(playerid)
  47. {
  48.  
  49.     velocimetro[playerid] = TextDrawCreate(262.000000, 383.000000, "130 km/h");
  50.     TextDrawBackgroundColor(velocimetro[playerid], -16776961);
  51.     TextDrawFont(velocimetro[playerid], 2);
  52.     TextDrawLetterSize(velocimetro[playerid], 0.419997, 3.099997);
  53.     TextDrawColor(velocimetro[playerid], -65281);
  54.     TextDrawSetOutline(velocimetro[playerid], 1);
  55.     TextDrawSetProportional(velocimetro[playerid], 1);
  56.     TextDrawSetSelectable(velocimetro[playerid], 0);
  57.  
  58.     BoxVelcimetro[playerid] = TextDrawCreate(441.000000, 367.000000, "~n~");
  59.     TextDrawBackgroundColor(BoxVelcimetro[playerid], 255);
  60.     TextDrawFont(BoxVelcimetro[playerid], 1);
  61.     TextDrawLetterSize(BoxVelcimetro[playerid], 1.709998, 6.199995);
  62.     TextDrawColor(BoxVelcimetro[playerid], -1);
  63.     TextDrawSetOutline(BoxVelcimetro[playerid], 0);
  64.     TextDrawSetProportional(BoxVelcimetro[playerid], 1);
  65.     TextDrawSetShadow(BoxVelcimetro[playerid], 1);
  66.     TextDrawUseBox(BoxVelcimetro[playerid], 1);
  67.     TextDrawBoxColor(BoxVelcimetro[playerid], 102);
  68.     TextDrawTextSize(BoxVelcimetro[playerid], 170.000000, -3.000000);
  69.     TextDrawSetSelectable(BoxVelcimetro[playerid], 0);
  70.  
  71.     Velocidade[playerid] = TextDrawCreate(267.000000, 365.000000, "Velocidade");
  72.     TextDrawBackgroundColor(Velocidade[playerid], 255);
  73.     TextDrawFont(Velocidade[playerid], 2);
  74.     TextDrawLetterSize(Velocidade[playerid], 0.250000, 1.800001);
  75.     TextDrawColor(Velocidade[playerid], -1);
  76.     TextDrawSetOutline(Velocidade[playerid], 1);
  77.     TextDrawSetProportional(Velocidade[playerid], 1);
  78.     TextDrawSetSelectable(Velocidade[playerid], 0);
  79.  
  80.     Foto[playerid] = TextDrawCreate(193.000000, 366.000000, "FOTO");
  81.     TextDrawBackgroundColor(Foto[playerid], 255);
  82.     TextDrawFont(Foto[playerid], 2);
  83.     TextDrawLetterSize(Foto[playerid], 0.319999, 1.799999);
  84.     TextDrawColor(Foto[playerid], -1);
  85.     TextDrawSetOutline(Foto[playerid], 0);
  86.     TextDrawSetProportional(Foto[playerid], 1);
  87.     TextDrawSetShadow(Foto[playerid], 1);
  88.     TextDrawSetSelectable(Foto[playerid], 0);
  89.  
  90.     Veiculo[playerid] = TextDrawCreate(366.000000, 365.000000, "Veiculo");
  91.     TextDrawBackgroundColor(Veiculo[playerid], 255);
  92.     TextDrawFont(Veiculo[playerid], 2);
  93.     TextDrawLetterSize(Veiculo[playerid], 0.319999, 1.799999);
  94.     TextDrawColor(Veiculo[playerid], -1);
  95.     TextDrawSetOutline(Veiculo[playerid], 0);
  96.     TextDrawSetProportional(Veiculo[playerid], 1);
  97.     TextDrawSetShadow(Veiculo[playerid], 1);
  98.     TextDrawSetSelectable(Veiculo[playerid], 0);
  99.  
  100.     ModeloCarro[playerid] = TextDrawCreate(356.000000, 391.000000, "_");
  101.     TextDrawBackgroundColor(ModeloCarro[playerid], 255);
  102.     TextDrawFont(ModeloCarro[playerid], 2);
  103.     TextDrawLetterSize(ModeloCarro[playerid], 0.250000, 1.200000);
  104.     TextDrawColor(ModeloCarro[playerid], -1);
  105.     TextDrawSetOutline(ModeloCarro[playerid], 1);
  106.     TextDrawSetProportional(ModeloCarro[playerid], 1);
  107.     TextDrawSetSelectable(ModeloCarro[playerid], 0);
  108.  
  109.     FotoCarro = CreatePlayerTextDraw(playerid, 192.000000, 384.000000, "_");
  110.     PlayerTextDrawFont(playerid, FotoCarro, TEXT_DRAW_FONT_MODEL_PREVIEW);
  111.     PlayerTextDrawTextSize(playerid, FotoCarro, 40.0, 40.0);
  112.     PlayerTextDrawSetPreviewModel(playerid, FotoCarro, 400);
  113.     PlayerTextDrawSetPreviewRot(playerid, FotoCarro, -10.0, 0.0, -20.0, 1.0);
  114.     return true;
  115. }
  116.  
  117. public Velocimetro()
  118. {
  119.     for(new i = 0; i < MAX_PLAYERS; i++)
  120.     {
  121.         if(IsPlayerConnected(i))
  122.         {
  123.             new aname[MAX_PLAYER_NAME];
  124.             GetPlayerName(i, aname, MAX_PLAYER_NAME);
  125.             if(IsPlayerInAnyVehicle(i))
  126.             {
  127.                 new Float:X, Float:Y, Float:Z, Float:Speed;
  128.                 GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
  129.                 Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 200.0);
  130.                 new Float:vcarro;
  131.                 GetVehicleHealth(GetPlayerVehicleID(i), vcarro);
  132.                 new velocidade;
  133.                 velocidade = floatround(Speed, floatround_floor);
  134.                
  135.                 new string[128];
  136.                
  137.                 new PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i));
  138.                 PlayerVehicleModelID -= 400;
  139.                 new nocarro[30];
  140.                 format(nocarro,30,NomeCarro[PlayerVehicleModelID]);
  141.                
  142.                 format(string, 128,"%s",nocarro);
  143.                 TextDrawSetString(ModeloCarro[i], string);
  144.  
  145.                 format(string, 128,"%i KM/H",velocidade);
  146.                 TextDrawSetString(velocimetro[i], string);
  147.  
  148.                 TextDrawShowForPlayer(i, velocimetro[i]);
  149.                 TextDrawShowForPlayer(i, BoxVelcimetro[i]);
  150.                 TextDrawShowForPlayer(i, Velocidade[i]);
  151.                 TextDrawShowForPlayer(i, Foto[i]);
  152.                 TextDrawShowForPlayer(i, Veiculo[i]);
  153.                 TextDrawShowForPlayer(i, ModeloCarro[i]);
  154.         }
  155.             else
  156.         {
  157.             TextDrawHideForPlayer(i, velocimetro[i]);
  158.             TextDrawHideForPlayer(i, BoxVelcimetro[i]);
  159.             TextDrawHideForPlayer(i, Velocidade[i]);
  160.             TextDrawHideForPlayer(i, Foto[i]);
  161.             TextDrawHideForPlayer(i, Veiculo[i]);
  162.             TextDrawHideForPlayer(i, ModeloCarro[i]);
  163.         }
  164.         }
  165.     }
  166.     return true;
  167. }
  168.  
  169. public OnPlayerDisconnect(playerid, reason)
  170. {
  171.     PlayerTextDrawHide(playerid, FotoCarro);
  172.     return 1;
  173. }
  174.  
  175. public OnPlayerStateChange(playerid, newstate, oldstate)
  176. {
  177.     new vid = GetPlayerVehicleID(playerid);
  178.     if(newstate == PLAYER_STATE_DRIVER)
  179.     {
  180.         PlayerTextDrawSetPreviewModel(playerid, FotoCarro, GetVehicleModel(vid));
  181.         PlayerTextDrawShow(playerid, FotoCarro);
  182.     }
  183.     else
  184.     {
  185.         PlayerTextDrawHide(playerid, FotoCarro);
  186.     }
  187.     return 1;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement