Guest User

Sandra

a guest
Sep 23rd, 2008
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.39 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //Remove this line here below if you want to disable the "/spawncar [name]" command.
  4. #define ENABLE_CARSPANW_COMMAND
  5.  
  6.  
  7. new VehicleNames[212][] =
  8. {
  9.    "Landstalker", "Bravura",   "Buffalo",   "Linerunner",   "Pereniel",   "Sentinel",   "Dumper",   "Firetruck",   "Trashmaster",   "Stretch",
  10.    "Manana",   "Infernus",   "Voodoo",   "Pony",   "Mule",   "Cheetah",   "Ambulance",   "Leviathan",   "Moonbeam",   "Esperanto",   "Taxi",
  11.    "Washington",   "Bobcat",   "Mr Whoopee",   "BF Injection",   "Hunter",   "Premier",   "Enforcer",   "Securicar",   "Banshee",   "Predator",
  12.    "Bus",   "Rhino",   "Barracks",   "Hotknife",   "Trailer",   "Previon",   "Coach",   "Cabbie",   "Stallion",   "Rumpo",   "RC Bandit",  "Romero",
  13.    "Packer",   "Monster",   "Admiral",   "Squalo",   "Seasparrow",   "Pizzaboy",   "Tram",   "Trailer",   "Turismo",   "Speeder",   "Reefer",   "Tropic",   "Flatbed",
  14.    "Yankee",   "Caddy",   "Solair",   "Berkley's RC Van",   "Skimmer",   "PCJ-600",   "Faggio",   "Freeway",   "RC Baron",   "RC Raider",
  15.    "Glendale",   "Oceanic",   "Sanchez",   "Sparrow",   "Patriot",   "Quad",   "Coastguard",   "Dinghy",   "Hermes",   "Sabre",   "Rustler",
  16.    "ZR350",   "Walton",   "Regina",   "Comet",   "BMX",   "Burrito",   "Camper",   "Marquis",   "Baggage",   "Dozer",   "Maverick",   "News Chopper",
  17.    "Rancher",   "FBI Rancher",   "Virgo",   "Greenwood",   "Jetmax",   "Hotring",   "Sandking",   "Blista Compact",   "Police Maverick",
  18.    "Boxville",   "Benson",   "Mesa",   "RC Goblin",   "Hotring Racer",   "Hotring Racer",   "Bloodring Banger",   "Rancher",   "Super GT",
  19.    "Elegant",   "Journey",   "Bike",   "Mountain Bike",   "Beagle",   "Cropdust",   "Stunt",   "Tanker",   "RoadTrain",   "Nebula",   "Majestic",
  20.    "Buccaneer",   "Shamal",   "Hydra",   "FCR-900",   "NRG-500",   "HPV1000",   "Cement Truck",   "Tow Truck",   "Fortune",   "Cadrona",   "FBI Truck",
  21.    "Willard",   "Forklift",   "Tractor",   "Combine",   "Feltzer",   "Remington",   "Slamvan",   "Blade",   "Freight",   "Streak",   "Vortex",   "Vincent",
  22.    "Bullet",   "Clover",   "Sadler",   "Firetruck",   "Hustler",   "Intruder",   "Primo",   "Cargobob",   "Tampa",   "Sunrise",   "Merit",   "Utility",
  23.    "Nevada",   "Yosemite",   "Windsor",   "Monster",   "Monster",   "Uranus",   "Jester",   "Sultan",   "Stratum",   "Elegy",   "Raindance",   "RC Tiger",
  24.    "Flash",   "Tahoma",   "Savanna",   "Bandito",   "Freight",   "Trailer",   "Kart",   "Mower",   "Duneride",   "Sweeper",   "Broadway",
  25.    "Tornado",   "AT-400",   "DFT-30",   "Huntley",   "Stafford",   "BF-400",   "Newsvan",   "Tug",   "Trailer",   "Emperor",   "Wayfarer",
  26.    "Euros",   "Hotdog",   "Club",   "Trailer",   "Trailer",   "Andromada",   "Dodo",   "RC Cam",   "Launch",   "Police Car (LSPD)",   "Police Car (SFPD)",
  27.    "Police Car (LVPD)",   "Police Ranger",   "Picador",   "S.W.A.T. Van",   "Alpha",   "Phoenix",   "Glendale",   "Sadler",   "Luggage Trailer",
  28.    "Luggage Trailer",   "Stair Trailer",   "Boxville",   "Farm Plow",   "Utility Trailer"
  29. };
  30.  
  31. public OnFilterScriptInit()
  32. {
  33.     print("--------------------------------------");
  34.     print(" Vehicle Library Filterscript Loaded! ");
  35.     print("--------------------------------------");
  36.     return 1;
  37. }
  38.  
  39. public OnFilterScriptExit()
  40. {
  41.     print("----------------------------------------");
  42.     print(" Vehicle Library Filterscript Unloaded! ");
  43.     print("----------------------------------------");
  44.     return 1;
  45. }
  46.  
  47.  
  48. public OnPlayerCommandText(playerid, cmdtext[])
  49. {
  50.     new cmd[256], tmp[256], index;
  51.     cmd = strtok(cmdtext, index);
  52.     if (strcmp("/searchvehicle", cmd, true) == 0 || strcmp("/sv", cmd, true) == 0)
  53.     {
  54.         new results, string[128];
  55.         tmp = strtok(cmdtext, index);
  56.         if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFBB00AA, "Usage: /searchvehicle [part of name] of /sv [part of name]");
  57.         format(string, sizeof(string), "Searching for vehicles containing \"%s\"....", tmp);
  58.         SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
  59.         SendClientMessage(playerid, 0xCCCC00AA, string);
  60.         for(new i; i<212; i++)
  61.         {
  62.             if(strfind(VehicleNames[i], tmp, true) != -1)
  63.             {
  64.                 if(results == 0)
  65.                 {
  66.                     format(string, sizeof(string), "%s", VehicleNames[i]);
  67.                 }
  68.                 else
  69.                 {
  70.                     format(string, sizeof(string), "%s, %s", string, VehicleNames[i]);
  71.                 }
  72.                 results++;
  73.                 if(strlen(string) > 118)
  74.                 {
  75.                    SendClientMessage(playerid, 0xFFBB00AA, "Too many results found! Please search more specified!");
  76.                    SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
  77.                    return 1;
  78.                 }
  79.             }
  80.         }
  81.         if(results == 0)
  82.         {
  83.             SendClientMessage(playerid, 0xFFBB00AA, "Sorry, no vehicles found.");
  84.             SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
  85.             return 1;
  86.         }
  87.         SendClientMessage(playerid, 0xCCCC00AA, "Results:");
  88.         SendClientMessage(playerid, 0xFFFF00AA, string);
  89.         SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
  90.         return 1;
  91.     }
  92.     #if defined ENABLE_CARSPANW_COMMAND
  93.     if (strcmp("/spawnvehicle", cmd, true) == 0)
  94.     {
  95.         new carfound, Float:X, Float:Y, Float:Z, Float:A, vid;
  96.         tmp = strtok(cmdtext, index);
  97.         if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFBB00AA, "Usage: /spawnvehicle [name]");
  98.         for(new i; i<212; i++)
  99.         {
  100.             if(strcmp(VehicleNames[i], tmp, true)==0)
  101.             {
  102.                 carfound = 1;
  103.                 GetPlayerPos(playerid, X, Y, Z);
  104.                 GetPlayerFacingAngle(playerid, A);
  105.                 vid = CreateVehicle(i+400, X, Y, Z, A, -1, -1, 600000);
  106.                 PutPlayerInVehicle(playerid, vid, 0);
  107.             }
  108.         }
  109.         if(carfound == 0)
  110.         {
  111.             new str[128];
  112.             format(str, sizeof(str), "Sorry, no vehicle found matching the name \"%s\"", tmp);
  113.             SendClientMessage(playerid, 0xFFBB00AA, str);
  114.             SendClientMessage(playerid, 0xFFBB00AA, "You can search for exact names in the VehicleLibrary using: /searchvehicle [part of name]");
  115.         }
  116.         return 1;
  117.     }
  118.     #endif
  119.     return 0;
  120. }
  121.  
  122. strtok(const string[], &index)
  123. {
  124.     new length = strlen(string);
  125.     while ((index < length) && (string[index] <= ' '))
  126.     {
  127.         index++;
  128.     }
  129.  
  130.     new offset = index;
  131.     new result[20];
  132.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  133.     {
  134.         result[index - offset] = string[index];
  135.         index++;
  136.     }
  137.     result[index - offset] = EOS;
  138.     return result;
  139. }
  140.  
Advertisement
Add Comment
Please, Sign In to add comment