Guest User

oSpeeDo1.2

a guest
Jun 12th, 2010
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.57 KB | None | 0 0
  1. #include <a_samp>
  2. /*Please leave credits if using!*/
  3. forward CheckSpeed();
  4. new Text:KMH[MAX_PLAYERS];
  5. new Text:Name[MAX_PLAYERS];
  6. new Text:CarH[MAX_PLAYERS];
  7. new Text:Type[MAX_PLAYERS];
  8. new Text:Out1[MAX_PLAYERS],Text:Out2[MAX_PLAYERS],Text:Out3[MAX_PLAYERS];
  9. new Text:Out4[MAX_PLAYERS],Text:Out5[MAX_PLAYERS],Text:Out6[MAX_PLAYERS];
  10. new Text:Out7[MAX_PLAYERS],Text:Out8[MAX_PLAYERS],Text:Out9[MAX_PLAYERS];
  11. new CarsName[][] = {
  12.    "Landstalker",
  13.    "Bravura",
  14.    "Buffalo",
  15.    "Linerunner",
  16.    "Pereniel",
  17.    "Sentinel",
  18.    "Dumper",
  19.    "Firetruck",
  20.    "Trashmaster",
  21.    "Stretch",
  22.    "Manana",
  23.    "Infernus",
  24.    "Voodoo",
  25.    "Pony",
  26.    "Mule",
  27.    "Cheetah",
  28.    "Ambulance",
  29.    "Leviathan",
  30.    "Moonbeam",
  31.    "Esperanto",
  32.    "Taxi",
  33.    "Washington",
  34.    "Bobcat",
  35.    "Mr Whoopee",
  36.    "BF Injection",
  37.    "Hunter",
  38.    "Premier",
  39.    "Enforcer",
  40.    "Securicar",
  41.    "Banshee",
  42.    "Predator",
  43.    "Bus",
  44.    "Rhino",
  45.    "Barracks",
  46.    "Hotknife",
  47.    "Trailer",
  48.    "Previon",
  49.    "Coach",
  50.    "Cabbie",
  51.    "Stallion",
  52.    "Rumpo",
  53.    "RC Bandit",
  54.    "Romero",
  55.    "Packer",
  56.    "Monster",
  57.    "Admiral",
  58.    "Squalo",
  59.    "Seasparrow",
  60.    "Pizzaboy",
  61.    "Tram",
  62.    "Trailer",
  63.    "Turismo",
  64.    "Speeder",
  65.    "Reefer",
  66.    "Tropic",
  67.    "Flatbed",
  68.    "Yankee",
  69.    "Caddy",
  70.    "Solair",
  71.    "RC Van",
  72.    "Skimmer",
  73.    "PCJ-600",
  74.    "Faggio",
  75.    "Freeway",
  76.    "RC Baron",
  77.    "RC Raider",
  78.    "Glendale",
  79.    "Oceanic",
  80.    "Sanchez",
  81.    "Sparrow",
  82.    "Patriot",
  83.    "Quad",
  84.    "Coastguard",
  85.    "Dinghy",
  86.    "Hermes",
  87.    "Sabre",
  88.    "Rustler",
  89.    "ZR-350",
  90.    "Walton",
  91.    "Regina",
  92.    "Comet",
  93.    "BMX",
  94.    "Burrito",
  95.    "Camper",
  96.    "Marquis",
  97.    "Baggage",
  98.    "Dozer",
  99.    "Maverick",
  100.    "News Chopper",
  101.    "Rancher",
  102.    "FBI Rancher",
  103.    "Virgo",
  104.    "Greenwood",
  105.    "Jetmax",
  106.    "Hotring",
  107.    "Sandking",
  108.    "Blista Compact",
  109.    "PD Maverick",
  110.    "Boxville",
  111.    "Benson",
  112.    "Mesa",
  113.    "RC Goblin",
  114.    "Hotring",
  115.    "Hotring",
  116.    "Bloodring",
  117.    "Rancher",
  118.    "Super GT",
  119.    "Elegant",
  120.    "Journey",
  121.    "Bike",
  122.    "Mountain Bike",
  123.    "Beagle",
  124.    "Cropdust",
  125.    "Stunt",
  126.    "Tanker",
  127.    "RoadTrain",
  128.    "Nebula",
  129.    "Majestic",
  130.    "Buccaneer",
  131.    "Shamal",
  132.    "Hydra",
  133.    "FCR-900",
  134.    "NRG-500",
  135.    "HPV1000",
  136.    "Cement",
  137.    "Tow Truck",
  138.    "Fortune",
  139.    "Cadrona",
  140.    "FBI Truck",
  141.    "Willard",
  142.    "Forklift",
  143.    "Tractor",
  144.    "Combine",
  145.    "Feltzer",
  146.    "Remington",
  147.    "Slamvan",
  148.    "Blade",
  149.    "Freight",
  150.    "Streak",
  151.    "Vortex",
  152.    "Vincent",
  153.    "Bullet",
  154.    "Clover",
  155.    "Sadler",
  156.    "Firetruck",
  157.    "Hustler",
  158.    "Intruder",
  159.    "Primo",
  160.    "Cargobob",
  161.    "Tampa",
  162.    "Sunrise",
  163.    "Merit",
  164.    "Utility",
  165.    "Nevada",
  166.    "Yosemite",
  167.    "Windsor",
  168.    "Monster",
  169.    "Monster",
  170.    "Uranus",
  171.    "Jester",
  172.    "Sultan",
  173.    "Stratum",
  174.    "Elegy",
  175.    "Raindance",
  176.    "RC Tiger",
  177.    "Flash",
  178.    "Tahoma",
  179.    "Savanna",
  180.    "Bandito",
  181.    "Freight",
  182.    "Trailer",
  183.    "Kart",
  184.    "Mower",
  185.    "Duneride",
  186.    "Sweeper",
  187.    "Broadway",
  188.    "Tornado",
  189.    "AT-400",
  190.    "DFT-30",
  191.    "Huntley",
  192.    "Stafford",
  193.    "BF-400",
  194.    "Newsvan",
  195.    "Tug",
  196.    "Trailer",
  197.    "Emperor",
  198.    "Wayfarer",
  199.    "Euros",
  200.    "Hotdog",
  201.    "Club",
  202.    "Trailer",
  203.    "Trailer",
  204.    "Andromada",
  205.    "Dodo",
  206.    "RC Cam",
  207.    "Launch",
  208.    "Police Car",
  209.    "Police Car",
  210.    "Police Car",
  211.    "Police Ranger",
  212.    "Picador",
  213.    "S.W.A.T",
  214.    "Alpha",
  215.    "Phoenix",
  216.    "Glendale",
  217.    "Sadler",
  218.    "Luggage Trailer",
  219.    "Luggage Trailer",
  220.    "Stair Trailer",
  221.    "Boxville",
  222.    "Farm Plow",
  223.    "Utility Trailer"
  224. };
  225. public OnFilterScriptInit()
  226. {
  227.     print("***********************************");
  228.     print("*     SA-MP Speedometer by O_x    *");
  229.     print("*        FILTERSCRIPT:LOADED      *");
  230.     print("***********************************");
  231.     SetTimer("CheckSpeed",150,1);
  232.     for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  233.     {
  234.     KMH[playerid] = TextDrawCreate(501.000000, 414.000000, "KM/H:");
  235.     TextDrawBackgroundColor(KMH[playerid], 255);
  236.     TextDrawFont(KMH[playerid], 1);
  237.     TextDrawLetterSize(KMH[playerid], 0.400000, 1.0000000);
  238.     TextDrawColor(KMH[playerid], -1);
  239.     TextDrawSetOutline(KMH[playerid], 1);
  240.     TextDrawSetProportional(KMH[playerid], 1);
  241.     TextDrawUseBox(KMH[playerid], 1);
  242.     TextDrawBoxColor(KMH[playerid], -2139062187);
  243.     TextDrawTextSize(KMH[playerid], 636.000000, 0.000000);
  244.  
  245.     Type[playerid] = TextDrawCreate(501.000000, 431.000000, "Type:");
  246.     TextDrawBackgroundColor(Type[playerid], 255);
  247.     TextDrawFont(Type[playerid], 1);
  248.     TextDrawLetterSize(Type[playerid], 0.400000, 1.000000);
  249.     TextDrawColor(Type[playerid], -1);
  250.     TextDrawSetOutline(Type[playerid], 1);
  251.     TextDrawSetProportional(Type[playerid], 1);
  252.     TextDrawUseBox(Type[playerid], 1);
  253.     TextDrawBoxColor(Type[playerid], -2139062187);
  254.     TextDrawTextSize(Type[playerid], 636.000000, 0.000000);
  255.  
  256.     CarH[playerid] = TextDrawCreate(501.000000, 398.000000, "Health:");
  257.     TextDrawBackgroundColor(CarH[playerid], 255);
  258.     TextDrawFont(CarH[playerid], 1);
  259.     TextDrawLetterSize(CarH[playerid], 0.400000, 1.0000000);
  260.     TextDrawColor(CarH[playerid], -1);
  261.     TextDrawSetOutline(CarH[playerid], 1);
  262.     TextDrawSetProportional(CarH[playerid], 1);
  263.     TextDrawUseBox(CarH[playerid], 1);
  264.     TextDrawBoxColor(CarH[playerid], -2139062187);
  265.     TextDrawTextSize(CarH[playerid], 636.000000, 0.000000);
  266.  
  267.     Name[playerid] = TextDrawCreate(501.000000, 382.000000, "Name:");
  268.     TextDrawBackgroundColor(Name[playerid], 255);
  269.     TextDrawFont(Name[playerid], 1);
  270.     TextDrawLetterSize(Name[playerid], 0.400000, 1.000000);
  271.     TextDrawColor(Name[playerid], -1);
  272.     TextDrawSetOutline(Name[playerid], 1);
  273.     TextDrawSetProportional(Name[playerid], 1);
  274.     TextDrawUseBox(Name[playerid], 1);
  275.     TextDrawBoxColor(Name[playerid], -2139062187);
  276.     TextDrawTextSize(Name[playerid], 636.000000, 0.000000);
  277.  
  278.     Out1[playerid] = TextDrawCreate(501.000000, 434.000000, "_");
  279.     TextDrawBackgroundColor(Out1[playerid], 255);
  280.     TextDrawFont(Out1[playerid], 1);
  281.     TextDrawLetterSize(Out1[playerid], 0.500000, 1.000000);
  282.     TextDrawColor(Out1[playerid], -1);
  283.     TextDrawSetOutline(Out1[playerid], 0);
  284.     TextDrawSetProportional(Out1[playerid], 1);
  285.     TextDrawSetShadow(Out1[playerid], 1);
  286.     TextDrawUseBox(Out1[playerid], 1);
  287.     TextDrawBoxColor(Out1[playerid], 255);
  288.     TextDrawTextSize(Out1[playerid], 489.000000, 0.000000);
  289.  
  290.     Out2[playerid] = TextDrawCreate(501.000000, 419.000000, "_");
  291.     TextDrawBackgroundColor(Out2[playerid], 255);
  292.     TextDrawFont(Out2[playerid], 1);
  293.     TextDrawLetterSize(Out2[playerid], 0.500000, 1.000000);
  294.     TextDrawColor(Out2[playerid], -1);
  295.     TextDrawSetOutline(Out2[playerid], 0);
  296.     TextDrawSetProportional(Out2[playerid], 1);
  297.     TextDrawSetShadow(Out2[playerid], 1);
  298.     TextDrawUseBox(Out2[playerid], 1);
  299.     TextDrawBoxColor(Out2[playerid], 255);
  300.     TextDrawTextSize(Out2[playerid], 489.000000, 0.000000);
  301.  
  302.     Out3[playerid] = TextDrawCreate(501.000000, 402.000000, "_");
  303.     TextDrawBackgroundColor(Out3[playerid], 255);
  304.     TextDrawFont(Out3[playerid], 1);
  305.     TextDrawLetterSize(Out3[playerid], 0.500000, 1.000000);
  306.     TextDrawColor(Out3[playerid], -1);
  307.     TextDrawSetOutline(Out3[playerid], 0);
  308.     TextDrawSetProportional(Out3[playerid], 1);
  309.     TextDrawSetShadow(Out3[playerid], 1);
  310.     TextDrawUseBox(Out3[playerid], 1);
  311.     TextDrawBoxColor(Out3[playerid], 255);
  312.     TextDrawTextSize(Out3[playerid], 489.000000, 0.000000);
  313.  
  314.     Out4[playerid] = TextDrawCreate(501.000000, 386.000000, "_");
  315.     TextDrawBackgroundColor(Out4[playerid], 255);
  316.     TextDrawFont(Out4[playerid], 1);
  317.     TextDrawLetterSize(Out4[playerid], 0.500000, 1.000000);
  318.     TextDrawColor(Out4[playerid], -1);
  319.     TextDrawSetOutline(Out4[playerid], 0);
  320.     TextDrawSetProportional(Out4[playerid], 1);
  321.     TextDrawSetShadow(Out4[playerid], 1);
  322.     TextDrawUseBox(Out4[playerid], 1);
  323.     TextDrawBoxColor(Out4[playerid], 255);
  324.     TextDrawTextSize(Out4[playerid], 489.000000, 0.000000);
  325.  
  326.     Out5[playerid] = TextDrawCreate(501.000000, 386.000000, "_");
  327.     TextDrawBackgroundColor(Out5[playerid], 255);
  328.     TextDrawFont(Out5[playerid], 1);
  329.     TextDrawLetterSize(Out5[playerid], 0.500000, 1.000000);
  330.     TextDrawColor(Out5[playerid], -1);
  331.     TextDrawSetOutline(Out5[playerid], 0);
  332.     TextDrawSetProportional(Out5[playerid], 1);
  333.     TextDrawSetShadow(Out5[playerid], 1);
  334.     TextDrawUseBox(Out5[playerid], 1);
  335.     TextDrawBoxColor(Out5[playerid], 255);
  336.     TextDrawTextSize(Out5[playerid], 489.000000, 0.000000);
  337.  
  338.     Out6[playerid] = TextDrawCreate(501.000000, 382.000000, "_");
  339.     TextDrawBackgroundColor(Out6[playerid], 255);
  340.     TextDrawFont(Out6[playerid], 1);
  341.     TextDrawLetterSize(Out6[playerid], 0.500000, 1.000000);
  342.     TextDrawColor(Out6[playerid], -1);
  343.     TextDrawSetOutline(Out6[playerid], 0);
  344.     TextDrawSetProportional(Out6[playerid], 1);
  345.     TextDrawSetShadow(Out6[playerid], 1);
  346.     TextDrawUseBox(Out6[playerid], 1);
  347.     TextDrawBoxColor(Out6[playerid], 255);
  348.     TextDrawTextSize(Out6[playerid], 489.000000, 0.000000);
  349.  
  350.     Out7[playerid] = TextDrawCreate(653.000000, 377.000000, "_");
  351.     TextDrawBackgroundColor(Out7[playerid], 255);
  352.     TextDrawFont(Out7[playerid], 1);
  353.     TextDrawLetterSize(Out7[playerid], 0.500000, -0.199999);
  354.     TextDrawColor(Out7[playerid], -1);
  355.     TextDrawSetOutline(Out7[playerid], 0);
  356.     TextDrawSetProportional(Out7[playerid], 1);
  357.     TextDrawSetShadow(Out7[playerid], 1);
  358.     TextDrawUseBox(Out7[playerid], 1);
  359.     TextDrawBoxColor(Out7[playerid], 255);
  360.     TextDrawTextSize(Out7[playerid], 489.000000, 0.000000);
  361.  
  362.     Out8[playerid] = TextDrawCreate(653.000000, 447.000000, "_");
  363.     TextDrawBackgroundColor(Out8[playerid], 255);
  364.     TextDrawFont(Out8[playerid], 1);
  365.     TextDrawLetterSize(Out8[playerid], 0.500000, -0.199999);
  366.     TextDrawColor(Out8[playerid], -1);
  367.     TextDrawSetOutline(Out8[playerid], 0);
  368.     TextDrawSetProportional(Out8[playerid], 1);
  369.     TextDrawSetShadow(Out8[playerid], 1);
  370.     TextDrawUseBox(Out8[playerid], 1);
  371.     TextDrawBoxColor(Out8[playerid], 255);
  372.     TextDrawTextSize(Out8[playerid], 489.000000, 0.000000);
  373.  
  374.     Out9[playerid] = TextDrawCreate(644.000000, 447.000000, "_");
  375.     TextDrawBackgroundColor(Out9[playerid], 255);
  376.     TextDrawFont(Out9[playerid], 1);
  377.     TextDrawLetterSize(Out9[playerid], 0.500000, -7.999998);
  378.     TextDrawColor(Out9[playerid], -1);
  379.     TextDrawSetOutline(Out9[playerid], 0);
  380.     TextDrawSetProportional(Out9[playerid], 1);
  381.     TextDrawSetShadow(Out9[playerid], 1);
  382.     TextDrawUseBox(Out9[playerid], 1);
  383.     TextDrawBoxColor(Out9[playerid], 255);
  384.     TextDrawTextSize(Out9[playerid], 632.000000, 1.000000);
  385.     }
  386.     return 1;
  387. }
  388. public OnFilterScriptExit()
  389. {
  390.     for(new i = 0;i < MAX_PLAYERS; i++)
  391.     {
  392.         TextDrawHideForPlayer(i,Name[i]);
  393.         TextDrawHideForPlayer(i,KMH[i]);
  394.         TextDrawHideForPlayer(i,Type[i]);
  395.         TextDrawHideForPlayer(i,CarH[i]);
  396.         TextDrawHideForPlayer(i,Out1[i]);
  397.         TextDrawHideForPlayer(i,Out2[i]);
  398.         TextDrawHideForPlayer(i,Out3[i]);
  399.         TextDrawHideForPlayer(i,Out4[i]);
  400.         TextDrawHideForPlayer(i,Out5[i]);
  401.         TextDrawHideForPlayer(i,Out6[i]);
  402.         TextDrawHideForPlayer(i,Out7[i]);
  403.         TextDrawHideForPlayer(i,Out8[i]);
  404.         TextDrawHideForPlayer(i,Out9[i]);
  405.     }
  406.     return 1;
  407. }
  408.  
  409. public CheckSpeed()
  410. {
  411.     for(new i=0;i<MAX_PLAYERS;i++)
  412.     {
  413.         if (IsPlayerInAnyVehicle(i) && IsPlayerConnected(i))
  414.         {
  415.             new Float:h,str[167],str3[167],str4[167],v,sp;
  416.             v = GetPlayerVehicleID(i);
  417.             GetVehicleHealth(v,h);
  418.             sp = GetPlayerSpeed(i);
  419.             format(str,sizeof(str),"KM/H: %d",sp);
  420.             if(IsInAnyBike(v))
  421.             {
  422.                 TextDrawSetString(Type[i],"Type: Bike");
  423.             }
  424.             else if(IsInAirplane(v))
  425.             {
  426.                 TextDrawSetString(Type[i],"Type: Airplane");
  427.             }
  428.             else if(IsInHeli(v))
  429.             {
  430.                 TextDrawSetString(Type[i],"Type: Helicopter");
  431.             }
  432.             else if(IsInBoat(v))
  433.             {
  434.                 TextDrawSetString(Type[i],"Type: Boat");
  435.             }
  436.             else
  437.             {
  438.                 TextDrawSetString(Type[i],"Type: Car");
  439.             }
  440.             format(str3,sizeof(str3),"Health: %.0f",h);
  441.             format(str4,167,"Name: %s",CarsName[GetVehicleModel(v)-400]);
  442.             TextDrawSetString(KMH[i],str);
  443.             TextDrawSetString(CarH[i],str3);
  444.             TextDrawSetString(Name[i],str4);
  445.         }
  446.     }
  447.     return 1;
  448. }
  449. public OnPlayerStateChange(playerid, newstate, oldstate)
  450. {
  451.     if (newstate == PLAYER_STATE_DRIVER)
  452.     {
  453.  
  454.         TextDrawShowForPlayer(playerid,KMH[playerid]);
  455.         TextDrawShowForPlayer(playerid,Name[playerid]);
  456.         TextDrawShowForPlayer(playerid,Type[playerid]);
  457.         TextDrawShowForPlayer(playerid,CarH[playerid]);
  458.         TextDrawShowForPlayer(playerid,Out1[playerid]);
  459.         TextDrawShowForPlayer(playerid,Out2[playerid]);
  460.         TextDrawShowForPlayer(playerid,Out3[playerid]);
  461.         TextDrawShowForPlayer(playerid,Out4[playerid]);
  462.         TextDrawShowForPlayer(playerid,Out5[playerid]);
  463.         TextDrawShowForPlayer(playerid,Out6[playerid]);
  464.         TextDrawShowForPlayer(playerid,Out7[playerid]);
  465.         TextDrawShowForPlayer(playerid,Out8[playerid]);
  466.         TextDrawShowForPlayer(playerid,Out9[playerid]);
  467.     }
  468.     else if (newstate == PLAYER_STATE_ONFOOT)
  469.     {
  470.         TextDrawHideForPlayer(playerid,KMH[playerid]);
  471.         TextDrawHideForPlayer(playerid,Name[playerid]);
  472.         TextDrawHideForPlayer(playerid,Type[playerid]);
  473.         TextDrawHideForPlayer(playerid,CarH[playerid]);
  474.         TextDrawHideForPlayer(playerid,Out1[playerid]);
  475.         TextDrawHideForPlayer(playerid,Out2[playerid]);
  476.         TextDrawHideForPlayer(playerid,Out3[playerid]);
  477.         TextDrawHideForPlayer(playerid,Out4[playerid]);
  478.         TextDrawHideForPlayer(playerid,Out5[playerid]);
  479.         TextDrawHideForPlayer(playerid,Out6[playerid]);
  480.         TextDrawHideForPlayer(playerid,Out7[playerid]);
  481.         TextDrawHideForPlayer(playerid,Out8[playerid]);
  482.         TextDrawHideForPlayer(playerid,Out9[playerid]);
  483.     }
  484.     return 1;
  485. }
  486. stock GetPlayerSpeed(playerid)
  487. {
  488.     new Float:ST[4];
  489.     if(IsPlayerInAnyVehicle(playerid))
  490.     GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
  491.     else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
  492.     ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
  493.     return floatround(ST[3]);
  494. }
  495. stock IsInAnyBike(bikeid)
  496. {
  497.     new Bikes[] = { 509,510,481,581, 462, 521, 463, 522, 461, 448, 471, 468, 586 };
  498.     for(new i = 0; i < sizeof(Bikes); i++)
  499.     {
  500.         if(GetVehicleModel(bikeid) == Bikes[i]) return 1;
  501.     }
  502.     return 0;
  503. }
  504. stock IsInAirplane(airplaneid)
  505. {
  506.     new Airplanes[] = { 460,476,511,512,513,519,520,553,577,563,592,593 };
  507.     for(new i = 0; i < sizeof(Airplanes); i++)
  508.     {
  509.         if(GetVehicleModel(airplaneid) == Airplanes[i]) return 1;
  510.     }
  511.     return 0;
  512. }
  513. stock IsInHeli(heliid)
  514. {
  515.     new Helis[] = { 417,425,447,469,487,488,497,548,563 };
  516.     for(new i = 0; i < sizeof(Helis); i++)
  517.     {
  518.         if(GetVehicleModel(heliid) == Helis[i]) return 1;
  519.     }
  520.     return 0;
  521. }
  522. stock IsInBoat(boatid)
  523. {
  524.     new Boats[] = { 472, 473, 493, 495, 484, 430, 454, 453, 452, 446 };
  525.     for(new i = 0; i < sizeof(Boats); i++)
  526.     {
  527.     if(GetVehicleModel(boatid) == Boats[i]) return 1;
  528.     }
  529.     return 0;
  530. }
Advertisement
Add Comment
Please, Sign In to add comment