Guest User

Tacho Helper (c) by Kaliber

a guest
Dec 11th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.39 KB | None | 0 0
  1. /* Sa-Mp Include Tacho Helper
  2.  *
  3.  * (c) by Kaliber, 2012
  4.  *
  5.  */
  6. #include <a_samp>
  7. #if !defined VERBRENNEN
  8.     #define VERBRENNEN 15
  9. #endif
  10. #pragma tabsize 0 //Nur hier in pastebin
  11.  
  12. forward _OnPlayerCommandText(playerid,cmdtext[]);
  13. forward _OnGameModeInit();
  14. forward Global_Tank();
  15.  
  16. static const VehicleName[212][] = {
  17. "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
  18. "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat",
  19. "Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife",
  20. "Trailer 1", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo",
  21. "Seasparrow", "Pizzaboy", "Tram", "Trailer 2", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair",
  22. "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic", "Sanchez", "Sparrow",
  23. "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX", "Burrito",
  24. "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring",
  25. "Sandking", "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B",
  26. "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster","Stunt",  "Tanker",
  27. "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  28. "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak",
  29. "Vortex", "Vincent", "Bullet", "Clover", "Sadler", "Firetruck LA", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit",
  30. "Utility", "Nevada", "Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance",
  31. "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito", "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway",
  32. "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer 3", "Emperor", "Wayfarer", "Euros", "Hotdog",
  33. "Club", "Freight Carriage", "Trailer 4", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
  34. "Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer A",
  35. "Luggage Trailer B", "Stairs", "Boxville", "Tiller", "Utility Trailer" };
  36. static c_Tank[MAX_VEHICLES];
  37.  
  38. stock bool:Tank_Check(vehicleid)
  39. {
  40.     if(c_Tank[vehicleid] > 0) return true;
  41.     return false;
  42. }
  43. stock bool:IsPlayerAtTanke(playerid)
  44. {
  45.     if(IsPlayerInRangeOfPoint(playerid, 5.0, 1944.4954,-1772.7089,13.3906)||
  46.     IsPlayerInRangeOfPoint(playerid, 5.0, 1004.2097,-940.1768,42.1797)||
  47.     IsPlayerInRangeOfPoint(playerid, 5.0, 651.8976,-564.9250,16.3359)||
  48.     IsPlayerInRangeOfPoint(playerid, 5.0, -90.8697,-1169.0400,2.4194)||
  49.     IsPlayerInRangeOfPoint(playerid, 5.0, -1605.8799,-2714.1003,48.5335)||
  50.     IsPlayerInRangeOfPoint(playerid, 5.0, -2244.3743,-2561.0940,31.9219)||
  51.     IsPlayerInRangeOfPoint(playerid, 5.0, -2029.6212,156.7755,28.8359)||
  52.     IsPlayerInRangeOfPoint(playerid, 5.0, -1675.8535,413.2264,7.1797)||
  53.     IsPlayerInRangeOfPoint(playerid, 5.0, -2405.9473,976.4783,45.2969)||
  54.     IsPlayerInRangeOfPoint(playerid, 5.0, -1328.2087,2677.4607,50.0625)||
  55.     IsPlayerInRangeOfPoint(playerid, 5.0, -737.0900,2742.5413,47.2266)||
  56.     IsPlayerInRangeOfPoint(playerid, 5.0, 611.6671,1694.5723,6.9922)||
  57.     IsPlayerInRangeOfPoint(playerid, 5.0, 70.5098,1218.7645,18.8123)||
  58.     IsPlayerInRangeOfPoint(playerid, 5.0, -1470.9233,1864.3240,32.6328)||
  59.     IsPlayerInRangeOfPoint(playerid, 5.0, 2149.5557,2747.8027,10.8203)||
  60.     IsPlayerInRangeOfPoint(playerid, 5.0, 2640.1379,1106.3120,10.8203)||
  61.     IsPlayerInRangeOfPoint(playerid, 5.0, 1596.4186,2199.0229,10.8203)||
  62.     IsPlayerInRangeOfPoint(playerid, 5.0, 2202.3293,2474.0010,10.8203)||
  63.     IsPlayerInRangeOfPoint(playerid, 5.0, 2114.8806,920.3449,10.8203)) return true;
  64.     return false;
  65. }
  66. stock GetVehicleSpeed(vehicleid)
  67. {
  68.     new Float:Q[3];
  69.     GetVehicleVelocity(vehicleid,Q[0],Q[1],Q[2]);
  70.     return floatround(floatsqroot(Q[0]*Q[0]+Q[1]*Q[1]+Q[2]*Q[2])*170);
  71. }
  72.  
  73. stock GetVehicleName(vehicleid)
  74. {
  75.     return VehicleName[GetVehicleModel(vehicleid)-400];
  76. }
  77.  
  78. stock GetTank(vehicleid)
  79. {
  80.     return c_Tank[vehicleid];
  81. }
  82.  
  83. public OnPlayerCommandText(playerid,cmdtext[])
  84. {
  85.     if(!strcmp(cmdtext, "/fill", true))
  86.     {
  87.         if(!IsPlayerAtTanke(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Du befindest dich an keiner Tankstelle !");
  88.         if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Du befindest dich in keinem Auto !");
  89.         new veh = GetPlayerVehicleID(playerid);
  90.         if(c_Tank[veh] > 50) return SendClientMessage(playerid,0xFF0000FF,"In deinem Tank befinden sich noch mehr als 50% !");
  91.         new liter = 100-c_Tank[veh];
  92.         CallRemoteFunction("OnPlayerTank", "ii", playerid,liter);
  93.         c_Tank[veh] = 100;
  94.         return 1;
  95.     }
  96.     return CallLocalFunction("OnPlayerCommandText","is",playerid,cmdtext);
  97. }
  98. #if defined _ALS_OnPlayerCommandText
  99.     #undef OnPlayerCommandText
  100. #else
  101.     #define _ALS_OnPlayerCommandText
  102. #endif
  103. #define OnPlayerCommandText _OnPlayerCommandText
  104. public OnGameModeInit()
  105. {
  106.     for(new v; v<MAX_VEHICLES; v++) c_Tank[v] = 100;
  107.     SetTimer("Global_Tank", 1000*VERBRENNEN, 1);
  108.     return CallLocalFunction("OnGameModeInit","");
  109. }
  110. #if defined _ALS_OnGameModeInit
  111.     #undef OnGameModeInit
  112. #else
  113.     #define _ALS_OnGameModeInit
  114. #endif
  115. #define OnGameModeInit _OnGameModeInit
  116. public Global_Tank()
  117. {
  118.     new v,engine,lights,alarm,doors,bonnet,boot,objective,i;
  119.     for(; v<MAX_VEHICLES; v++) {
  120.     GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
  121.     if(!engine) continue;
  122.     if(c_Tank[v] == 0) {
  123.     SetVehicleParamsEx(v,0,lights,alarm,doors,bonnet,boot,objective);
  124.     for(; i<MAX_PLAYERS; i++) {
  125.     if(!IsPlayerConnected(i) || GetPlayerVehicleID(i) != v) continue;
  126.     CallRemoteFunction("OnVehicleEmpty", "i", i); break; } } continue;
  127.     c_Tank[v]--; }
  128.     return 1;
  129. }
  130. forward OnPlayerTank(playerid,liter);
  131. forward OnVehicleEmpty(playerid);
Advertisement
Add Comment
Please, Sign In to add comment