Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////SA:MP Tacho & Tank System by !Stan//////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- //////////////////////////www.SAMP-German.de////////////////////////////////////
- #include <a_samp>
- /*defines*/
- #define GasMax 100
- #define RunOutTime 30000
- #define RefuelWait 5000
- #define CAR_AMOUNT 700
- #define SpeedoTime 500
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF00AA
- #define Dialog_Tanken 1
- /*forwards*/
- forward UpdateSpeedo();
- forward CheckGas();
- forward Fillup();
- forward SpeedoMeter();
- forward IsAtGasStation(playerid);
- forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
- /*new´s*/
- new Text:SpeedoBox, Text:SpeedoVehText, Text:SpeedoVeh[MAX_PLAYERS], Text:SpeedoKMHText, Text:SpeedoKMH[MAX_PLAYERS],Text:SpeedoTankText, Text:SpeedoTank[MAX_PLAYERS];
- new Gas[CAR_AMOUNT], Betanken[MAX_PLAYERS],Float:TachoX[MAX_PLAYERS],Float:TachoY[MAX_PLAYERS],Float:TachoZ[MAX_PLAYERS];
- new FahrzeugName[][] =
- {
- "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()
- {
- /*Server Online*/
- print("\n__________________________________________");
- print("[!Stan´s] Speedometer geladen...");
- print("__________________________________________\n");
- /*Textdraws*/
- SpeedoBox = TextDrawCreate(623.000000, 324.000000, " .");
- TextDrawBackgroundColor(SpeedoBox, 255);
- TextDrawFont(SpeedoBox, 1);
- TextDrawLetterSize(SpeedoBox, 27.410072, 1.000000);
- TextDrawColor(SpeedoBox, -1);
- TextDrawSetOutline(SpeedoBox, 0);
- TextDrawSetProportional(SpeedoBox, 1);
- TextDrawSetShadow(SpeedoBox, 1);
- TextDrawUseBox(SpeedoBox, 1);
- TextDrawBoxColor(SpeedoBox, 50);
- TextDrawTextSize(SpeedoBox, 511.000000, -7.000000);
- SpeedoVehText = TextDrawCreate(516.000000, 322.000000, "Fahrzeug:");
- TextDrawBackgroundColor(SpeedoVehText, 255);
- TextDrawFont(SpeedoVehText, 2);
- TextDrawLetterSize(SpeedoVehText, 0.320000, 1.000000);
- TextDrawColor(SpeedoVehText, 75366399);
- TextDrawSetOutline(SpeedoVehText, 1);
- TextDrawSetProportional(SpeedoVehText, 1);
- SpeedoTankText = TextDrawCreate(516.000000, 376.000000, "Tank:");
- TextDrawBackgroundColor(SpeedoTankText, 255);
- TextDrawFont(SpeedoTankText, 2);
- TextDrawLetterSize(SpeedoTankText, 0.320000, 1.000000);
- TextDrawColor(SpeedoTankText, 75366399);
- TextDrawSetOutline(SpeedoTankText, 1);
- TextDrawSetProportional(SpeedoTankText, 1);
- SpeedoKMHText = TextDrawCreate(516.000000, 349.000000, "KM/H:");
- TextDrawBackgroundColor(SpeedoKMHText, 255);
- TextDrawFont(SpeedoKMHText, 2);
- TextDrawLetterSize(SpeedoKMHText, 0.320000, 1.000000);
- TextDrawColor(SpeedoKMHText, 75366399);
- TextDrawSetOutline(SpeedoKMHText, 1);
- TextDrawSetProportional(SpeedoKMHText, 1);
- for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
- {
- SpeedoVeh[playerid] = TextDrawCreate(516.000000, 333.000000, " ");
- TextDrawBackgroundColor(SpeedoVeh[playerid], 255);
- TextDrawFont(SpeedoVeh[playerid], 2);
- TextDrawLetterSize(SpeedoVeh[playerid], 0.320000, 1.000000);
- TextDrawColor(SpeedoVeh[playerid], -1);
- TextDrawSetOutline(SpeedoVeh[playerid], 1);
- TextDrawSetProportional(SpeedoVeh[playerid], 1);
- SpeedoKMH[playerid] = TextDrawCreate(516.000000, 360.000000, " ");
- TextDrawBackgroundColor(SpeedoKMH[playerid], 255);
- TextDrawFont(SpeedoKMH[playerid], 2);
- TextDrawLetterSize(SpeedoKMH[playerid], 0.320000, 1.000000);
- TextDrawColor(SpeedoKMH[playerid], -1);
- TextDrawSetOutline(SpeedoKMH[playerid], 1);
- TextDrawSetProportional(SpeedoKMH[playerid], 1);
- SpeedoTank[playerid] = TextDrawCreate(516.000000, 387.000000, " ");
- TextDrawBackgroundColor(SpeedoTank[playerid], 255);
- TextDrawFont(SpeedoTank[playerid], 2);
- TextDrawLetterSize(SpeedoTank[playerid], 0.320000, 1.000000);
- TextDrawColor(SpeedoTank[playerid], -1);
- TextDrawSetOutline(SpeedoTank[playerid], 1);
- TextDrawSetProportional(SpeedoTank[playerid], 1);
- }
- /*Timer*/
- SetTimer("UpdateSpeedo",1000,1);
- SetTimer("SpeedoMeter",1000,1);
- SetTimer("CheckGas",30000,1);
- for(new c = 0; c < CAR_AMOUNT; c++)
- {
- Gas[c] = GasMax;
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp("/Tanken", cmdtext, true, 10) == 0)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(IsAtGasStation(playerid))
- {
- ShowPlayerDialog(playerid,Dialog_Tanken,DIALOG_STYLE_MSGBOX,"{FF0000}Möchtest du dein Fahrzeug Betanken ?","{FFFFFF}Wähle 'Ja' oder 'Nein'.","Ja","Nein");
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "Du bist an keiner Tankstelle!");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem Fahrzeug!");
- return 1;
- }
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- TextDrawShowForPlayer(playerid,SpeedoBox);
- TextDrawShowForPlayer(playerid,SpeedoVehText);
- TextDrawShowForPlayer(playerid,SpeedoVeh[playerid]);
- TextDrawShowForPlayer(playerid,SpeedoKMHText);
- TextDrawShowForPlayer(playerid,SpeedoKMH[playerid]);
- TextDrawShowForPlayer(playerid,SpeedoTankText);
- TextDrawShowForPlayer(playerid,SpeedoTank[playerid]);
- }
- if(oldstate == PLAYER_STATE_DRIVER)
- {
- TextDrawHideForPlayer(playerid,SpeedoBox);
- TextDrawHideForPlayer(playerid,SpeedoVehText);
- TextDrawHideForPlayer(playerid,SpeedoVeh[playerid]);
- TextDrawHideForPlayer(playerid,SpeedoKMHText);
- TextDrawHideForPlayer(playerid,SpeedoKMH[playerid]);
- TextDrawHideForPlayer(playerid,SpeedoTankText);
- TextDrawHideForPlayer(playerid, SpeedoTank[playerid]);
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public UpdateSpeedo()
- {
- for(new i = 0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPlayerState(i)==2)
- {
- new speed[128];
- new Float:xfloat,Float:yfloat,Float:zfloat;
- new Float:distance,value;
- GetPlayerPos(i, xfloat, yfloat, zfloat);
- distance = floatsqroot(floatpower(floatabs(floatsub(xfloat,TachoX[i])),2)+floatpower(floatabs(floatsub(yfloat,TachoY[i])),2)+floatpower(floatabs(floatsub(zfloat,TachoZ[i])),2));
- value = floatround(distance * 11000);
- TachoX[i] = xfloat;
- TachoY[i] = yfloat;
- TachoZ[i] = zfloat;
- format(speed,sizeof(speed),"%d",floatround(value/3200));
- TextDrawSetString(SpeedoKMH[i],speed);
- new namestring[128];
- format(namestring,sizeof(namestring),"%s",FahrzeugName[GetVehicleModel(GetPlayerVehicleID(i))-400]);
- TextDrawSetString(SpeedoVeh[i],namestring);
- }
- }
- }
- return 1;
- }
- public SpeedoMeter()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == 2)
- {
- new string[100];
- new vehicle = GetPlayerVehicleID(i);
- if(Gas[vehicle] <= 10)
- {
- format(string, sizeof(string), "%d%", Gas[vehicle]);
- TextDrawSetString(SpeedoTank[i], string);
- }
- else
- {
- format(string, sizeof(string), "%d%", Gas[vehicle]);
- TextDrawSetString(SpeedoTank[i], string);
- }
- }
- }
- }
- return 1;
- }
- public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- tempposx = (oldposx -x);
- tempposy = (oldposy -y);
- tempposz = (oldposz -z);
- //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- return 1;
- }
- }
- return 0;
- }
- public CheckGas()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == 2)
- {
- new vehicle = GetPlayerVehicleID(i);
- if(Gas[vehicle] >= 1)
- {
- if(Gas[vehicle] <= 10)
- {
- PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
- }
- Gas[vehicle]--;
- } else {
- TogglePlayerControllable(i, 0);
- GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~n~~n~~r~Dein Tank ist leer!~n~~w~/exit zum aussteigen", 5000, 3);
- }
- }
- }
- }
- return 1;
- }
- public Fillup()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- new string[255];
- new TankPreis;
- new vehicle = GetPlayerVehicleID(i);
- TankPreis = ((GasMax - Gas[vehicle]) * 2);
- if(Betanken[i] == 1)
- {
- if(GetPlayerMoney(i) >= TankPreis)
- {
- Gas[vehicle] = GasMax;
- TogglePlayerControllable(i, 1);
- GivePlayerMoney(i, - TankPreis);
- Betanken[i] = 0;
- format(string,sizeof(string),"Dein Fahrzeug wurde für %d$ voll aufgetankt!", TankPreis);
- SendClientMessage(i, COLOR_YELLOW, string);
- } else {
- SendClientMessage(i, COLOR_RED, "Leider hast du nicht genug Geld um dein Fahrzeug voll zu tanken!");
- format(string,sizeof(string),"Um deinen Tank bis auf das letzte aufzufüllen bräuchtest du %d$.", TankPreis);
- SendClientMessage(i, COLOR_RED, string);
- }
- }
- }
- }
- return 1;
- }
- public IsAtGasStation(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(PlayerToPoint(6.0,playerid,1004.0070,-939.3102,42.1797) || PlayerToPoint(6.0,playerid,1944.3260,-1772.9254,13.3906))
- {//LS
- return 1;
- }
- else if(PlayerToPoint(6.0,playerid,-90.5515,-1169.4578,2.4079) || PlayerToPoint(6.0,playerid,-1609.7958,-2718.2048,48.5391))
- {//LS
- return 1;
- }
- else if(PlayerToPoint(6.0,playerid,-2029.4968,156.4366,28.9498) || PlayerToPoint(8.0,playerid,-2408.7590,976.0934,45.4175))
- {//SF
- return 1;
- }
- else if(PlayerToPoint(5.0,playerid,-2243.9629,-2560.6477,31.8841) || PlayerToPoint(8.0,playerid,-1676.6323,414.0262,6.9484))
- {//Between LS and SF
- return 1;
- }
- else if(PlayerToPoint(6.0,playerid,2202.2349,2474.3494,10.5258) || PlayerToPoint(10.0,playerid,614.9333,1689.7418,6.6968))
- {//LV
- return 1;
- }
- else if(PlayerToPoint(8.0,playerid,-1328.8250,2677.2173,49.7665) || PlayerToPoint(6.0,playerid,70.3882,1218.6783,18.5165))
- {//LV
- return 1;
- }
- else if(PlayerToPoint(8.0,playerid,2113.7390,920.1079,10.5255) || PlayerToPoint(6.0,playerid,-1327.7218,2678.8723,50.0625))
- {//LV
- return 1;
- }
- }
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == Dialog_Tanken)
- {
- if(response == 1)
- {
- TogglePlayerControllable(playerid, 0);
- GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~r~Betanke Fahrzeug!~n~~y~~h~Bitte warten...",4600,3);
- SetTimer("Fillup", RefuelWait, 0);
- Betanken[playerid] = 1;
- }
- if(response == 0)
- {
- SendClientMessage(playerid,COLOR_RED,"Dann Betankst du dein Fahrzeug nicht.");
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement