Advertisement
Shiny_

Untitled

Aug 3rd, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.90 KB | None | 0 0
  1. // Biblioteki:
  2.     #include <a_samp>
  3.     #include <zcmd>
  4.  
  5. // Makra i constansy:
  6.     #define foreach(%1)         for(new %1; gPlayerIDs[%1] != INVALID_PLAYER_ID; %1++) if(IsPlayerConnected(%1))
  7.     #define function%0(%1)      forward%0(%1);      public%0(%1)
  8.     const RefreshTime = 150;
  9.  
  10. // Zmienne:
  11.     new
  12.         string[16],
  13.         PlayerText:licznik[MAX_PLAYERS],
  14.         Text:km,
  15.         gPlayerIDs[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...},
  16.         VehicleCmdNames[212][32] =
  17.         {
  18.             "/Landstalker", "/Bravura", "/Buffalo", "/Linerunner", "/Pereniel", "/Sentinel", "/Dumper", "/Firetruck", "/Trashmaster", "/Stretch",
  19.             "/Manana", "/Infernus", "/Voodoo", "/Pony", "/Mule", "/Cheetah", "/Ambulance", "/Leviathan", "/Moonbeam", "/Esperanto",
  20.             "/Taxi", "/Washington", "/Bobcat", "/Mr Whoopee", "/BF Injection", "/Hunter", "/Premier", "/Enforcer", "/Securicar", "/Banshee",
  21.             "/Predator", "/Bus", "/Rhino", "/Barracks", "/Hotknife", "/Trailer", "/Previon", "/Coach", "/Cabbie", "/Stallion",
  22.             "/Rumpo", "/RC Bandit", "/Romero", "/Packer", "/Monster", "/Admiral", "/Squalo", "/Seasparrow", "/Pizzaboy", "/Tram",
  23.             "/Trailer", "/Turismo", "/Speeder", "/Reefer", "/Tropic", "/Flatbed", "/Yankee", "/Caddy", "/Solair", "/Berkley's RC Van",
  24.             "/Skimmer", "/PCJ-600", "/Faggio", "/Freeway", "/RC Baron", "/RC Raider", "/Glendale", "/Oceanic", "/Sanchez", "/Sparrow",
  25.             "/Patriot", "/Quad", "/Coastguard", "/Dinghy", "/Hermes", "/Sabre", "/Rustler", "/ZR 350", "/Walton", "/Regina",
  26.             "/Comet", "/BMX", "/Burrito", "/Camper", "/Marquis", "/Baggage", "/Dozer", "/Maverick", "/News Chopper", "/Rancher",
  27.             "/FBI Rancher", "/Virgo", "/Greenwood", "/Jetmax", "/Hotring", "/Sandking", "/Blista Compact", "/Police Maverick", "/Boxville", "/Benson",
  28.             "/Mesa", "/RC Goblin", "/Hotring Racer", "/Hotring Racer", "/Bloodring Banger", "/Rancher", "/Super GT", "/Elegant", "/Journey", "/Bike",
  29.             "/Mountain Bike", "/Beagle", "/Cropdust", "/Stunt", "/Tanker", "/RoadTrain", "/Nebula", "/Majestic", "/Buccaneer", "/Shamal",
  30.             "/Hydra", "/FCR", "/NRG", "/HPV1000", "/Cement Truck", "/Tow Truck", "/Fortune", "/Cadrona", "/FBI Truck", "/Willard",
  31.             "/Forklift", "/Tractor", "/Combine", "/Feltzer", "/Remington", "/Slamvan", "/Blade", "/Freight", "/Streak", "/Vortex",
  32.             "/Vincent", "/Bullet", "/Clover", "/Sadler", "/Firetruck", "/Hustler", "/Intruder", "/Primo", "/Cargobob", "/Tampa",
  33.             "/Sunrise", "/Merit", "/Utility", "/Nevada", "/Yosemite", "/Windsor", "/Monstera", "/Monsterb", "/Uranus", "/Jester",
  34.             "/Sultan", "/Stratum", "/Elegy", "/Raindance", "/RC Tiger", "/Flash", "/Tahoma", "/Savanna", "/Bandito", "/Freight",
  35.             "/Trailer", "/Kart", "/Mower", "/Duneride", "/Sweeper", "/Broadway", "/Tornado", "/AT-400", "/DFT-30", "/Huntley",
  36.             "/Stafford", "/BF-400", "/Newsvan", "/Tug", "/Trailer2", "/Emperor", "/Wayfarer", "/Euros", "/Hotdog", "/Club",
  37.             "/Trailer3", "/Trailer4", "/Andromeda", "/Dodo", "/RC Cam", "/Launch", "/Police Car (LSPD)", "/Police Car (SFPD)", "/Police Car (LVPD)", "/Police Ranger",
  38.             "/Picador", "/S.W.A.T. Van", "/Alpha", "/Phoenix", "/Glendale", "/Sadler", "/Luggage Trailer", "/Luggage Trailer2", "/Stair Trailer", "/Boxville",
  39.             "/Farm Plow", "/Utility Trailer"
  40.         }
  41.     ;
  42.  
  43. // Funkcje publiczne:
  44.     main();
  45.    
  46.     public OnGameModeInit()
  47.     {
  48.         km = TextDrawCreate(557.000000, 368.000000, "km/h");
  49.         TextDrawBackgroundColor(km, 255);
  50.         TextDrawFont(km, 3);
  51.         TextDrawLetterSize(km, 0.200000, 0.900000);
  52.         TextDrawColor(km, -1);
  53.         TextDrawSetOutline(km, 1);
  54.         TextDrawSetProportional(km, 1);
  55.         SetTimer("SpeedoMeter", 25, true); //RefreshTime / 2, true);
  56.         return true;
  57.     }
  58.    
  59.     public OnPlayerConnect(playerid)
  60.     {
  61.         licznik[playerid] = CreatePlayerTextDraw(playerid, 520.000000, 360.000000, "340");
  62.         PlayerTextDrawBackgroundColor(playerid, licznik[playerid], 255);
  63.         PlayerTextDrawFont(playerid, licznik[playerid], 3);
  64.         PlayerTextDrawLetterSize(playerid, licznik[playerid], 0.500000, 1.900000);
  65.         PlayerTextDrawColor(playerid, licznik[playerid], -1);
  66.         PlayerTextDrawSetOutline(playerid, licznik[playerid], 1);
  67.         PlayerTextDrawSetProportional(playerid, licznik[playerid], 1);
  68.         return true;
  69.     }
  70.  
  71.     public OnPlayerDisconnect(playerid, reason)
  72.     {
  73.         PlayerTextDrawDestroy(playerid, licznik[playerid]);
  74.         return true;
  75.     }
  76.  
  77.     public OnPlayerStateChange(playerid, newstate, oldstate)
  78.     {
  79.         switch(newstate)
  80.         {
  81.             case PLAYER_STATE_DRIVER:
  82.             {
  83.                 PlayerTextDrawShow(playerid, licznik[playerid]);
  84.                 TextDrawShowForPlayer(playerid, km);
  85.             }
  86.             case PLAYER_STATE_ONFOOT:
  87.             {
  88.                 if(oldstate == PLAYER_STATE_DRIVER)
  89.                 {
  90.                     PlayerTextDrawHide(playerid, licznik[playerid]);
  91.                     TextDrawHideForPlayer(playerid, km);
  92.                 }
  93.             }
  94.         }
  95.         return true;
  96.     }
  97.  
  98.     public OnPlayerCommandReceived(playerid, cmdtext[])
  99.     {
  100.         new
  101.             vid,
  102.             string2[64];
  103.        
  104.         for(new i = 0; i < sizeof(VehicleCmdNames); i++)
  105.         {
  106.             if(strfind(VehicleCmdNames[i], cmdtext, true) != -1)
  107.             {
  108.                 if(!IsPlayerAdmin(playerid))
  109.                 {
  110.                     switch(i+400)
  111.                     {
  112.                         case 425, 432, 441, 406, 449, 464, 465, 501, 520, 537, 538, 564, 569, 570, 590, 591, 594, 606 .. 608, 610, 611: return SendClientMessage(playerid, -1, "Tego pojazdu nie możesz stworzyć nie będąc administratorem!");
  113.                     }
  114.                 }
  115.                 vid = CreateVehicleEx(playerid, i + 400, -1, -1);
  116.                 LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
  117.                 SetVehicleVirtualWorld(vid, GetPlayerVirtualWorld(playerid));
  118.                 format(string2, sizeof(string2), "Tworzysz %s", VehicleCmdNames[i]);
  119.                 SendClientMessage(playerid, -1, string2);
  120.                 PutPlayerInVehicle(playerid, vid, 0);
  121.                 return false;
  122.             }
  123.         }
  124.         return true;
  125.     }
  126.    
  127.     public OnGameModeExit()
  128.     {
  129.         TextDrawDestroy(km);
  130.         printf("Serwer jest wyłączany!");
  131.         return true;
  132.     }
  133.  
  134. // Funkcje dynamiczne:
  135.     function SpeedoMeter()
  136.     {
  137.         foreach(i)
  138.         {
  139.             if(IsPlayerInAnyVehicle(i))
  140.             {
  141.                 format(string, sizeof string, "%d", GetPlayerSpeed(GetPlayerVehicleID(i)));
  142.                 PlayerTextDrawSetString(i, licznik[i], string);
  143.             }
  144.         }
  145.     }
  146.  
  147. // Funkcje statyczne:
  148.     stock GetPlayerSpeed(playerid)
  149.     {
  150.         new Float: ST[4];
  151.         if(IsPlayerInAnyVehicle(playerid))
  152.         GetVehicleVelocity(GetPlayerVehicleID(playerid), ST[0], ST[1], ST[2]);
  153.         else GetPlayerVelocity(playerid, ST[0], ST[1], ST[2]);
  154.         ST[3] = floatround(floatmul(floatmul(ST[0], ST[0]) + floatmul(ST[1], ST[1]) + floatmul(ST[2], ST[2]), 190.0));
  155.         return floatround(ST[3]);
  156.     }
  157.  
  158.     stock CreateVehicleEx(playerid, vehiclemodel, color1, color2)
  159.     {
  160.         new Float:x,Float:y,Float:z;
  161.         new Float:facing;
  162.         new Float:distance;
  163.        
  164.         GetPlayerPos(playerid, x, y, z);
  165.         GetPlayerFacingAngle(playerid, facing);
  166.        
  167.         new Float:size_x,Float:size_y,Float:size_z;
  168.         GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
  169.        
  170.         distance = size_x + 0.5;
  171.        
  172.         x += (distance * floatsin(- facing, degrees));
  173.         y += (distance * floatcos(- facing, degrees));
  174.        
  175.         facing += 90.0;
  176.         if(facing > 360.0) facing -= 360.0;
  177.        
  178.         return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
  179.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement