Advertisement
Guest User

Untitled

a guest
Aug 28th, 2010
2,550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.23 KB | None | 0 0
  1. /*
  2.             ||----------[Speedo^&Radar^]----------||
  3.             //------------------------------------\\
  4.             //--------   By BumbiS*   ------------\\
  5.             ||------------------------------------||
  6. */
  7.  
  8. #include <a_samp>
  9. #include <float>
  10.  
  11. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  12. #define COLOR_YELLOW 0xDABB3EAA
  13. #define COLOR_WHITE 0xFFFFFFAA
  14. #define COLOR_GREEN 0x9EC73DAA
  15. #define COLOR_PURPLE 0xB370FCFF
  16. #define COLOR_GREY 0xAFAFAFAA
  17. ////////////////////////////////////////////////////////////////////
  18. new Speed[MAX_PLAYERS];
  19. new Text:Box[MAX_PLAYERS];
  20. new Text:Title[MAX_PLAYERS];
  21. new Text:Yellow1[MAX_PLAYERS];
  22. new Text:Vehicle[MAX_PLAYERS];
  23. new Text:Health[MAX_PLAYERS];
  24. new Text:Speedd[MAX_PLAYERS];
  25. new Text:Yellow2[MAX_PLAYERS];
  26. new SpeedoON[MAX_PLAYERS];
  27. new BigEar[MAX_PLAYERS];
  28. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  29. forward ProxDetectorS(Float:radi, playerid, targetid);
  30.  
  31. new VehicleNames[][] =
  32. {
  33.     "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  34.     "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  35.     "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  36.     "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  37.     "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  38.     "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  39.     "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  40.     "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  41.     "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  42.     "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  43.     "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  44.     "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  45.     "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  46.     "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  47.     "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  48.     "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  49.     "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  50.     "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  51.     "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  52.     "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  53.     "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  54.     "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  55.     "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  56.     "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
  57.     "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  58.     "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  59.     "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  60.     "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  61.     "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  62.     "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  63.     "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
  64.     "Tiller", "Utility Trailer"
  65. };
  66.  
  67. forward Speedo();
  68. //----------------------------------------------------------------------------------------
  69.  
  70. public OnFilterScriptInit()
  71. {
  72.     print("\n--------------------------------------");
  73.     print(" Speedo&Radar Filterscript by BumbiS* started!");
  74.     print("--------------------------------------\n");
  75.     SetTimer("Speedo", 180, 1);
  76.     for(new i=0; i<MAX_PLAYERS; i++)
  77.     {
  78.         Box[i] = TextDrawCreate(645.000000, 358.000000, "_");
  79.         TextDrawBackgroundColor(Box[i], 255);
  80.         TextDrawFont(Box[i], 1);
  81.         TextDrawLetterSize(Box[i], 0.500000, 13.800002);
  82.         TextDrawColor(Box[i], -1);
  83.         TextDrawSetOutline(Box[i], 1);
  84.         TextDrawSetProportional(Box[i], 1);
  85.         TextDrawUseBox(Box[i], 1);
  86.         TextDrawBoxColor(Box[i], 150);
  87.         TextDrawTextSize(Box[i], 504.000000, 64.000000);
  88.  
  89.         Title[i] = TextDrawCreate(537.000000, 356.000000, "Speedometer");
  90.         TextDrawBackgroundColor(Title[i], 255);
  91.         TextDrawFont(Title[i], 1);
  92.         TextDrawLetterSize(Title[i], 0.370000, 1.399999);
  93.         TextDrawColor(Title[i], -1);
  94.         TextDrawSetOutline(Title[i], 1);
  95.         TextDrawSetProportional(Title[i], 1);
  96.  
  97.         Yellow1[i] = TextDrawCreate(698.000000, 370.000000, "_");
  98.         TextDrawBackgroundColor(Yellow1[i], 255);
  99.         TextDrawFont(Yellow1[i], 1);
  100.         TextDrawLetterSize(Yellow1[i], 0.899999, 0.099999);
  101.         TextDrawColor(Yellow1[i], -1);
  102.         TextDrawSetOutline(Yellow1[i], 0);
  103.         TextDrawSetProportional(Yellow1[i], 1);
  104.         TextDrawSetShadow(Yellow1[i], 1);
  105.         TextDrawUseBox(Yellow1[i], 1);
  106.         TextDrawBoxColor(Yellow1[i], -65281);
  107.         TextDrawTextSize(Yellow1[i], 504.000000, -1.000000);
  108.  
  109.         Vehicle[i] = TextDrawCreate(507.000000, 377.000000, " ");
  110.         TextDrawBackgroundColor(Vehicle[i], 255);
  111.         TextDrawFont(Vehicle[i], 1);
  112.         TextDrawLetterSize(Vehicle[i], 0.329998, 1.200000);
  113.         TextDrawColor(Vehicle[i], -1);
  114.         TextDrawSetOutline(Vehicle[i], 1);
  115.         TextDrawSetProportional(Vehicle[i], 1);
  116.  
  117.         Health[i] = TextDrawCreate(507.000000, 392.000000, " ");
  118.         TextDrawBackgroundColor(Health[i], 255);
  119.         TextDrawFont(Health[i], 1);
  120.         TextDrawLetterSize(Health[i], 0.330000, 1.299999);
  121.         TextDrawColor(Health[i], -1);
  122.         TextDrawSetOutline(Health[i], 1);
  123.         TextDrawSetProportional(Health[i], 1);
  124.  
  125.         Speedd[i] = TextDrawCreate(506.000000, 409.000000, " ");
  126.         TextDrawBackgroundColor(Speedd[i], 255);
  127.         TextDrawFont(Speedd[i], 1);
  128.         TextDrawLetterSize(Speedd[i], 0.360000, 1.200000);
  129.         TextDrawColor(Speedd[i], -1);
  130.         TextDrawSetOutline(Speedd[i], 1);
  131.         TextDrawSetProportional(Speedd[i], 1);
  132.  
  133.         Yellow2[i] = TextDrawCreate(628.000000, 358.000000, "_");
  134.         TextDrawBackgroundColor(Yellow2[i], 255);
  135.         TextDrawFont(Yellow2[i], 1);
  136.         TextDrawLetterSize(Yellow2[i], 0.500000, 10.000000);
  137.         TextDrawColor(Yellow2[i], -1);
  138.         TextDrawSetOutline(Yellow2[i], 0);
  139.         TextDrawSetProportional(Yellow2[i], 1);
  140.         TextDrawSetShadow(Yellow2[i], 1);
  141.         TextDrawUseBox(Yellow2[i], 1);
  142.         TextDrawBoxColor(Yellow2[i], -65281);
  143.         TextDrawTextSize(Yellow2[i], 619.000000, 12.000000);
  144.     }
  145.     return 1;
  146. }
  147.  
  148. public OnFilterScriptExit()
  149. {
  150.     return 1;
  151. }
  152. public OnPlayerConnect(playerid)
  153. {
  154.     BigEar[playerid] = 0;
  155.     return 1;
  156. }
  157. dcmd_radar(playerid, params[])
  158. {
  159.     #pragma unused params
  160.     if(IsPlayerConnected(playerid))
  161.     {
  162.         new sendername[MAX_PLAYER_NAME];
  163.         new giveplayer[MAX_PLAYER_NAME];
  164.         new string[128];
  165.         if(GetPlayerSkin(playerid) == 280 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288 || GetPlayerSkin(playerid) == 284)
  166.         {
  167.             GetPlayerName(playerid, sendername, sizeof(sendername));
  168.             sendername[strfind(sendername,"_")] = ' ';
  169.             format(string, sizeof(string), "* %s takes out a speed radar and shoots it out.", sendername);
  170.             ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  171.             SendClientMessage(playerid, COLOR_GREEN, "Nearest vehicles speed:");
  172.             for(new i=0; i < MAX_PLAYERS; i++)
  173.             {
  174.                 if(IsPlayerConnected(i) && i!=playerid)
  175.                 {
  176.                     if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
  177.                     {
  178.                         if (ProxDetectorS(30.0, playerid, i) && Speed[i] > 15)
  179.                         {
  180.                             GetPlayerName(i, giveplayer, sizeof(giveplayer));
  181.                             giveplayer[strfind(giveplayer,"_")] = ' ';
  182.                             format(string, sizeof(string), "Vehicle:%s Name:%s speed ~%dkm/h", VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400],giveplayer,Speed[i]);
  183.                             SendClientMessage(playerid, COLOR_YELLOW, string);
  184.                         }
  185.                     }
  186.                 }
  187.             }
  188.         }
  189.         else
  190.         {
  191.             SendClientMessage(playerid, COLOR_GREY, "* You are not a cop!");
  192.             return 1;
  193.         }
  194.         return 1;
  195.     }
  196.     return 1;
  197. }
  198. public OnPlayerCommandText(playerid, cmdtext[])
  199. {
  200.     dcmd(radar,5,cmdtext);
  201.     return 0;
  202. }
  203.  
  204. public OnPlayerStateChange(playerid, newstate, oldstate)
  205. {
  206.     return 1;
  207. }
  208.  
  209. public Speedo()
  210. {
  211.     new Float:Speedo_HP;
  212.  
  213.     for(new i=0;i<MAX_PLAYERS;i++)
  214.     {
  215.         if(IsPlayerInAnyVehicle(i))
  216.         {
  217.             new vehicle = GetPlayerVehicleID(i);
  218.             GetVehicleHealth(vehicle, Speedo_HP);
  219.             new Float:X, Float:Y, Float:Z, Float:Sp;
  220.             GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
  221.             Sp = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0);
  222.             Speed[i]=floatround(floatdiv(Sp, 0.75), floatround_floor);
  223.  
  224.             new str1[128],str2[128],str4[128];
  225.             if(SpeedoON[i] == 0)
  226.             {
  227.                 TextDrawShowForPlayer(i, Box[i]); TextDrawShowForPlayer(i, Title[i]); TextDrawShowForPlayer(i, Yellow1[i]); TextDrawShowForPlayer(i, Yellow2[i]);
  228.                 TextDrawShowForPlayer(i, Speedd[i]); TextDrawShowForPlayer(i, Vehicle[i]); TextDrawShowForPlayer(i, Health[i]);
  229.                 SpeedoON[i] = 1;
  230.             }
  231.             format(str1,sizeof(str1),"Vehicle: %s",VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]);
  232.             TextDrawSetString(Vehicle[i], str1);
  233.             format(str2,sizeof(str2),"Speed: %dmp/h",Speed[i]);
  234.             TextDrawSetString(Speedd[i], str2);
  235.             format(str4,sizeof(str4),"Health: %.2f", Speedo_HP);
  236.             TextDrawSetString(Health[i], str4);
  237.         }
  238.     }
  239.     for(new i=0;i<MAX_PLAYERS;i++)
  240.     {
  241.         if(!IsPlayerInAnyVehicle(i))
  242.         {
  243.             TextDrawHideForPlayer(i, Box[i]); TextDrawHideForPlayer(i, Title[i]); TextDrawHideForPlayer(i, Yellow1[i]); TextDrawHideForPlayer(i, Health[i]);
  244.             TextDrawHideForPlayer(i, Vehicle[i]); TextDrawHideForPlayer(i, Yellow2[i]); TextDrawHideForPlayer(i, Speedd[i]);
  245.             SpeedoON[i] = 0;
  246.         }
  247.     }
  248. }
  249. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  250. {
  251.     if(IsPlayerConnected(playerid))
  252.     {
  253.         new Float:posx, Float:posy, Float:posz;
  254.         new Float:oldposx, Float:oldposy, Float:oldposz;
  255.         new Float:tempposx, Float:tempposy, Float:tempposz;
  256.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  257.         for(new i=0;i<MAX_PLAYERS;i++)
  258.         {
  259.             if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  260.             {
  261.                 if(!BigEar[i])
  262.                 {
  263.                     GetPlayerPos(i, posx, posy, posz);
  264.                     tempposx = (oldposx -posx);
  265.                     tempposy = (oldposy -posy);
  266.                     tempposz = (oldposz -posz);
  267.                     if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  268.                     {
  269.                         SendClientMessage(i, col1, string);
  270.                     }
  271.                     else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  272.                     {
  273.                         SendClientMessage(i, col2, string);
  274.                     }
  275.                     else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  276.                     {
  277.                         SendClientMessage(i, col3, string);
  278.                     }
  279.                     else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  280.                     {
  281.                         SendClientMessage(i, col4, string);
  282.                     }
  283.                     else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  284.                     {
  285.                         SendClientMessage(i, col5, string);
  286.                     }
  287.                 }
  288.                 else
  289.                 {
  290.                     SendClientMessage(i, col1, string);
  291.                 }
  292.             }
  293.         }
  294.     }//not connected
  295.     return 1;
  296. }
  297.  
  298. public ProxDetectorS(Float:radi, playerid, targetid)
  299. {
  300.     if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
  301.     {
  302.         new Float:posx, Float:posy, Float:posz;
  303.         new Float:oldposx, Float:oldposy, Float:oldposz;
  304.         new Float:tempposx, Float:tempposy, Float:tempposz;
  305.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  306.         GetPlayerPos(targetid, posx, posy, posz);
  307.         tempposx = (oldposx -posx);
  308.         tempposy = (oldposy -posy);
  309.         tempposz = (oldposz -posz);
  310.         if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  311.         {
  312.             return 1;
  313.         }
  314.     }
  315.     return 0;
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement