Advertisement
ErikSon_

Tachosystem [S3] by ErikSon

Aug 3rd, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.08 KB | None | 0 0
  1. /*                              Tachosystem [S3] by ErikSon                             */
  2.  
  3. #include <a_samp>
  4.  
  5. /*      Settings        */
  6. #undef MAX_PLAYERS
  7. #define MAX_PLAYERS     5   //Server-Slotanzahl
  8. /*      Settings        */
  9.  
  10. #define formatEx(%0,%1,%2)          format(%0,sizeof(%0),%1,%2)
  11.  
  12. enum T_EC{
  13.     Text:Name,
  14.     Text:punkt[10],
  15.     Text:Speed,
  16.     Text:kmh,
  17.     Text:TachoBox,
  18.     Text:Zustand,
  19.     Shown
  20. }
  21. new Tacho[MAX_PLAYERS][T_EC];
  22.  
  23. new VehName[][] ={
  24.         "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  25.         "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  26.         "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  27.         "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  28.         "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  29.         "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  30.         "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  31.         "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  32.         "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  33.         "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  34.         "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  35.         "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  36.         "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  37.         "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  38.         "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  39.         "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  40.         "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  41.         "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  42.         "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  43.         "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  44.         "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  45.         "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  46.         "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  47.         "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum",
  48.         "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  49.         "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  50.         "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  51.         "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  52.         "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  53.         "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  54.         "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
  55.         "Tiller", "Utility Trailer"
  56. };
  57.  
  58.  
  59. public OnFilterScriptInit(){
  60.     print("\n--------------------------------------");
  61.     print(" Tachosystem [S3] by ErikSon");
  62.     print("--------------------------------------\n");
  63.     for(new i = 0; i<MAX_PLAYERS; i++){
  64.         Tacho[i][Speed] = TextDrawCreate(495.000000, 342.000000, "-");
  65.         TextDrawBackgroundColor(Tacho[i][Speed], 255);
  66.         TextDrawFont(Tacho[i][Speed], 1);
  67.         TextDrawLetterSize(Tacho[i][Speed], 0.699999, 4.000000);
  68.         TextDrawColor(Tacho[i][Speed], -1);
  69.         TextDrawSetOutline(Tacho[i][Speed], 0);
  70.         TextDrawSetProportional(Tacho[i][Speed], 1);
  71.         TextDrawSetShadow(Tacho[i][Speed], 1);
  72.         TextDrawSetSelectable(Tacho[i][Speed], 0);
  73.  
  74.         Tacho[i][kmh] = TextDrawCreate(548.000000, 349.000000, "km/h");
  75.         TextDrawBackgroundColor(Tacho[i][kmh], 255);
  76.         TextDrawFont(Tacho[i][kmh], 1);
  77.         TextDrawLetterSize(Tacho[i][kmh], 0.500000, 1.000000);
  78.         TextDrawColor(Tacho[i][kmh], -1);
  79.         TextDrawSetOutline(Tacho[i][kmh], 0);
  80.         TextDrawSetProportional(Tacho[i][kmh], 1);
  81.         TextDrawSetShadow(Tacho[i][kmh], 1);
  82.         TextDrawSetSelectable(Tacho[i][kmh], 0);
  83.  
  84.         Tacho[i][punkt][0] = TextDrawCreate(495.000000, 369.000000, ".");
  85.         TextDrawBackgroundColor(Tacho[i][punkt][0], 255);
  86.         TextDrawFont(Tacho[i][punkt][0], 1);
  87.         TextDrawLetterSize(Tacho[i][punkt][0], 0.800000, 4.000000);
  88.         TextDrawColor(Tacho[i][punkt][0], 16711935);
  89.         TextDrawSetOutline(Tacho[i][punkt][0], 0);
  90.         TextDrawSetProportional(Tacho[i][punkt][0], 1);
  91.         TextDrawSetShadow(Tacho[i][punkt][0], 1);
  92.         TextDrawSetSelectable(Tacho[i][punkt][0], 0);
  93.  
  94.         Tacho[i][punkt][1] = TextDrawCreate(505.000000, 369.000000, ".");
  95.         TextDrawBackgroundColor(Tacho[i][punkt][1], 255);
  96.         TextDrawFont(Tacho[i][punkt][1], 1);
  97.         TextDrawLetterSize(Tacho[i][punkt][1], 0.800000, 4.000000);
  98.         TextDrawColor(Tacho[i][punkt][1], 16711935);
  99.         TextDrawSetOutline(Tacho[i][punkt][1], 0);
  100.         TextDrawSetProportional(Tacho[i][punkt][1], 1);
  101.         TextDrawSetShadow(Tacho[i][punkt][1], 1);
  102.         TextDrawSetSelectable(Tacho[i][punkt][1], 0);
  103.  
  104.         Tacho[i][punkt][2] = TextDrawCreate(515.000000, 369.000000, ".");
  105.         TextDrawBackgroundColor(Tacho[i][punkt][2], 255);
  106.         TextDrawFont(Tacho[i][punkt][2], 1);
  107.         TextDrawLetterSize(Tacho[i][punkt][2], 0.800000, 4.000000);
  108.         TextDrawColor(Tacho[i][punkt][2], 16711935);
  109.         TextDrawSetOutline(Tacho[i][punkt][2], 0);
  110.         TextDrawSetProportional(Tacho[i][punkt][2], 1);
  111.         TextDrawSetShadow(Tacho[i][punkt][2], 1);
  112.         TextDrawSetSelectable(Tacho[i][punkt][2], 0);
  113.  
  114.         Tacho[i][punkt][3] = TextDrawCreate(525.000000, 369.000000, ".");
  115.         TextDrawBackgroundColor(Tacho[i][punkt][3], 255);
  116.         TextDrawFont(Tacho[i][punkt][3], 1);
  117.         TextDrawLetterSize(Tacho[i][punkt][3], 0.800000, 4.000000);
  118.         TextDrawColor(Tacho[i][punkt][3], 16711935);
  119.         TextDrawSetOutline(Tacho[i][punkt][3], 0);
  120.         TextDrawSetProportional(Tacho[i][punkt][3], 1);
  121.         TextDrawSetShadow(Tacho[i][punkt][3], 1);
  122.         TextDrawSetSelectable(Tacho[i][punkt][3], 0);
  123.  
  124.         Tacho[i][punkt][4] = TextDrawCreate(535.000000, 369.000000, ".");
  125.         TextDrawBackgroundColor(Tacho[i][punkt][4], 255);
  126.         TextDrawFont(Tacho[i][punkt][4], 1);
  127.         TextDrawLetterSize(Tacho[i][punkt][4], 0.800000, 4.000000);
  128.         TextDrawColor(Tacho[i][punkt][4], 16711935);
  129.         TextDrawSetOutline(Tacho[i][punkt][4], 0);
  130.         TextDrawSetProportional(Tacho[i][punkt][4], 1);
  131.         TextDrawSetShadow(Tacho[i][punkt][4], 1);
  132.         TextDrawSetSelectable(Tacho[i][punkt][4], 0);
  133.  
  134.         Tacho[i][punkt][5] = TextDrawCreate(545.000000, 369.000000, ".");
  135.         TextDrawBackgroundColor(Tacho[i][punkt][5], 255);
  136.         TextDrawFont(Tacho[i][punkt][5], 1);
  137.         TextDrawLetterSize(Tacho[i][punkt][5], 0.800000, 4.000000);
  138.         TextDrawColor(Tacho[i][punkt][5], 16711935);
  139.         TextDrawSetOutline(Tacho[i][punkt][5], 0);
  140.         TextDrawSetProportional(Tacho[i][punkt][5], 1);
  141.         TextDrawSetShadow(Tacho[i][punkt][5], 1);
  142.         TextDrawSetSelectable(Tacho[i][punkt][5], 0);
  143.  
  144.         Tacho[i][punkt][6] = TextDrawCreate(555.000000, 369.000000, ".");
  145.         TextDrawBackgroundColor(Tacho[i][punkt][6], 255);
  146.         TextDrawFont(Tacho[i][punkt][6], 1);
  147.         TextDrawLetterSize(Tacho[i][punkt][6], 0.800000, 4.000000);
  148.         TextDrawColor(Tacho[i][punkt][6], 16711935);
  149.         TextDrawSetOutline(Tacho[i][punkt][6], 0);
  150.         TextDrawSetProportional(Tacho[i][punkt][6], 1);
  151.         TextDrawSetShadow(Tacho[i][punkt][6], 1);
  152.         TextDrawSetSelectable(Tacho[i][punkt][6], 0);
  153.  
  154.         Tacho[i][punkt][7] = TextDrawCreate(565.000000, 369.000000, ".");
  155.         TextDrawBackgroundColor(Tacho[i][punkt][7], 255);
  156.         TextDrawFont(Tacho[i][punkt][7], 1);
  157.         TextDrawLetterSize(Tacho[i][punkt][7], 0.800000, 4.000000);
  158.         TextDrawColor(Tacho[i][punkt][7], 16711935);
  159.         TextDrawSetOutline(Tacho[i][punkt][7], 0);
  160.         TextDrawSetProportional(Tacho[i][punkt][7], 1);
  161.         TextDrawSetShadow(Tacho[i][punkt][7], 1);
  162.         TextDrawSetSelectable(Tacho[i][punkt][7], 0);
  163.  
  164.         Tacho[i][punkt][8] = TextDrawCreate(575.000000, 369.000000, ".");
  165.         TextDrawBackgroundColor(Tacho[i][punkt][8], 255);
  166.         TextDrawFont(Tacho[i][punkt][8], 1);
  167.         TextDrawLetterSize(Tacho[i][punkt][8], 0.800000, 4.000000);
  168.         TextDrawColor(Tacho[i][punkt][8], 16711935);
  169.         TextDrawSetOutline(Tacho[i][punkt][8], 0);
  170.         TextDrawSetProportional(Tacho[i][punkt][8], 1);
  171.         TextDrawSetShadow(Tacho[i][punkt][8], 1);
  172.         TextDrawSetSelectable(Tacho[i][punkt][8], 0);
  173.  
  174.         Tacho[i][punkt][9] = TextDrawCreate(585.000000, 369.000000, ".");
  175.         TextDrawBackgroundColor(Tacho[i][punkt][9], 255);
  176.         TextDrawFont(Tacho[i][punkt][9], 1);
  177.         TextDrawLetterSize(Tacho[i][punkt][9], 0.800000, 4.000000);
  178.         TextDrawColor(Tacho[i][punkt][9], 16711935);
  179.         TextDrawSetOutline(Tacho[i][punkt][9], 0);
  180.         TextDrawSetProportional(Tacho[i][punkt][9], 1);
  181.         TextDrawSetShadow(Tacho[i][punkt][9], 1);
  182.         TextDrawSetSelectable(Tacho[i][punkt][9], 0);
  183.  
  184.         Tacho[i][Zustand] = TextDrawCreate(517.000000, 379.000000, "Zustand");
  185.         TextDrawBackgroundColor(Tacho[i][Zustand], 255);
  186.         TextDrawFont(Tacho[i][Zustand], 1);
  187.         TextDrawLetterSize(Tacho[i][Zustand], 0.469999, 1.100000);
  188.         TextDrawColor(Tacho[i][Zustand], 0xFF000F88);
  189.         TextDrawSetOutline(Tacho[i][Zustand], 0);
  190.         TextDrawSetProportional(Tacho[i][Zustand], 1);
  191.         TextDrawSetShadow(Tacho[i][Zustand], 1);
  192.         TextDrawSetSelectable(Tacho[i][Zustand], 0);
  193.  
  194.         Tacho[i][Name] = TextDrawCreate(510.000000, 324.000000, "-");
  195.         TextDrawBackgroundColor(Tacho[i][Name], 255);
  196.         TextDrawFont(Tacho[i][Name], 1);
  197.         TextDrawLetterSize(Tacho[i][Name], 0.500000, 2.000000);
  198.         TextDrawColor(Tacho[i][Name], -16776961);
  199.         TextDrawSetOutline(Tacho[i][Name], 0);
  200.         TextDrawSetProportional(Tacho[i][Name], 1);
  201.         TextDrawSetShadow(Tacho[i][Name], 1);
  202.         TextDrawSetSelectable(Tacho[i][Name], 0);
  203.  
  204.         Tacho[i][TachoBox] = TextDrawCreate(495.000000, 321.000000, "~n~~n~");
  205.         TextDrawBackgroundColor(Tacho[i][TachoBox], 255);
  206.         TextDrawFont(Tacho[i][TachoBox], 1);
  207.         TextDrawLetterSize(Tacho[i][TachoBox], 6.809998, 5.000000);
  208.         TextDrawColor(Tacho[i][TachoBox], 255);
  209.         TextDrawSetOutline(Tacho[i][TachoBox], 0);
  210.         TextDrawSetProportional(Tacho[i][TachoBox], 1);
  211.         TextDrawSetShadow(Tacho[i][TachoBox], 1);
  212.         TextDrawUseBox(Tacho[i][TachoBox], 1);
  213.         TextDrawBoxColor(Tacho[i][TachoBox], 0x00000088);
  214.         TextDrawTextSize(Tacho[i][TachoBox], 596.000000, 70.000000);
  215.         TextDrawSetSelectable(Tacho[i][TachoBox], 0);
  216.     }
  217.     return SetTimer("TachoUpdate",444,true);
  218. }
  219.  
  220. public OnFilterScriptExit(){
  221.     for(new i = 0; i<MAX_PLAYERS; i++){
  222.         TextDrawHideForPlayer(i,Tacho[i][Name]);
  223.         TextDrawHideForPlayer(i,Tacho[i][Zustand]);
  224.         TextDrawHideForPlayer(i,Tacho[i][Speed]);
  225.         TextDrawHideForPlayer(i, Tacho[i][TachoBox]);
  226.         TextDrawHideForPlayer(i, Tacho[i][kmh]);
  227.         for(new _i = 0; _i<10; _i++)TextDrawHideForPlayer(i, Tacho[i][punkt][_i]);
  228.            
  229.         TextDrawDestroy(Tacho[i][Name]);
  230.         TextDrawDestroy(Tacho[i][Zustand]);
  231.         TextDrawDestroy(Tacho[i][Speed]);
  232.         TextDrawDestroy(Tacho[i][TachoBox]);
  233.         TextDrawDestroy(Tacho[i][kmh]);
  234.         for(new _i = 0; _i<10; _i++)TextDrawDestroy(Tacho[i][punkt][_i]);
  235.     }
  236.     return 1;
  237. }
  238.  
  239. public OnPlayerConnect(playerid){
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerDisconnect(playerid, reason){
  244.     if(IsPlayerInAnyVehicle(playerid)){
  245.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  246.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  247.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  248.         TextDrawHideForPlayer(playerid, Tacho[playerid][TachoBox]);
  249.         TextDrawHideForPlayer(playerid, Tacho[playerid][kmh]);
  250.         for(new i = 0; i<10; i++)TextDrawHideForPlayer(playerid, Tacho[playerid][punkt][i]);
  251.     }
  252.     return 1;
  253. }
  254.  
  255. public OnPlayerStateChange(playerid, newstate, oldstate){
  256.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER){
  257.         TextDrawShowForPlayer(playerid, Tacho[playerid][TachoBox]);
  258.         TextDrawShowForPlayer(playerid, Tacho[playerid][Name]);
  259.         TextDrawShowForPlayer(playerid, Tacho[playerid][Zustand]);
  260.         TextDrawShowForPlayer(playerid, Tacho[playerid][Speed]);
  261.         TextDrawShowForPlayer(playerid, Tacho[playerid][kmh]);
  262.         for(new i = 0; i<10; i++)TextDrawShowForPlayer(playerid, Tacho[playerid][punkt][i]);
  263.     }
  264.     if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER){
  265.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  266.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  267.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  268.         TextDrawHideForPlayer(playerid, Tacho[playerid][TachoBox]);
  269.         TextDrawHideForPlayer(playerid, Tacho[playerid][kmh]);
  270.         for(new i = 0; i<10; i++)TextDrawHideForPlayer(playerid, Tacho[playerid][punkt][i]);
  271.     }
  272.     return 1;
  273. }
  274.  
  275. forward TachoUpdate();
  276. public TachoUpdate(){
  277.     for(new i = 0; i<MAX_PLAYERS; i++){
  278.         if(!IsPlayerConnected(i))continue;
  279.         if(!IsPlayerInAnyVehicle(i))continue;
  280.         new veh = GetPlayerVehicleID(i),str[64],Float:hp,speed = GetVehicleSpeed(veh);
  281.         if(speed < 100)formatEx(str,"~g~%d", speed);
  282.         else if(speed > 100 && speed < 160)formatEx(str,"~y~%d",speed);
  283.         else if(speed > 160)formatEx(str,"~r~%d",speed);
  284.         TextDrawSetString(Tacho[i][Speed],str);
  285.         GetVehicleHealth(veh, hp); hp = floatround(hp);
  286.         formatEx(str,"~p~%s", VehName[GetVehicleModel(veh)-400]), TextDrawSetString(Tacho[i][Name],str);
  287.         for(new x = 0; x<10; x++)TextDrawHideForPlayer(i,Tacho[i][punkt][x]);
  288.         if(hp>= 1000)for(new x = 0; x<10; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  289.         else if(hp >= 900 && hp < 1000)for(new x = 0; x<9; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  290.         else if(hp >= 800 && hp < 900) for(new x = 0; x<8; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  291.         else if(hp >= 700 && hp < 800) for(new x = 0; x<7; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  292.         else if(hp >= 600 && hp < 700)for(new x = 0; x<6; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  293.         else if(hp >= 500 && hp < 600)for(new x = 0; x<5; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  294.         else if(hp >= 400 && hp < 500)for(new x = 0; x<4; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  295.         else if(hp >= 300 && hp < 400)for(new x = 0; x<3; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  296.         else if(hp >= 200 && hp < 300)for(new x = 0; x<2; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  297.         else if(hp >= 100 && hp < 200)for(new x = 0; x<1; x++)TextDrawShowForPlayer(i,Tacho[i][punkt][x]);
  298.     }
  299.     return 1;
  300. }
  301.  
  302. stock GetVehicleSpeed(vehicleid){
  303.     new Float:xPos[3];
  304.     GetVehicleVelocity(vehicleid, xPos[0], xPos[1], xPos[2]);
  305.     return floatround(floatsqroot(xPos[0] * xPos[0] + xPos[1] * xPos[1] + xPos[2] * xPos[2]) * 100 * 1.61);
  306. }
  307.  
  308. stock IsNoTachoVeh(vehicleid)
  309. {
  310.     if(vehicleid == INVALID_VEHICLE_ID)return 0;
  311.     if(GetVehicleModel(vehicleid)==441||GetVehicleModel(vehicleid)==449||GetVehicleModel(vehicleid)==450||GetVehicleModel(vehicleid)==464||GetVehicleModel(vehicleid)==465||
  312.     GetVehicleModel(vehicleid)==481||GetVehicleModel(vehicleid)==501||GetVehicleModel(vehicleid)==509||GetVehicleModel(vehicleid)==510||GetVehicleModel(vehicleid)==537||
  313.     GetVehicleModel(vehicleid)==538||GetVehicleModel(vehicleid)==564||GetVehicleModel(vehicleid)==569||GetVehicleModel(vehicleid)==570||GetVehicleModel(vehicleid)==584||
  314.     GetVehicleModel(vehicleid)==590||GetVehicleModel(vehicleid)==591||GetVehicleModel(vehicleid)==594||GetVehicleModel(vehicleid)==606||GetVehicleModel(vehicleid)==607||
  315.     GetVehicleModel(vehicleid)==608||GetVehicleModel(vehicleid)==610||GetVehicleModel(vehicleid)==611)return 1;
  316.     return 0;
  317. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement