Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Vehicles ordered alphabetically
- new VehiclesSorted[][] =
- {
- "Admiral","Alpha","Ambulance","Andromada","AT-400","Baggage","Bandito",
- "Banshee","Barracks","Beagle","Benson","Berkley's RC_Van","BF_Injection",
- "BF-400","Bike","Blade","Blista Compact","Bloodring_Banger","BMX","Bobcat",
- "Boxville","Bravura","Broadway","Buccaneer","Buffalo","Bullet","Burrito",
- "Bus","Cabbie","Caddy","Cadrona","Camper","Cargobob","Cement_Truck",
- "Cheetah","Clover","Club","Coach","Coastguard","Combine","Comet","Cropduster",
- "DFT-30","Dinghy","Dodo","Dozer","Dumper","Dune","Elegant","Elegy","Emperor",
- "Enforcer","Esperanto","Euros","Faggio","FBI_Rancher","FBI_Truck","FCR-900",
- "Feltzer","Firetruck_Ladder","Firetruck","Flash","Flatbed","Forklift",
- "Fortune","Freeway","Freight_Box","Freight_Flat","Freight",
- "Glendale","Greenwood","Hermes","Hotdog","Hotknife","Hotring_Racer_A",
- "Hotring_Racer_B","Hotring","HPV1000","Hunter","Huntley","Hustler","Hydra",
- "Infernus","Intruder","Jester","Jetmax","Journey","Kart","Landstalker",
- "Launch","Leviathan","Linerunner","Majestic","Manana","Marquis","Maverick",
- "Merit","Mesa","Monster_A","Monster_B","Moonbeam","Mountain_Bike","Mower",
- "Mule","Nebula","Nevada","News_Chopper","News_Van","NRG-500","Oceanic",
- "Packer","Patriot","PCJ-600","Perenniel","Phoenix","Picador","Pizzaboy",
- "Police_LS","Police_LV","Police_Maverick","Police_Ranger","Police_SF","Pony",
- "Predator","Premier","Previon","Primo","Quad","Raindance","Rancher",
- "RC_Bandit","RC_Baron","RC_Cam","RC_Goblin","RC_Raider","RC_Tiger","Reefer",
- "Regina","Remington","Rhino","Roadtrain","Romero","Rumpo","Rustler","S.W.A.T",
- "Sabre","Sadler","Sanchez","Sandking","Savanna","Seasparrow",
- "Securicar","Sentinel","Shamal","Skimmer","Slamvan","Solair","Sparrow",
- "Speeder","Squallo","Stafford","Stairs","Stallion","Stratum",
- "Stretch","Stunt","Sultan","Sunrise","Super_GT","Sweeper","Tahoma",
- "Tampa","Tanker","Taxi","Tiller","Tornado","Towtruck","Tractor","Trailer",
- "Trashmaster","Tropic","Tug","Turismo","Uranus","Utility_Trailer",
- "Utility_van","Vincent","Virgo","Voodoo","Vortex","Walton","Washington","Wayfarer",
- "Whoopee","Willard","Windsor","Yankee","Yosemite","ZR-350"
- };
- //This list of id's maps to the above list of ordered vehicles
- new VehiclesSortedIDs[] =
- {
- 445, 602, 416, 592, 577, 485, 568, 429,
- 433, 511, 499, 459, 424, 581, 509,
- 536, 496, 504, 481, 422, 498,
- 401, 575, 518, 402, 541, 482, 431, 438, 457,
- 527, 483, 548, 524, 415, 542, 589, 437,
- 472, 532, 480, 512, 578, 473, 593, 486, 406,
- 573, 507, 562, 585, 427, 419, 587, 462,
- 490, 528, 521, 533, 407, 544, 565,
- 455, 530, 526, 463, 590, 569, 537,
- 466, 492, 474, 588, 434, 494,
- 502, 503, 523, 425, 579, 545, 520, 411,
- 546, 559, 493, 508, 571, 400, 595, 417,
- 403, 517, 410, 484, 487, 551,
- 500, 556, 557, 418, 510, 572, 414,
- 516, 553, 488, 582, 522, 467, 443, 470,
- 461, 404, 603, 600, 448, 596, 598,
- 497, 599, 597, 413,
- 430, 426, 436, 547, 471, 563, 489,
- 441, 464, 594, 501, 465, 564, 453,
- 479, 534, 432, 515, 442, 440, 476, 601,
- 475, 543, 468, 495, 567, 447,
- 428, 405, 519, 460, 535, 458, 469,
- 452, 446, 580, 608, 439, 561,
- 409, 513, 560, 550, 506, 574, 566,
- 549, 514, 420, 610, 576, 525, 531, 435,
- 408, 454, 583, 451, 558, 611,
- 552, 540, 491, 412, 539, 478, 421, 586,
- 423, 529, 555, 456, 554, 477
- };
- //Search for vehicle ID using a binary search to reduce comparison count and increase efficiency
- //The two optional parameters are not needed when calling this function, they are used by the function itself when doing recursion
- SearchVehicleId(playerid, vehname[], index = -1, character = 0) {
- new suggestions[200];
- if(index == -1) {
- new low = 0; new high = 199; new mid;
- while(low <= high) {
- mid = (low + high)/2;
- if(toupper(VehiclesSorted[mid][0]) == toupper(vehname[0])) {
- index = mid;
- return SearchVehicleId(playerid,vehname,index,character++);
- }
- else {
- if(toupper(VehiclesSorted[mid][0]) > toupper(vehname[0])) {
- high = mid - 1;
- }
- if(toupper(VehiclesSorted[mid][0]) < toupper(vehname[0])) {
- low = mid + 1;
- }
- }
- }
- }
- else {
- if(toupper(VehiclesSorted[index][character]) > toupper(vehname[character])) {
- while(toupper(VehiclesSorted[index][character]) >= toupper(vehname[character]) && toupper(VehiclesSorted[index][0]) == toupper(vehname[0])) {
- if(strcmp(VehiclesSorted[index],vehname,true) == 0) return VehiclesSortedIDs[index];
- else index--;
- }
- }
- else if (toupper(VehiclesSorted[index][character]) < toupper(vehname[character])) {
- while(toupper(VehiclesSorted[index][character]) <= toupper(vehname[character]) && toupper(VehiclesSorted[index][0]) == toupper(vehname[0])) {
- if(strcmp(VehiclesSorted[index],vehname,true) == 0) return VehiclesSortedIDs[index];
- else index++;
- }
- }
- else {
- if(strcmp(VehiclesSorted[index],vehname,true) == 0) return VehiclesSortedIDs[index];
- else return SearchVehicleId(playerid,vehname,index,(character + 1));
- }
- }
- format(suggestions, sizeof(suggestions),"%s, %s, %s, %s, %s",VehiclesSorted[(index - 2)], VehiclesSorted[(index - 1)], VehiclesSorted[index], VehiclesSorted[(index + 1)], VehiclesSorted[(index + 2)]);
- SendClientMessage(playerid, COLOR_RED, "Vehicle not found, Close matches:");
- SendClientMessage(playerid, COLOR_RED, suggestions);
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement