Advertisement
Guest User

Vehcile Spawn

a guest
Jun 18th, 2012
9,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.10 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4. #include <zcmd>
  5. #include <streamer>
  6. #include <sscanf2>
  7.  
  8. //Colorlist
  9. #define COLOR_GREY 0x808080FF
  10. #define COLOR_WHITE 0xFFFFFFFF
  11. #define COLOR_YELLOW 0xFFFF00FF
  12. #define COLOR_GREEN 0x088A08FF
  13.  
  14. //Forwards
  15. forward GetVehicleModelIDFromName(vname[]);
  16.  
  17. //Defines
  18.  
  19.  
  20. //PlayerInfo
  21. enum pInfo
  22. {
  23.  
  24.     bool:pCanSpawnVehicle,
  25.     pSpawnVehicle,
  26. }
  27.  
  28. //Client Variables
  29. new PlayerInfo[MAX_PLAYERS][pInfo];
  30.  
  31. //Server Variables
  32. new  Float:pX,
  33. Float:pY, Float:pZ, Float:pAngle;
  34.  
  35.  
  36.  
  37.  
  38.  
  39. new VehicleNames[212][] = {
  40. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
  41. {"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
  42. {"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
  43. {"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
  44. {"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
  45. {"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  46. {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
  47. {"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
  48. {"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  49. {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
  50. {"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
  51. {"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
  52. {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
  53. {"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
  54. {"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
  55. {"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
  56. {"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
  57. {"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
  58. {"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
  59. {"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
  60. {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
  61. {"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
  62. {"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
  63. {"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
  64. {"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
  65. {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  66. {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
  67. {"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
  68. {"Utility Trailer"}};
  69.  
  70. main()
  71. {
  72.     print("\n>Vehicle spawn!\n");
  73. }
  74.  
  75.  
  76. public GetVehicleModelIDFromName(vname[])
  77. {
  78.     for(new i = 0; i < 211; i++)
  79.     {
  80.         if ( strfind(VehicleNames[i], vname, true) != -1 )
  81.             return i + 400;
  82.     }
  83.     return -1;
  84. }
  85.  
  86. CMD:v(playerid, params[])
  87. {
  88.     new Vehicle[32], VehicleID, ColorOne, ColorTwo;
  89.     PlayerInfo[playerid][pCanSpawnVehicle] = true;
  90.     if(sscanf(params, "s[32]D(1)D(1)", Vehicle, ColorOne, ColorTwo))
  91.     {
  92.         PlayerInfo[playerid][pCanSpawnVehicle] = true;
  93.         SendClientMessage(playerid, COLOR_GREY, "[USAGE]: /v[Vehiclename/Vehicleid] [Color 1 (optional)] [Color 2 (optional)]");
  94.         SendClientMessage(playerid, COLOR_GREY, "[USAGE]: Like /v Turismo , /v Elegy /v Nrg /v 522");
  95.         return 1;
  96.     }
  97.    
  98.     if(PlayerInfo[playerid][pCanSpawnVehicle])
  99.     {
  100.         VehicleID = GetVehicleModelIDFromName(Vehicle);
  101.         if(VehicleID != 425 && VehicleID != 432 && VehicleID != 447 &&
  102.            VehicleID != 430 && VehicleID != 417 && VehicleID != 435 &&
  103.            VehicleID != 446 && VehicleID != 449 && VehicleID != 450 &&
  104.            VehicleID != 452 && VehicleID != 453 && VehicleID != 454 &&
  105.            VehicleID != 460 && VehicleID != 464 && VehicleID != 465 &&
  106.            VehicleID != 469 && VehicleID != 472 && VehicleID != 473 &&
  107.            VehicleID != 476 && VehicleID != 484 && VehicleID != 487 &&
  108.            VehicleID != 488 && VehicleID != 493 && VehicleID != 497 &&
  109.            VehicleID != 501 && VehicleID != 511 && VehicleID != 512 &&
  110.            VehicleID != 513 && VehicleID != 519 && VehicleID != 520 &&
  111.            VehicleID != 537 && VehicleID != 538 && VehicleID != 548 &&
  112.            VehicleID != 553 && VehicleID != 563 && VehicleID != 564 &&
  113.            VehicleID != 569 && VehicleID != 570 && VehicleID != 577 &&
  114.            VehicleID != 584 && VehicleID != 590 && VehicleID != 591 &&
  115.            VehicleID != 592 && VehicleID != 593 && VehicleID != 594 &&
  116.            VehicleID != 595 && VehicleID != 606 && VehicleID != 607 &&
  117.            VehicleID != 608 && VehicleID != 610 && VehicleID != 611) {
  118.             if(VehicleID == -1 )
  119.             {
  120.                 VehicleID = strval(Vehicle);
  121.  
  122.                 if(VehicleID < 400 || VehicleID > 611 )
  123.                 {
  124.                     return SendClientMessage(playerid, COLOR_GREY, "You entered an invalid vehiclename!");
  125.                 }
  126.             }
  127.  
  128.             GetPlayerPos(playerid, pX, pY, pZ);
  129.             GetPlayerFacingAngle(playerid, pAngle);
  130.  
  131.             DestroyVehicle(PlayerInfo[playerid][pSpawnVehicle]);
  132.             PlayerInfo[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX, pY, pZ+2.0, pAngle, ColorOne, ColorTwo, -1);
  133.             LinkVehicleToInterior(PlayerInfo[playerid][pSpawnVehicle], GetPlayerInterior(playerid));
  134.             PutPlayerInVehicle(playerid, PlayerInfo[playerid][pSpawnVehicle], 0);
  135.             SendClientMessage(playerid, COLOR_GREY, "You succesfully spawned this vehicle!");
  136.         } else {
  137.             SendClientMessage(playerid, COLOR_GREY, "You are not allowed to spawn this vehicle!!");
  138.         }
  139.     } else {
  140.         SendClientMessage(playerid, COLOR_GREY, "You can not spawn vehicles in this zone!");
  141.     }
  142.     return 1;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement