Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Tachosystem [S4] by ErikSon */
- #include <a_samp>
- #include <progress>
- /* 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:Speed,
- Bar:ZustandBar
- }
- 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 [S4] by ErikSon");
- print("--------------------------------------\n");
- for(new i = 0; i<MAX_PLAYERS; i++){
- Tacho[i][Speed] = TextDrawCreate(508.000000, 370.000000, "- km/h");
- TextDrawBackgroundColor(Tacho[i][Speed], 255);
- TextDrawFont(Tacho[i][Speed], 1);
- TextDrawLetterSize(Tacho[i][Speed], 0.600000, 2.000000);
- TextDrawColor(Tacho[i][Speed], -1);
- TextDrawSetOutline(Tacho[i][Speed], 0);
- TextDrawSetProportional(Tacho[i][Speed], 1);
- TextDrawSetShadow(Tacho[i][Speed], 1);
- TextDrawSetSelectable(Tacho[i][Speed], 0);
- Tacho[i][Name] = TextDrawCreate(507.000000, 392.000000, "-");
- TextDrawBackgroundColor(Tacho[i][Name], 255);
- TextDrawFont(Tacho[i][Name], 1);
- TextDrawLetterSize(Tacho[i][Name], 0.500000, 1.000000);
- TextDrawColor(Tacho[i][Name], -1);
- TextDrawSetOutline(Tacho[i][Name], 0);
- TextDrawSetProportional(Tacho[i][Name], 1);
- TextDrawSetShadow(Tacho[i][Name], 1);
- TextDrawSetSelectable(Tacho[i][Name], 0);
- Tacho[i][Zustand] = TextDrawCreate(520.000000, 408.000000, "Zustand: - HP");
- TextDrawBackgroundColor(Tacho[i][Zustand], 255);
- TextDrawFont(Tacho[i][Zustand], 1);
- TextDrawLetterSize(Tacho[i][Zustand], 0.300000, 1.000000);
- TextDrawColor(Tacho[i][Zustand], -1);
- TextDrawSetOutline(Tacho[i][Zustand], 0);
- TextDrawSetProportional(Tacho[i][Zustand], 1);
- TextDrawSetShadow(Tacho[i][Zustand], 1);
- TextDrawSetSelectable(Tacho[i][Zustand], 0);
- Tacho[i][ZustandBar] = CreateProgressBar(508.00, 408.00, 130.50, 11.19, 0xFFFFFFFF, 1000.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]);
- HideProgressBarForPlayer(i,Tacho[i][ZustandBar]);
- TextDrawDestroy(Tacho[i][Name]);
- TextDrawDestroy(Tacho[i][Zustand]);
- TextDrawDestroy(Tacho[i][Speed]);
- DestroyProgressBar(Tacho[i][ZustandBar]);
- }
- 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]);
- HideProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
- }
- 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]);
- ShowProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
- }
- if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER){
- TextDrawHideForPlayer(playerid, Tacho[playerid][Name]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Zustand]);
- TextDrawHideForPlayer(playerid, Tacho[playerid][Speed]);
- HideProgressBarForPlayer(playerid,Tacho[playerid][ZustandBar]);
- }
- 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);
- formatEx(str,"%d km/h", speed);
- TextDrawSetString(Tacho[i][Speed],str);
- GetVehicleHealth(veh, hp);
- formatEx(str,"Zustand: %.0f HP", hp);
- TextDrawSetString(Tacho[i][Zustand],str);
- formatEx(str,"%s", VehName[GetVehicleModel(veh)-400]), TextDrawSetString(Tacho[i][Name],str);
- hp = floatround(hp);
- if(hp <= 350)SetProgressBarColor(Tacho[i][ZustandBar],0xFF000066);
- else if(hp > 350 && hp < 750)SetProgressBarColor(Tacho[i][ZustandBar],0xFF910066);
- else if(hp > 750)SetProgressBarColor(Tacho[i][ZustandBar],0x00FF0066);
- SetProgressBarValue(Tacho[i][ZustandBar],hp);
- UpdateProgressBar(Tacho[i][ZustandBar],i);
- }
- 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