Advertisement
ErikSon_

Tachosystem [S1] by ErikSon

Aug 2nd, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.66 KB | None | 0 0
  1. /*                              Tachosystem [S1] 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:Zustand,
  15.     Text:StatusMotor,
  16.     Text:StatusLicht,
  17.     Text:Speed,
  18.     _switch
  19. }
  20. new Tacho[MAX_PLAYERS][T_EC];
  21.  
  22. new VehName[][] ={
  23.         "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  24.         "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  25.         "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  26.         "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  27.         "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  28.         "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  29.         "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  30.         "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  31.         "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  32.         "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  33.         "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  34.         "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  35.         "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  36.         "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  37.         "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  38.         "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  39.         "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  40.         "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  41.         "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  42.         "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  43.         "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  44.         "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  45.         "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  46.         "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum",
  47.         "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  48.         "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  49.         "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  50.         "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  51.         "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  52.         "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  53.         "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
  54.         "Tiller", "Utility Trailer"
  55. };
  56.  
  57.  
  58. public OnFilterScriptInit(){
  59.     print("\n--------------------------------------");
  60.     print(" Tachosystem [S1] by ErikSon");
  61.     print("--------------------------------------\n");
  62.     for(new i = 0; i<MAX_PLAYERS; i++){
  63.         Tacho[i][StatusMotor] = TextDrawCreate(503.000000, 421.000000, "Motor: '-'");
  64.         TextDrawBackgroundColor(Tacho[i][StatusMotor], 255);
  65.         TextDrawFont(Tacho[i][StatusMotor], 1);
  66.         TextDrawLetterSize(Tacho[i][StatusMotor], 0.200000, 1.000000);
  67.         TextDrawColor(Tacho[i][StatusMotor], -1);
  68.         TextDrawSetOutline(Tacho[i][StatusMotor], 0);
  69.         TextDrawSetProportional(Tacho[i][StatusMotor], 1);
  70.         TextDrawSetShadow(Tacho[i][StatusMotor], 1);
  71.         TextDrawUseBox(Tacho[i][StatusMotor], 1);
  72.         TextDrawBoxColor(Tacho[i][StatusMotor], 255);
  73.         TextDrawTextSize(Tacho[i][StatusMotor], 631.000000, 295.000000);
  74.         TextDrawSetSelectable(Tacho[i][StatusMotor], 0);
  75.        
  76.        
  77.         Tacho[i][StatusLicht] = TextDrawCreate(570.000000, 420.000000, "Licht: '-'");
  78.         TextDrawBackgroundColor(Tacho[i][StatusLicht], 255);
  79.         TextDrawFont(Tacho[i][StatusLicht], 1);
  80.         TextDrawLetterSize(Tacho[i][StatusLicht], 0.200000, 1.0000);
  81.         TextDrawColor(Tacho[i][StatusLicht], -1);
  82.         TextDrawSetOutline(Tacho[i][StatusLicht], 0);
  83.         TextDrawSetProportional(Tacho[i][StatusLicht], 1);
  84.         TextDrawSetShadow(Tacho[i][StatusLicht], 1);
  85.         TextDrawSetSelectable(Tacho[i][StatusLicht], 0);
  86.  
  87.         Tacho[i][Speed] = TextDrawCreate(503.000000, 390.000000, "Speed: - KM/H");
  88.         TextDrawBackgroundColor(Tacho[i][Speed], 255);
  89.         TextDrawFont(Tacho[i][Speed], 1);
  90.         TextDrawLetterSize(Tacho[i][Speed], 0.400000, 1.000000);
  91.         TextDrawColor(Tacho[i][Speed], -1);
  92.         TextDrawSetOutline(Tacho[i][Speed], 0);
  93.         TextDrawSetProportional(Tacho[i][Speed], 1);
  94.         TextDrawSetShadow(Tacho[i][Speed], 1);
  95.         TextDrawUseBox(Tacho[i][Speed], 1);
  96.         TextDrawBoxColor(Tacho[i][Speed], 255);
  97.         TextDrawTextSize(Tacho[i][Speed], 631.000000, 0.000000);
  98.         TextDrawSetSelectable(Tacho[i][Speed], 0);
  99.  
  100.         Tacho[i][Zustand] = TextDrawCreate(503.000000, 406.000000, "Zustand: - HP");
  101.         TextDrawBackgroundColor(Tacho[i][Zustand], 255);
  102.         TextDrawFont(Tacho[i][Zustand], 1);
  103.         TextDrawLetterSize(Tacho[i][Zustand], 0.340000, 1.000000);
  104.         TextDrawColor(Tacho[i][Zustand], -1);
  105.         TextDrawSetOutline(Tacho[i][Zustand], 0);
  106.         TextDrawSetProportional(Tacho[i][Zustand], 1);
  107.         TextDrawSetShadow(Tacho[i][Zustand], 1);
  108.         TextDrawUseBox(Tacho[i][Zustand], 1);
  109.         TextDrawBoxColor(Tacho[i][Zustand], 255);
  110.         TextDrawTextSize(Tacho[i][Zustand], 631.000000, -2.000000);
  111.         TextDrawSetSelectable(Tacho[i][Zustand], 0);
  112.  
  113.         Tacho[i][Name] = TextDrawCreate(503.000000, 374.000000, "-");
  114.         TextDrawBackgroundColor(Tacho[i][Name], 255);
  115.         TextDrawFont(Tacho[i][Name], 1);
  116.         TextDrawLetterSize(Tacho[i][Name], 0.400000, 1.000000);
  117.         TextDrawColor(Tacho[i][Name], -1);
  118.         TextDrawSetOutline(Tacho[i][Name], 0);
  119.         TextDrawSetProportional(Tacho[i][Name], 1);
  120.         TextDrawSetShadow(Tacho[i][Name], 1);
  121.         TextDrawUseBox(Tacho[i][Name], 1);
  122.         TextDrawBoxColor(Tacho[i][Name], 255);
  123.         TextDrawTextSize(Tacho[i][Name], 631.000000, 0.000000);
  124.         TextDrawSetSelectable(Tacho[i][Name], 0);
  125.     }
  126.     return SetTimer("TachoUpdate",444,true);
  127. }
  128.  
  129. public OnFilterScriptExit(){
  130.     for(new i = 0; i<MAX_PLAYERS; i++){
  131.         TextDrawHideForPlayer(i,Tacho[i][Name]);
  132.         TextDrawHideForPlayer(i,Tacho[i][Zustand]);
  133.         TextDrawHideForPlayer(i,Tacho[i][Speed]);
  134.         TextDrawHideForPlayer(i,Tacho[i][StatusMotor]);
  135.         TextDrawHideForPlayer(i,Tacho[i][StatusLicht]);
  136.            
  137.         TextDrawDestroy(Tacho[i][Name]);
  138.         TextDrawDestroy(Tacho[i][Zustand]);
  139.         TextDrawDestroy(Tacho[i][Speed]);
  140.         TextDrawDestroy(Tacho[i][StatusMotor]);
  141.         TextDrawDestroy(Tacho[i][StatusLicht]);
  142.     }
  143.     return 1;
  144. }
  145.  
  146. public OnPlayerConnect(playerid){
  147.     return 1;
  148. }
  149.  
  150. public OnPlayerDisconnect(playerid, reason){
  151.     if(IsPlayerInAnyVehicle(playerid)){
  152.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  153.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  154.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  155.         TextDrawHideForPlayer(playerid, Tacho[playerid][StatusMotor]);
  156.         TextDrawHideForPlayer(playerid,Tacho[playerid][StatusLicht]);
  157.     }
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerStateChange(playerid, newstate, oldstate){
  162.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER){
  163.         TextDrawShowForPlayer(playerid, Tacho[playerid][Name]);
  164.         TextDrawShowForPlayer(playerid, Tacho[playerid][Zustand]);
  165.         TextDrawShowForPlayer(playerid, Tacho[playerid][Speed]);
  166.         TextDrawShowForPlayer(playerid, Tacho[playerid][StatusMotor]);
  167.         TextDrawShowForPlayer(playerid,Tacho[playerid][StatusLicht]);
  168.     }
  169.     if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER){
  170.         TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
  171.         TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
  172.         TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
  173.         TextDrawHideForPlayer(playerid, Tacho[playerid][StatusMotor]);
  174.         TextDrawHideForPlayer(playerid,Tacho[playerid][StatusLicht]);
  175.     }
  176.     return 1;
  177. }
  178.  
  179. forward TachoUpdate();
  180. public TachoUpdate(){
  181.     for(new i = 0; i<MAX_PLAYERS; i++){
  182.         if(!IsPlayerConnected(i))continue;
  183.         if(!IsPlayerInAnyVehicle(i))continue;
  184.        
  185.         new veh = GetPlayerVehicleID(i),str[64],Float:hp,speed = GetVehicleSpeed(veh);
  186.         if(speed < 100)formatEx(str,"Speed: ~g~%d~w~ KM/H", speed);
  187.         else if(speed > 100 && speed < 160)formatEx(str,"Speed: ~y~%d ~w~KM/H",speed);
  188.         else if(speed > 160)formatEx(str,"Speed: ~r~%d~w~ KM/H",speed);
  189.         TextDrawSetString(Tacho[i][Speed],str);
  190.         GetVehicleHealth(veh, hp);
  191.         if(hp > 700)formatEx(str,"Zustand: ~g~%.0f HP", hp),Tacho[i][_switch] = 0;
  192.         else if(hp > 350 && hp < 700)formatEx(str,"Zustand: ~y~%.0f HP", hp),Tacho[i][_switch] = 0;
  193.         else if(hp < 350){
  194.             formatEx(str,"Zustand: ~r~%.0f HP", hp);
  195.             switch(Tacho[i][_switch]){
  196.                 case 0:Tacho[i][_switch] = 1,TextDrawHideForPlayer(i,Tacho[i][Zustand]);
  197.                 case 1:Tacho[i][_switch] = 0,TextDrawShowForPlayer(i,Tacho[i][Zustand]);
  198.             }
  199.         }
  200.         TextDrawSetString(Tacho[i][Zustand],str);
  201.         formatEx(str,"~r~%s", VehName[GetVehicleModel(veh)-400]), TextDrawSetString(Tacho[i][Name],str);
  202.         new motor,lichter,objektiv,boot,bonnet,doors,alarm;
  203.         GetVehicleParamsEx(veh,motor,lichter,alarm,doors,bonnet,boot,objektiv);
  204.         if(IsNoTachoVeh(veh)){
  205.             TextDrawSetString(Tacho[i][StatusMotor],"Motor: '-"),
  206.             TextDrawSetString(Tacho[i][StatusLicht],"Licht: '-");
  207.         }
  208.         else{
  209.             formatEx(str,"Motor: '%s'",(!motor) ? ("~r~Aus~w~") : ("~g~An~w~")), TextDrawSetString(Tacho[i][StatusMotor],str);
  210.             formatEx(str,"Licht: '%s'",(!lichter) ? ("~r~Aus~w~") : ("~g~An~w~")),TextDrawSetString(Tacho[i][StatusLicht],str);
  211.         }
  212.     }
  213.     return 1;
  214. }
  215.  
  216. stock GetVehicleSpeed(vehicleid){
  217.     new Float:xPos[3];
  218.     GetVehicleVelocity(vehicleid, xPos[0], xPos[1], xPos[2]);
  219.     return floatround(floatsqroot(xPos[0] * xPos[0] + xPos[1] * xPos[1] + xPos[2] * xPos[2]) * 100 * 1.61);
  220. }
  221.  
  222. stock IsNoTachoVeh(vehicleid)
  223. {
  224.     if(vehicleid == INVALID_VEHICLE_ID)return 0;
  225.     if(GetVehicleModel(vehicleid)==441||GetVehicleModel(vehicleid)==449||GetVehicleModel(vehicleid)==450||GetVehicleModel(vehicleid)==464||GetVehicleModel(vehicleid)==465||
  226.     GetVehicleModel(vehicleid)==481||GetVehicleModel(vehicleid)==501||GetVehicleModel(vehicleid)==509||GetVehicleModel(vehicleid)==510||GetVehicleModel(vehicleid)==537||
  227.     GetVehicleModel(vehicleid)==538||GetVehicleModel(vehicleid)==564||GetVehicleModel(vehicleid)==569||GetVehicleModel(vehicleid)==570||GetVehicleModel(vehicleid)==584||
  228.     GetVehicleModel(vehicleid)==590||GetVehicleModel(vehicleid)==591||GetVehicleModel(vehicleid)==594||GetVehicleModel(vehicleid)==606||GetVehicleModel(vehicleid)==607||
  229.     GetVehicleModel(vehicleid)==608||GetVehicleModel(vehicleid)==610||GetVehicleModel(vehicleid)==611)return 1;
  230.     return 0;
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement