Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //Remove this line here below if you want to disable the "/spawncar [name]" command.
- #define ENABLE_CARSPANW_COMMAND
- new VehicleNames[212][] =
- {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch",
- "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi",
- "Washington", "Bobcat", "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator",
- "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero",
- "Packer", "Monster", "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed",
- "Yankee", "Caddy", "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider",
- "Glendale", "Oceanic", "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler",
- "ZR350", "Walton", "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
- "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick",
- "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer", "Hotring Racer", "Bloodring Banger", "Rancher", "Super GT",
- "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropdust", "Stunt", "Tanker", "RoadTrain", "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", "Vincent",
- "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility",
- "Nevada", "Yosemite", "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger",
- "Flash", "Tahoma", "Savanna", "Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway",
- "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer",
- "Euros", "Hotdog", "Club", "Trailer", "Trailer", "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",
- "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
- };
- public OnFilterScriptInit()
- {
- print("--------------------------------------");
- print(" Vehicle Library Filterscript Loaded! ");
- print("--------------------------------------");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("----------------------------------------");
- print(" Vehicle Library Filterscript Unloaded! ");
- print("----------------------------------------");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], tmp[256], index;
- cmd = strtok(cmdtext, index);
- if (strcmp("/searchvehicle", cmd, true) == 0 || strcmp("/sv", cmd, true) == 0)
- {
- new results, string[128];
- tmp = strtok(cmdtext, index);
- if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFBB00AA, "Usage: /searchvehicle [part of name] of /sv [part of name]");
- format(string, sizeof(string), "Searching for vehicles containing \"%s\"....", tmp);
- SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
- SendClientMessage(playerid, 0xCCCC00AA, string);
- for(new i; i<212; i++)
- {
- if(strfind(VehicleNames[i], tmp, true) != -1)
- {
- if(results == 0)
- {
- format(string, sizeof(string), "%s", VehicleNames[i]);
- }
- else
- {
- format(string, sizeof(string), "%s, %s", string, VehicleNames[i]);
- }
- results++;
- if(strlen(string) > 118)
- {
- SendClientMessage(playerid, 0xFFBB00AA, "Too many results found! Please search more specified!");
- SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
- return 1;
- }
- }
- }
- if(results == 0)
- {
- SendClientMessage(playerid, 0xFFBB00AA, "Sorry, no vehicles found.");
- SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
- return 1;
- }
- SendClientMessage(playerid, 0xCCCC00AA, "Results:");
- SendClientMessage(playerid, 0xFFFF00AA, string);
- SendClientMessage(playerid, 0xCCCC00AA, "=================================================");
- return 1;
- }
- #if defined ENABLE_CARSPANW_COMMAND
- if (strcmp("/spawnvehicle", cmd, true) == 0)
- {
- new carfound, Float:X, Float:Y, Float:Z, Float:A, vid;
- tmp = strtok(cmdtext, index);
- if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFBB00AA, "Usage: /spawnvehicle [name]");
- for(new i; i<212; i++)
- {
- if(strcmp(VehicleNames[i], tmp, true)==0)
- {
- carfound = 1;
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, A);
- vid = CreateVehicle(i+400, X, Y, Z, A, -1, -1, 600000);
- PutPlayerInVehicle(playerid, vid, 0);
- }
- }
- if(carfound == 0)
- {
- new str[128];
- format(str, sizeof(str), "Sorry, no vehicle found matching the name \"%s\"", tmp);
- SendClientMessage(playerid, 0xFFBB00AA, str);
- SendClientMessage(playerid, 0xFFBB00AA, "You can search for exact names in the VehicleLibrary using: /searchvehicle [part of name]");
- }
- return 1;
- }
- #endif
- return 0;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment