Advertisement
Shiny_

PSD

Sep 19th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.36 KB | None | 0 0
  1. // Includes:
  2.     #include <a_samp>
  3.     #include <YSI\y_iterate>
  4.     #include <zcmd>
  5.  
  6. // Macros:
  7.     #define function%0(%1)                          \
  8.             forward %0(%1);                         \
  9.             public %0(%1)
  10.    
  11. // Variables:
  12.     new bool: Commanded[MAX_VEHICLES];
  13.     new gVehicleNames[212][] = {
  14.         "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
  15.         "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat",
  16.         "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks",
  17.         "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  18.         "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy",
  19.         "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Harley", "RC Baron", "RC Raider", "Glendale", "Oceanic",
  20.         "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "Walton", "Regina",
  21.         "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher",
  22.         "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa",
  23.         "RC Goblin", "Hotring Racer", "Hotring Racer", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike",
  24.         "Mountain Bike", "Beagle", "Cropdust", "Stunt", "Tanker", "RoadTrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  25.         "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Traktor",
  26.         "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
  27.         "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor",
  28.         "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
  29.         "Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
  30.         "Stafford", "BF-400", "Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer",
  31.         "Andromeda", "Dodo", "RC Cam", "Launch", "Radiowoz", "Radiowoz", "Radiowoz", "Radiowoz", "Picador", "S.W.A.T. Van",
  32.         "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
  33.     };
  34.    
  35. // Static functions:
  36.     stock RespawnUnusedVehicles() {
  37.         new UsedVeh[MAX_VEHICLES] = {false, ...};
  38.         foreach(new playerid: Player) {
  39.             UsedVeh[GetPlayerVehicleID(playerid)] = true;
  40.         }
  41.        
  42.         for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++) {
  43.             if(UsedVeh[vehicleid]) continue;
  44.             else if(Commanded[vehicleid]) return DestroyVehicle(vehicleid), Commanded[vehicleid] = false;
  45.             SetVehicleToRespawn(vehicleid);
  46.         }
  47.         return true;
  48.     }
  49.  
  50.     stock CreatePlayerVehicle(playerid, modelid) {
  51.         new vehicle;
  52.         new Float: Position[4];
  53.         if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  54.             vehicle = GetPlayerVehicleID(playerid);
  55.             GetVehiclePos(vehicle, Position[0], Position[1], Position[2]);
  56.             GetVehicleZAngle(vehicle, Position[3]);
  57.             DestroyVehicle(vehicle);
  58.         } else {
  59.             GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  60.             GetPlayerFacingAngle(playerid, Position[3]);
  61.         }
  62.         vehicle = AddStaticVehicle(modelid, Position[0], Position[1], Position[2] + 1, Position[3], -1, -1);
  63.         LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
  64.         SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
  65.         SetVehicleNumberPlate(vehicle, PlayerName(playerid));
  66.         PutPlayerInVehicle(playerid, vehicle, 0);
  67.         Commanded[vehicle] = true;
  68.         return true;
  69.     }
  70.    
  71.     stock GetVehicleModelIDByName(vehiclename[]) {
  72.         for(new i = 0; i < 211; i++) {
  73.             if(strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
  74.         }
  75.         return -1;
  76.     }
  77.    
  78.     stock delete_free_space(string[], character = ' ') {
  79.         new len = strlen(string);
  80.         if(len) {
  81.             new begin = -1, end = len;
  82.             while(string[++begin] == character) {}
  83.             if(string[begin] == EOS) {
  84.                 string[0] = false;
  85.                 return true;
  86.             }
  87.             while(string[--end] == character) {}
  88.             strmid(string, string, begin, end + 1, len + 1);
  89.         }
  90.         return true;
  91.     }
  92.    
  93.     stock PlayerName(playerid) {
  94.         new Name[MAX_PLAYER_NAME];
  95.         GetPlayerName(playerid, Name, sizeof(Name));
  96.         return Name;
  97.     }
  98.     stock SpawnVehicle_InfrontOfPlayer2(playerid, vehiclemodel, color1, color2) {
  99.         new Float:x, Float:y, Float:z;
  100.         new Float:facing;
  101.         new Float:distance;
  102.        
  103.         GetPlayerPos(playerid, x, y, z);
  104.         GetPlayerFacingAngle(playerid, facing);
  105.        
  106.         new Float:size_x, Float:size_y, Float:size_z;
  107.         GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
  108.        
  109.         distance = size_x + 0.5;
  110.         x += (distance * floatsin(-facing, degrees));
  111.         y += (distance * floatcos(-facing, degrees));
  112.        
  113.         facing += 90.0;
  114.         if(facing > 360.0) facing -= 360.0;
  115.         return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
  116.     }
  117.    
  118. // Dynamic functions:  
  119.     function RespawnVehicles(vehicleid) {
  120.         RespawnUnusedVehicles();
  121.         SendClientMessageToAll(-1, "Auta stworzone za pomocą komendy /v zostały usunięte!");
  122.         return true;
  123.     }
  124.    
  125. // Public functions:
  126.     main() {
  127.         SetTimer("RespawnVehicles", 15 * 60 * 1000, true);
  128.         return false;
  129.     }
  130.    
  131.     public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
  132.         new text[100];
  133.         if(!success) {
  134.             for(new veh; veh < sizeof(gVehicleNames); veh++) {
  135.                 if(strlen(cmdtext) > 2 && !strcmp(cmdtext[1], gVehicleNames[veh], true)) {
  136.                     new c_veh_model = veh + 400, message[128];
  137.                     new Float:f[3] = {0.0, 0.0, 0.0};
  138.                    
  139.                     if(IsPlayerInAnyVehicle(playerid)) {
  140.                         new local_vehid = GetPlayerVehicleID(playerid);
  141.                         GetVehicleVelocity(GetPlayerVehicleID(playerid), f[0], f[1], f[2]);
  142.                         DestroyVehicle(local_vehid);
  143.                     }
  144.                    
  145.                     new local_vehid = CreatePlayerVehicle(playerid, c_veh_model);
  146.                     PutPlayerInVehicle(playerid, local_vehid, 0);
  147.                     SetVehicleVelocity(local_vehid, f[0], f[1], f[2]);
  148.                    
  149.                     format(message, sizeof(message), "Tworzysz pojazd o nazwie \"%s\".", gVehicleNames[veh]);
  150.                     SendClientMessage(playerid, 0x99FF00AA, message);
  151.                     return true;
  152.                 }
  153.             }
  154.         }
  155.         format(text, sizeof(text), "Na serwerze nie ma takiej komendy jak %s!", cmdtext), SendClientMessage(playerid, -1, text);
  156.         printf("%s wpisuje komendę: %s", PlayerName(playerid), cmdtext);
  157.         return true;
  158.     }
  159.  
  160. // Commands:
  161.     CMD:v(playerid, params[]) {
  162.         delete_free_space(params);
  163.         if(isnull(params)) return SendClientMessage(playerid, -1, "Wpisz /v nazwa_pojazdu");
  164.         else if(GetVehicleModelIDByName(params) != -1) CreatePlayerVehicle(playerid, GetVehicleModelIDByName(params));
  165.         else return SendClientMessage(playerid, -1, "Zła nazwa pojazdu!");
  166.         return true;
  167.     }
  168.    
  169.     CMD:respawn(playerid) {
  170.         (!IsPlayerAdmin(playerid)? SendClientMessage(playerid, -1, "Tą komendę może wpisać tylko Administrator!"): SendClientMessage(playerid, -1, "Auta stworzone za pomocą komendy /v zostały usunięte!"),
  171.         RespawnUnusedVehicles());
  172.         return true;
  173.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement