Advertisement
System32

S32_Speedo

Dec 2nd, 2011
1,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.86 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_commands>
  3.  
  4. #define COLOR_KRED                                              0xFF0000FF
  5. #define COLOR_YELLOW                                            0xFFFF00AA
  6.  
  7. forward RefuelVehicle(playerid);
  8. forward FuelLower();
  9.  
  10. new Fuel[MAX_VEHICLES], bool: IsRefuelling[MAX_PLAYERS] = false, FuelPrice = 0;
  11. new Text: sName[MAX_PLAYERS], Text: sSpeed[MAX_PLAYERS], Text: sState[MAX_PLAYERS], Text: sHealth[MAX_PLAYERS], Text: sFuel[MAX_PLAYERS];
  12.  
  13. new Vehicles[212][]=
  14. {
  15. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"}, {"Dumper"},{"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},
  16. {"Washington"},{"Bobcat"},{"Mr. Whoopee"},{"BF. Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},{"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Article Trailer"},{"Previon"},{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  17. {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Article Trailer 2"},{"Turismo"},{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},{"Sanchez"},
  18. {"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"},
  19. {"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},{"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},{"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},{"Tanker"},{"Roadtrain"},
  20. {"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"},
  21. {"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},{"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},
  22. {"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},{"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Dunerider"},{"Sweeper"},{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},{"Tug"},{"Article Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Mobile Hotdog"},
  23. {"Club"},{"Freight Carriage"},{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},{"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T Van"},{"Alpha"},{"Phoenix"},{"Glendale"},{"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},
  24. {"Boxville"},{"Farm Plow"},{"Utility Trailer"}
  25. };
  26.  
  27. public OnFilterScriptInit()
  28. {
  29.     print("\n");
  30.     print("  \4\4\4\4\4\4\4\4\4\4\4\4\4\4");
  31.     print("  \4 S32_Speedo \4");
  32.     print("  \4 by         \4");
  33.     print("  \4 System32   \4");
  34.     print("  \4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
  35.    
  36.     for(new v = 0; v < MAX_VEHICLES; v++) Fuel[v] = 100;
  37.     SetTimer("FuelLower", 20000, 1);
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43.     sName[playerid] = TextDrawCreate(561.000000, 266.000000, "Name");
  44.     TextDrawAlignment(sName[playerid], 2);
  45.     TextDrawBackgroundColor(sName[playerid], 255);
  46.     TextDrawFont(sName[playerid], 2);
  47.     TextDrawLetterSize(sName[playerid], 0.500000, 1.000000);
  48.     TextDrawColor(sName[playerid], -1);
  49.     TextDrawSetOutline(sName[playerid], 0);
  50.     TextDrawSetProportional(sName[playerid], 1);
  51.     TextDrawSetShadow(sName[playerid], 1);
  52.  
  53.     sSpeed[playerid] = TextDrawCreate(561.000000, 280.000000, "0 KM/H");
  54.     TextDrawAlignment(sSpeed[playerid], 2);
  55.     TextDrawBackgroundColor(sSpeed[playerid], 255);
  56.     TextDrawFont(sSpeed[playerid], 1);
  57.     TextDrawLetterSize(sSpeed[playerid], 0.500000, 1.000000);
  58.     TextDrawColor(sSpeed[playerid], 16711935);
  59.     TextDrawSetOutline(sSpeed[playerid], 0);
  60.     TextDrawSetProportional(sSpeed[playerid], 1);
  61.     TextDrawSetShadow(sSpeed[playerid], 1);
  62.  
  63.     sState[playerid] = TextDrawCreate(539.000000, 295.000000, "~r~R N D");
  64.     TextDrawBackgroundColor(sState[playerid], 255);
  65.     TextDrawFont(sState[playerid], 1);
  66.     TextDrawLetterSize(sState[playerid], 0.500000, 1.000000);
  67.     TextDrawColor(sState[playerid], -1);
  68.     TextDrawSetOutline(sState[playerid], 0);
  69.     TextDrawSetProportional(sState[playerid], 1);
  70.     TextDrawSetShadow(sState[playerid], 1);
  71.  
  72.     sHealth[playerid] = TextDrawCreate(537.000000, 309.000000, "~g~| | |");
  73.     TextDrawBackgroundColor(sHealth[playerid], 255);
  74.     TextDrawFont(sHealth[playerid], 1);
  75.     TextDrawLetterSize(sHealth[playerid], 0.640000, 1.999999);
  76.     TextDrawColor(sHealth[playerid], -1);
  77.     TextDrawSetOutline(sHealth[playerid], 1);
  78.     TextDrawSetProportional(sHealth[playerid], 1);
  79.    
  80.     sFuel[playerid] = TextDrawCreate(565.000000, 324.000000, ".");
  81.     TextDrawAlignment(sFuel[playerid], 2);
  82.     TextDrawBackgroundColor(sFuel[playerid], 255);
  83.     TextDrawFont(sFuel[playerid], 1);
  84.     TextDrawLetterSize(sFuel[playerid], 0.500000, 1.000000);
  85.     TextDrawColor(sFuel[playerid], -1);
  86.     TextDrawSetOutline(sFuel[playerid], 0);
  87.     TextDrawSetProportional(sFuel[playerid], 1);
  88.     TextDrawSetShadow(sFuel[playerid], 1);
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerDisconnect(playerid, reason)
  93. {
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerStateChange(playerid, newstate, oldstate)
  98. {
  99.     new string[128], sname[50];
  100.     if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, sName[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, sName[playerid]), format(sname, sizeof(sname), "%s", Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]), TextDrawSetString(sName[playerid], sname);
  101.     if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, sSpeed[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, sSpeed[playerid]);
  102.     if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, sState[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, sState[playerid]);
  103.     if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, sHealth[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, sHealth[playerid]);
  104.     if(oldstate-1 && newstate) TextDrawHideForPlayer(playerid, sFuel[playerid]); else if(newstate-1) TextDrawShowForPlayer(playerid, sFuel[playerid]), format(string, sizeof(string), "%d", Fuel[GetPlayerVehicleID(playerid)]), TextDrawSetString(sFuel[playerid], string);
  105.     return 1;
  106. }
  107.  
  108. public OnPlayerUpdate(playerid)
  109. {
  110.     if(IsPlayerInAnyVehicle(playerid))
  111.     {
  112.         // Vehicle speed
  113.         new sspeed[16];
  114.         format(sspeed, sizeof(sspeed), "%d KM/H", GetSpeed(playerid));
  115.         TextDrawSetString(sSpeed[playerid], sspeed);
  116.        
  117.         // Vehicle state
  118.         new Float: Pos[4];
  119.         GetVehicleVelocity(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
  120.        
  121.         new keys, ud, lr;
  122.         GetPlayerKeys(playerid, keys, ud, lr);
  123.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  124.         {
  125.             if(keys == KEY_JUMP) TextDrawSetString(sState[playerid], "~w~R ~r~N D");
  126.             else if(keys == KEY_SPRINT) TextDrawSetString(sState[playerid], "~r~R N ~w~D");
  127.             if(Pos[0] == 0.0 && Pos[1] == 0.0 && Pos[2] == 0.0) TextDrawSetString(sState[playerid], "~r~R ~w~N ~r~D");
  128.         }
  129.        
  130.         // Vehicle health
  131.         new Float: vHealth;
  132.         GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
  133.  
  134.         if(vHealth > 700) TextDrawSetString(sHealth[playerid], "~g~| | |");
  135.         if(vHealth < 700) TextDrawSetString(sHealth[playerid], "~r~| ~g~| |");
  136.         if(vHealth < 400) TextDrawSetString(sHealth[playerid], "~r~| | ~g~|");
  137.         if(vHealth < 250) TextDrawSetString(sHealth[playerid], "~r~| | |");
  138.     }
  139.     return 1;
  140. }
  141.  
  142. YCMD:refuel(playerid, params[], help)
  143. {
  144.     #pragma unused help
  145.     #pragma unused params
  146.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_KRED, "You are not in an vehicle!");
  147.     if(IsRefuelling[playerid] == true) return SendClientMessage(playerid, COLOR_KRED, "You are already refueling!");
  148.     if(Fuel[GetPlayerVehicleID(playerid)] > 90) FuelPrice = 500;
  149.     if(Fuel[GetPlayerVehicleID(playerid)] > 80 && Fuel[GetPlayerVehicleID(playerid)] < 90) FuelPrice = 450;
  150.     if(Fuel[GetPlayerVehicleID(playerid)] > 70 && Fuel[GetPlayerVehicleID(playerid)] < 80) FuelPrice = 400;
  151.     if(Fuel[GetPlayerVehicleID(playerid)] > 60 && Fuel[GetPlayerVehicleID(playerid)] < 70) FuelPrice = 350;
  152.     if(Fuel[GetPlayerVehicleID(playerid)] > 50 && Fuel[GetPlayerVehicleID(playerid)] < 60) FuelPrice = 300;
  153.     if(Fuel[GetPlayerVehicleID(playerid)] > 40 && Fuel[GetPlayerVehicleID(playerid)] < 50) FuelPrice = 250;
  154.     if(Fuel[GetPlayerVehicleID(playerid)] > 30 && Fuel[GetPlayerVehicleID(playerid)] < 40) FuelPrice = 200;
  155.     if(Fuel[GetPlayerVehicleID(playerid)] > 20 && Fuel[GetPlayerVehicleID(playerid)] < 30) FuelPrice = 150;
  156.     if(Fuel[GetPlayerVehicleID(playerid)] > 10 && Fuel[GetPlayerVehicleID(playerid)] < 20) FuelPrice = 100;
  157.     if(Fuel[GetPlayerVehicleID(playerid)] < 10) FuelPrice = 50;
  158.     if(GetPlayerMoney(playerid) < FuelPrice) return SendClientMessage(playerid, COLOR_KRED, "You don't have enough money!");
  159.     IsRefuelling[playerid] = true;
  160.     SetCameraBehindPlayer(playerid);
  161.     TogglePlayerControllable(playerid, 0);
  162.     GameTextForPlayer(playerid, "Refuelling...", 1000, 5);
  163.     SetTimerEx("RefuelVehicle", 5000, 0, "d", playerid);
  164.     return 1;
  165. }
  166.  
  167. public RefuelVehicle(playerid)
  168. {
  169.     new string[128];
  170.     Fuel[GetPlayerVehicleID(playerid)] = Fuel[GetPlayerVehicleID(playerid)] = 100;
  171.     IsRefuelling[playerid] = false;
  172.     GivePlayerMoney(playerid, -FuelPrice);
  173.     TogglePlayerControllable(playerid, 1);
  174.     format(string, sizeof(string), "Your vehicle is refuel! You paid $%d!", FuelPrice);
  175.     SendClientMessage(playerid, COLOR_YELLOW, string);
  176.     FuelPrice = 0;
  177.     return 1;
  178. }
  179.  
  180. public FuelLower()
  181. {
  182.     for(new i = 0; i < MAX_PLAYERS; i++)
  183.     {
  184.         if(!IsPlayerConnected(i)) continue;
  185.         if(IsRefuelling[i]) continue;
  186.         if(GetPlayerVehicleSeat(i) == 0)
  187.         {
  188.             Fuel[GetPlayerVehicleID(i)] = Fuel[GetPlayerVehicleID(i)] - 1;
  189.             if(Fuel[GetPlayerVehicleID(i)] < 1)
  190.             {
  191.                 Fuel[GetPlayerVehicleID(i)] = 0;
  192.                 RemovePlayerFromVehicle(i);
  193.                 GameTextForPlayer(i, "~r~Vehicle is out of ~w~fuel~r~!", 5000, 5);
  194.             }
  195.         }
  196.         new string[128];
  197.         format(string, sizeof(string), "%d", Fuel[GetPlayerVehicleID(i)]);
  198.         TextDrawSetString(sFuel[i], string);
  199.     }
  200.     return 1;
  201. }
  202.  
  203. stock GetSpeed(playerid)
  204. {
  205.     new Float: Pos[4];
  206.     GetVehicleVelocity(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
  207.     return floatround(1.61 * floatsqroot(floatabs(floatpower(Pos[0] + Pos[1] + Pos[2], 2))) * 100);
  208. }
  209.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement