Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Tachosystem [S1] by ErikSon */
- #include <a_samp>
- /* Settings */
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 5 //Server-Slotanzahl
- /* Settings */
- #define formatEx(%0,%1,%2) format(%0,sizeof(%0),%1,%2)
- enum T_EC{
- Text:Name,
- Text:Zustand,
- Text:StatusMotor,
- Text:StatusLicht,
- Text:Speed,
- _switch
- }
- new Tacho[MAX_PLAYERS][T_EC];
- new VehName[][] ={
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
- "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
- "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
- "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
- "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
- "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
- "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
- "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
- "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
- "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
- "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
- "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
- "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
- "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
- "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
- "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
- "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
- "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
- "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
- "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
- "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
- "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
- "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
- "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum",
- "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
- "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
- "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
- "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
- "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
- "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
- "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
- "Tiller", "Utility Trailer"
- };
- public OnFilterScriptInit(){
- print("\n--------------------------------------");
- print(" Tachosystem [S1] by ErikSon");
- print("--------------------------------------\n");
- for(new i = 0; i<MAX_PLAYERS; i++){
- Tacho[i][StatusMotor] = TextDrawCreate(503.000000, 421.000000, "Motor: '-'");
- TextDrawBackgroundColor(Tacho[i][StatusMotor], 255);
- TextDrawFont(Tacho[i][StatusMotor], 1);
- TextDrawLetterSize(Tacho[i][StatusMotor], 0.200000, 1.000000);
- TextDrawColor(Tacho[i][StatusMotor], -1);
- TextDrawSetOutline(Tacho[i][StatusMotor], 0);
- TextDrawSetProportional(Tacho[i][StatusMotor], 1);
- TextDrawSetShadow(Tacho[i][StatusMotor], 1);
- TextDrawUseBox(Tacho[i][StatusMotor], 1);
- TextDrawBoxColor(Tacho[i][StatusMotor], 255);
- TextDrawTextSize(Tacho[i][StatusMotor], 631.000000, 295.000000);
- TextDrawSetSelectable(Tacho[i][StatusMotor], 0);
- Tacho[i][StatusLicht] = TextDrawCreate(570.000000, 420.000000, "Licht: '-'");
- TextDrawBackgroundColor(Tacho[i][StatusLicht], 255);
- TextDrawFont(Tacho[i][StatusLicht], 1);
- TextDrawLetterSize(Tacho[i][StatusLicht], 0.200000, 1.0000);
- TextDrawColor(Tacho[i][StatusLicht], -1);
- TextDrawSetOutline(Tacho[i][StatusLicht], 0);
- TextDrawSetProportional(Tacho[i][StatusLicht], 1);
- TextDrawSetShadow(Tacho[i][StatusLicht], 1);
- TextDrawSetSelectable(Tacho[i][StatusLicht], 0);
- Tacho[i][Speed] = TextDrawCreate(503.000000, 390.000000, "Speed: - KM/H");
- TextDrawBackgroundColor(Tacho[i][Speed], 255);
- TextDrawFont(Tacho[i][Speed], 1);
- TextDrawLetterSize(Tacho[i][Speed], 0.400000, 1.000000);
- TextDrawColor(Tacho[i][Speed], -1);
- TextDrawSetOutline(Tacho[i][Speed], 0);
- TextDrawSetProportional(Tacho[i][Speed], 1);
- TextDrawSetShadow(Tacho[i][Speed], 1);
- TextDrawUseBox(Tacho[i][Speed], 1);
- TextDrawBoxColor(Tacho[i][Speed], 255);
- TextDrawTextSize(Tacho[i][Speed], 631.000000, 0.000000);
- TextDrawSetSelectable(Tacho[i][Speed], 0);
- Tacho[i][Zustand] = TextDrawCreate(503.000000, 406.000000, "Zustand: - HP");
- TextDrawBackgroundColor(Tacho[i][Zustand], 255);
- TextDrawFont(Tacho[i][Zustand], 1);
- TextDrawLetterSize(Tacho[i][Zustand], 0.340000, 1.000000);
- TextDrawColor(Tacho[i][Zustand], -1);
- TextDrawSetOutline(Tacho[i][Zustand], 0);
- TextDrawSetProportional(Tacho[i][Zustand], 1);
- TextDrawSetShadow(Tacho[i][Zustand], 1);
- TextDrawUseBox(Tacho[i][Zustand], 1);
- TextDrawBoxColor(Tacho[i][Zustand], 255);
- TextDrawTextSize(Tacho[i][Zustand], 631.000000, -2.000000);
- TextDrawSetSelectable(Tacho[i][Zustand], 0);
- Tacho[i][Name] = TextDrawCreate(503.000000, 374.000000, "-");
- TextDrawBackgroundColor(Tacho[i][Name], 255);
- TextDrawFont(Tacho[i][Name], 1);
- TextDrawLetterSize(Tacho[i][Name], 0.400000, 1.000000);
- TextDrawColor(Tacho[i][Name], -1);
- TextDrawSetOutline(Tacho[i][Name], 0);
- TextDrawSetProportional(Tacho[i][Name], 1);
- TextDrawSetShadow(Tacho[i][Name], 1);
- TextDrawUseBox(Tacho[i][Name], 1);
- TextDrawBoxColor(Tacho[i][Name], 255);
- TextDrawTextSize(Tacho[i][Name], 631.000000, 0.000000);
- TextDrawSetSelectable(Tacho[i][Name], 0);
- }
- return SetTimer("TachoUpdate",444,true);
- }
- public OnFilterScriptExit(){
- for(new i = 0; i<MAX_PLAYERS; i++){
- TextDrawHideForPlayer(i,Tacho[i][Name]);
- TextDrawHideForPlayer(i,Tacho[i][Zustand]);
- TextDrawHideForPlayer(i,Tacho[i][Speed]);
- TextDrawHideForPlayer(i,Tacho[i][StatusMotor]);
- TextDrawHideForPlayer(i,Tacho[i][StatusLicht]);
- TextDrawDestroy(Tacho[i][Name]);
- TextDrawDestroy(Tacho[i][Zustand]);
- TextDrawDestroy(Tacho[i][Speed]);
- TextDrawDestroy(Tacho[i][StatusMotor]);
- TextDrawDestroy(Tacho[i][StatusLicht]);
- }
- return 1;
- }
- public OnPlayerConnect(playerid){
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason){
- if(IsPlayerInAnyVehicle(playerid)){
- TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][StatusMotor]);
- TextDrawHideForPlayer(playerid,Tacho[playerid][StatusLicht]);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate){
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER){
- TextDrawShowForPlayer(playerid, Tacho[playerid][Name]);
- TextDrawShowForPlayer(playerid, Tacho[playerid][Zustand]);
- TextDrawShowForPlayer(playerid, Tacho[playerid][Speed]);
- TextDrawShowForPlayer(playerid, Tacho[playerid][StatusMotor]);
- TextDrawShowForPlayer(playerid,Tacho[playerid][StatusLicht]);
- }
- if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER){
- TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][StatusMotor]);
- TextDrawHideForPlayer(playerid,Tacho[playerid][StatusLicht]);
- }
- return 1;
- }
- forward TachoUpdate();
- public TachoUpdate(){
- for(new i = 0; i<MAX_PLAYERS; i++){
- if(!IsPlayerConnected(i))continue;
- if(!IsPlayerInAnyVehicle(i))continue;
- new veh = GetPlayerVehicleID(i),str[64],Float:hp,speed = GetVehicleSpeed(veh);
- if(speed < 100)formatEx(str,"Speed: ~g~%d~w~ KM/H", speed);
- else if(speed > 100 && speed < 160)formatEx(str,"Speed: ~y~%d ~w~KM/H",speed);
- else if(speed > 160)formatEx(str,"Speed: ~r~%d~w~ KM/H",speed);
- TextDrawSetString(Tacho[i][Speed],str);
- GetVehicleHealth(veh, hp);
- if(hp > 700)formatEx(str,"Zustand: ~g~%.0f HP", hp),Tacho[i][_switch] = 0;
- else if(hp > 350 && hp < 700)formatEx(str,"Zustand: ~y~%.0f HP", hp),Tacho[i][_switch] = 0;
- else if(hp < 350){
- formatEx(str,"Zustand: ~r~%.0f HP", hp);
- switch(Tacho[i][_switch]){
- case 0:Tacho[i][_switch] = 1,TextDrawHideForPlayer(i,Tacho[i][Zustand]);
- case 1:Tacho[i][_switch] = 0,TextDrawShowForPlayer(i,Tacho[i][Zustand]);
- }
- }
- TextDrawSetString(Tacho[i][Zustand],str);
- formatEx(str,"~r~%s", VehName[GetVehicleModel(veh)-400]), TextDrawSetString(Tacho[i][Name],str);
- new motor,lichter,objektiv,boot,bonnet,doors,alarm;
- GetVehicleParamsEx(veh,motor,lichter,alarm,doors,bonnet,boot,objektiv);
- if(IsNoTachoVeh(veh)){
- TextDrawSetString(Tacho[i][StatusMotor],"Motor: '-"),
- TextDrawSetString(Tacho[i][StatusLicht],"Licht: '-");
- }
- else{
- formatEx(str,"Motor: '%s'",(!motor) ? ("~r~Aus~w~") : ("~g~An~w~")), TextDrawSetString(Tacho[i][StatusMotor],str);
- formatEx(str,"Licht: '%s'",(!lichter) ? ("~r~Aus~w~") : ("~g~An~w~")),TextDrawSetString(Tacho[i][StatusLicht],str);
- }
- }
- return 1;
- }
- stock GetVehicleSpeed(vehicleid){
- new Float:xPos[3];
- GetVehicleVelocity(vehicleid, xPos[0], xPos[1], xPos[2]);
- return floatround(floatsqroot(xPos[0] * xPos[0] + xPos[1] * xPos[1] + xPos[2] * xPos[2]) * 100 * 1.61);
- }
- stock IsNoTachoVeh(vehicleid)
- {
- if(vehicleid == INVALID_VEHICLE_ID)return 0;
- if(GetVehicleModel(vehicleid)==441||GetVehicleModel(vehicleid)==449||GetVehicleModel(vehicleid)==450||GetVehicleModel(vehicleid)==464||GetVehicleModel(vehicleid)==465||
- GetVehicleModel(vehicleid)==481||GetVehicleModel(vehicleid)==501||GetVehicleModel(vehicleid)==509||GetVehicleModel(vehicleid)==510||GetVehicleModel(vehicleid)==537||
- GetVehicleModel(vehicleid)==538||GetVehicleModel(vehicleid)==564||GetVehicleModel(vehicleid)==569||GetVehicleModel(vehicleid)==570||GetVehicleModel(vehicleid)==584||
- GetVehicleModel(vehicleid)==590||GetVehicleModel(vehicleid)==591||GetVehicleModel(vehicleid)==594||GetVehicleModel(vehicleid)==606||GetVehicleModel(vehicleid)==607||
- GetVehicleModel(vehicleid)==608||GetVehicleModel(vehicleid)==610||GetVehicleModel(vehicleid)==611)return 1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement