Advertisement
Guest User

JCSpawner V0.1

a guest
Jun 8th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.50 KB | None | 0 0
  1. /*
  2.        ___               _____             _        _      
  3.       |_  |             /  __ \           | |      (_)      
  4.         | | _____      _| /  \/ __ _ _ __ | |_ __ _ _ _ __  
  5.         | |/ _ \ \ /\ / / |    / _` | '_ \| __/ _` | | '_ \
  6.     /\__/ /  __/\ V  V /| \__/\ (_| | |_) | || (_| | | | | |
  7.     \____/ \___| \_/\_/  \____/\__,_| .__/ \__\__,_|_|_| |_|
  8.                                     | |                    
  9.                                     |_|                                
  10.     ==========================================================
  11.     JewCaptain's Vehicle Spawner:
  12.         Creation Date: 08/06/2012
  13.         Version: 0.1
  14.         -------------------------------
  15.         Copyrights:
  16.         -------------------------------
  17.             Created by JewCaptain (CptK as in SA-MP forums), for public server usage. All copyrights reserved ©.
  18.             You are NOT allowed to remove those credits.
  19.     ==========================================================
  20. */
  21.  
  22. //==========================================================
  23. #include <a_samp>
  24. //==========================================================
  25. #define VERSION "0.1"
  26.  
  27. // Change dialog ids if it interrupt with other dialog ids
  28. #define DIALOG_MSG 500 // Messages
  29. #define DIALOG_SPAWNER 501 // Main spawner menu
  30. #define DIALOG_SPAWNER_1 502 // By ID
  31. #define DIALOG_SPAWNER_2 503 // By name
  32. //==========================================================
  33. new VehNames[212][] = {
  34. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
  35. {"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
  36. {"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
  37. {"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
  38. {"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
  39. {"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  40. {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
  41. {"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
  42. {"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  43. {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
  44. {"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
  45. {"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
  46. {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
  47. {"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
  48. {"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
  49. {"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
  50. {"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
  51. {"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
  52. {"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
  53. {"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
  54. {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
  55. {"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
  56. {"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
  57. {"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
  58. {"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
  59. {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  60. {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
  61. {"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
  62. {"Utility Trailer"}
  63. };
  64. //==========================================================
  65. public OnFilterScriptInit()
  66. {
  67.     print("\n==========================================================");
  68.     print(" JewCaptain's Vehicle Spawner V"VERSION" has been successfully loaded.");
  69.     print("==========================================================\n");
  70.     return 1;
  71. }
  72. //==========================================================
  73. public OnPlayerCommandText(playerid, cmdtext[]) // Not using any command processor because there's no need for params, and it's a pretty basic script with just one command
  74. {
  75.     if (!strcmp(cmdtext, "/jcspawner", true))
  76.     {
  77.         if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You are not authorized to use this command!"); // Delete this line if you want all the players to be able to use the spawner
  78.         ShowPlayerDialog(playerid, DIALOG_SPAWNER, DIALOG_STYLE_LIST, "{FFFFFF}JC's Spawner", "{FFFFFF}By ID\nBy Name", "Select", "Cancel");
  79.         return 1;
  80.     }
  81.     return 0;
  82. }
  83. //==========================================================
  84. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  85. {
  86.     switch (dialogid)
  87.     {
  88.         case DIALOG_SPAWNER: // Main menu
  89.         {
  90.             if (response)
  91.             {
  92.                 if (listitem == 0) // By ID
  93.                     ShowPlayerDialog(playerid, DIALOG_SPAWNER_1, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FFFFFF}Type in a vehicle ID to spawn (400-611):", "Spawn", "Cancel");
  94.                 else if (listitem == 1) // By name
  95.                     ShowPlayerDialog(playerid, DIALOG_SPAWNER_2, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FFFFFF}Type in a vehicle name to spawn:", "Spawn", "Cancel");
  96.             }
  97.             return 1;
  98.         }
  99.        
  100.         case DIALOG_SPAWNER_1: // By ID
  101.         {
  102.             if (response)
  103.             {
  104.                 if (!strlen(inputtext) || strval(inputtext) < 400 || strval(inputtext) > 611) return ShowPlayerDialog(playerid, DIALOG_SPAWNER_1, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FF0000}Invalid vehicle ID!\n{FFFFFF}Type in a vehicle ID to spawn (400-611):", "Spawn", "Cancel");
  105.                 new CarSpawn, Float:pos[4];
  106.                 GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  107.                 GetPlayerFacingAngle(playerid, pos[3]);
  108.                 CarSpawn = CreateVehicle(strval(inputtext), pos[0], pos[1], pos[2], pos[3], 0, 0, 999999);
  109.                 PutPlayerInVehicle(playerid, CarSpawn, 0);
  110.                 SendClientMessage(playerid, 0x33AA33AA, "The vehicle has been successfully spawned!");
  111.             }
  112.             return 1;
  113.         }
  114.        
  115.         case DIALOG_SPAWNER_2: // By Name
  116.         {
  117.             if (response)
  118.             {
  119.                 if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_SPAWNER_2, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FF0000}Invalid vehicle name!\n{FFFFFF}Type in a vehicle name to spawn:", "Spawn", "Cancel");
  120.                 new bool:found, carid;
  121.                 for (new i; i < sizeof(VehNames); i++)
  122.                 {
  123.                     if (!strcmp(VehNames[i], inputtext, true))
  124.                     {
  125.                         carid = i + 400;
  126.                         found = true;
  127.                     }
  128.                     if (i == sizeof(VehNames) + 1)
  129.                         found = false;
  130.                 }
  131.                 if (found != true) return ShowPlayerDialog(playerid, DIALOG_SPAWNER_2, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FF0000}Invalid vehicle name!\n{FFFFFF}Type in a vehicle name to spawn:", "Spawn", "Cancel");
  132.                 new CarSpawn, Float:pos[4];
  133.                 GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  134.                 GetPlayerFacingAngle(playerid, pos[3]);
  135.                 CarSpawn = CreateVehicle(carid, pos[0], pos[1], pos[2], pos[3], 0, 0, 999999);
  136.                 PutPlayerInVehicle(playerid, CarSpawn, 0);
  137.                 SendClientMessage(playerid, 0x33AA33AA, "The vehicle has been successfully spawned!");
  138.             }
  139.             return 1;
  140.         }
  141.     }
  142.     return 0;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement