Advertisement
ErikSon_

Tachosystem [S4] by ErikSon

Aug 3rd, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.18 KB | None | 0 0
  1. /*                              Tachosystem [S4] by ErikSon                             */
  2.  
  3. #include <a_samp>
  4. #include <progress>
  5.  
  6. /*      Settings        */
  7. #undef MAX_PLAYERS
  8. #define MAX_PLAYERS     5   //Server-Slotanzahl
  9. /*      Settings        */
  10.  
  11. #define formatEx(%0,%1,%2)          format(%0,sizeof(%0),%1,%2)
  12.  
  13. enum T_EC{
  14.     Text:Name,
  15.     Text:Zustand,
  16.     Text:Speed,
  17.     Bar:ZustandBar
  18. }
  19. new Tacho[MAX_PLAYERS][T_EC];
  20.  
  21. new VehName[][] ={
  22.         "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  23.         "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  24.         "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  25.         "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  26.         "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  27.         "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  28.         "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  29.         "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  30.         "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  31.         "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  32.         "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  33.         "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  34.         "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  35.         "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  36.         "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  37.         "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  38.         "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  39.         "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  40.         "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  41.         "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  42.         "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  43.         "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  44.         "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  45.         "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum",
  46.         "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  47.         "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  48.         "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  49.         "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  50.         "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  51.         "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  52.         "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
  53.         "Tiller", "Utility Trailer"
  54. };
  55.  
  56.  
  57. public OnFilterScriptInit(){
  58.     print("\n--------------------------------------");
  59.     print(" Tachosystem [S4] by ErikSon");
  60.     print("--------------------------------------\n");
  61.     for(new i = 0; i<MAX_PLAYERS; i++){
  62.         Tacho[i][Speed] = TextDrawCreate(508.000000, 370.000000, "- km/h");
  63.         TextDrawBackgroundColor(Tacho[i][Speed], 255);
  64.         TextDrawFont(Tacho[i][Speed], 1);
  65.         TextDrawLetterSize(Tacho[i][Speed], 0.600000, 2.000000);
  66.         TextDrawColor(Tacho[i][Speed], -1);
  67.         TextDrawSetOutline(Tacho[i][Speed], 0);
  68.         TextDrawSetProportional(Tacho[i][Speed], 1);
  69.         TextDrawSetShadow(Tacho[i][Speed], 1);
  70.         TextDrawSetSelectable(Tacho[i][Speed], 0);
  71.  
  72.         Tacho[i][Name] = TextDrawCreate(507.000000, 392.000000, "-");
  73.         TextDrawBackgroundColor(Tacho[i][Name], 255);
  74.         TextDrawFont(Tacho[i][Name], 1);
  75.         TextDrawLetterSize(Tacho[i][Name], 0.500000, 1.000000);
  76.         TextDrawColor(Tacho[i][Name], -1);
  77.         TextDrawSetOutline(Tacho[i][Name], 0);
  78.         TextDrawSetProportional(Tacho[i][Name], 1);
  79.         TextDrawSetShadow(Tacho[i][Name], 1);
  80.         TextDrawSetSelectable(Tacho[i][Name], 0);
  81.        
  82.         Tacho[i][Zustand] = TextDrawCreate(520.000000, 408.000000, "Zustand: - HP");
  83.         TextDrawBackgroundColor(Tacho[i][Zustand], 255);
  84.         TextDrawFont(Tacho[i][Zustand], 1);
  85.         TextDrawLetterSize(Tacho[i][Zustand], 0.300000, 1.000000);
  86.         TextDrawColor(Tacho[i][Zustand], -1);
  87.         TextDrawSetOutline(Tacho[i][Zustand], 0);
  88.         TextDrawSetProportional(Tacho[i][Zustand], 1);
  89.         TextDrawSetShadow(Tacho[i][Zustand], 1);
  90.         TextDrawSetSelectable(Tacho[i][Zustand], 0);
  91.        
  92.         Tacho[i][ZustandBar] = CreateProgressBar(508.00, 408.00, 130.50, 11.19, 0xFFFFFFFF, 1000.0);
  93.     }
  94.     return SetTimer("TachoUpdate",444,true);
  95. }
  96.  
  97. public OnFilterScriptExit(){
  98.     for(new i = 0; i<MAX_PLAYERS; i++){
  99.         TextDrawHideForPlayer(i,Tacho[i][Name]);
  100.         TextDrawHideForPlayer(i,Tacho[i][Zustand]);
  101.         TextDrawHideForPlayer(i,Tacho[i][Speed]);
  102.         HideProgressBarForPlayer(i,Tacho[i][ZustandBar]);
  103.            
  104.         TextDrawDestroy(Tacho[i][Name]);
  105.         TextDrawDestroy(Tacho[i][Zustand]);
  106.         TextDrawDestroy(Tacho[i][Speed]);
  107.         DestroyProgressBar(Tacho[i][ZustandBar]);
  108.     }
  109.     return 1;
  110. }
  111.  
  112. public OnPlayerConnect(playerid){
  113.     return 1;
  114. }
  115.  
  116. public OnPlayerDisconnect(playerid, reason){
  117.     if(IsPlayerInAnyVehicle(playerid)){
  118.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  119.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  120.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  121.         HideProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
  122.     }
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerStateChange(playerid, newstate, oldstate){
  127.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER){
  128.         TextDrawShowForPlayer(playerid, Tacho[playerid][Name]);
  129.         TextDrawShowForPlayer(playerid, Tacho[playerid][Zustand]);
  130.         TextDrawShowForPlayer(playerid, Tacho[playerid][Speed]);
  131.         ShowProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
  132.     }
  133.     if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER){
  134.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  135.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  136.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  137.         HideProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
  138.     }
  139.     return 1;
  140. }
  141.  
  142. forward TachoUpdate();
  143. public TachoUpdate(){
  144.     for(new i = 0; i<MAX_PLAYERS; i++){
  145.         if(!IsPlayerConnected(i))continue;
  146.         if(!IsPlayerInAnyVehicle(i))continue;
  147.        
  148.         new veh = GetPlayerVehicleID(i),str[64],Float:hp,speed = GetVehicleSpeed(veh);
  149.         formatEx(str,"%d km/h", speed);
  150.         TextDrawSetString(Tacho[i][Speed],str);
  151.         GetVehicleHealth(veh, hp);
  152.         formatEx(str,"Zustand: %.0f HP", hp);
  153.         TextDrawSetString(Tacho[i][Zustand],str);
  154.         formatEx(str,"%s", VehName[GetVehicleModel(veh)-400]), TextDrawSetString(Tacho[i][Name],str);
  155.         hp = floatround(hp);
  156.         if(hp <= 350)SetProgressBarColor(Tacho[i][ZustandBar],0xFF000066);
  157.         else if(hp > 350 && hp < 750)SetProgressBarColor(Tacho[i][ZustandBar],0xFF910066);
  158.         else if(hp > 750)SetProgressBarColor(Tacho[i][ZustandBar],0x00FF0066);
  159.         SetProgressBarValue(Tacho[i][ZustandBar],hp);
  160.         UpdateProgressBar(Tacho[i][ZustandBar],i);
  161.     }
  162.     return 1;
  163. }
  164.  
  165. stock GetVehicleSpeed(vehicleid){
  166.     new Float:xPos[3];
  167.     GetVehicleVelocity(vehicleid, xPos[0], xPos[1], xPos[2]);
  168.     return floatround(floatsqroot(xPos[0] * xPos[0] + xPos[1] * xPos[1] + xPos[2] * xPos[2]) * 100 * 1.61);
  169. }
  170.  
  171. stock IsNoTachoVeh(vehicleid)
  172. {
  173.     if(vehicleid == INVALID_VEHICLE_ID)return 0;
  174.     if(GetVehicleModel(vehicleid)==441||GetVehicleModel(vehicleid)==449||GetVehicleModel(vehicleid)==450||GetVehicleModel(vehicleid)==464||GetVehicleModel(vehicleid)==465||
  175.     GetVehicleModel(vehicleid)==481||GetVehicleModel(vehicleid)==501||GetVehicleModel(vehicleid)==509||GetVehicleModel(vehicleid)==510||GetVehicleModel(vehicleid)==537||
  176.     GetVehicleModel(vehicleid)==538||GetVehicleModel(vehicleid)==564||GetVehicleModel(vehicleid)==569||GetVehicleModel(vehicleid)==570||GetVehicleModel(vehicleid)==584||
  177.     GetVehicleModel(vehicleid)==590||GetVehicleModel(vehicleid)==591||GetVehicleModel(vehicleid)==594||GetVehicleModel(vehicleid)==606||GetVehicleModel(vehicleid)==607||
  178.     GetVehicleModel(vehicleid)==608||GetVehicleModel(vehicleid)==610||GetVehicleModel(vehicleid)==611)return 1;
  179.     return 0;
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement