Advertisement
Guest User

JCSpawner V0.2

a guest
Jun 8th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.63 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.2
  14.         -------------------------------
  15.         Changelog:
  16.         -------------------------------
  17.             V0.2:
  18.                 Be able to pick a car color
  19.         -------------------------------
  20.         Copyrights:
  21.         -------------------------------
  22.             Created by JewCaptain (CptK as in SA-MP forums), for public server usage. All copyrights reserved ©.
  23.             You are NOT allowed to remove those credits.
  24.     ==========================================================
  25. */
  26.  
  27. //==========================================================
  28. #include <a_samp>
  29. //==========================================================
  30. #define VERSION "0.2"
  31.  
  32. // Change dialog ids if it interrupt with other dialog ids
  33. #define DIALOG_SPAWNER 501 // Main spawner menu
  34. #define DIALOG_SPAWNER_1 502 // By ID
  35. #define DIALOG_SPAWNER_2 503 // By name
  36. #define DIALOG_SPAWNER_3 504 // Color
  37. //==========================================================
  38. enum sInfo
  39. {
  40.     bool:sByID,
  41.     sCarColors[2],
  42.     sCarID,
  43.     sCarName[50]
  44. }
  45. //==========================================================
  46. new VehNames[212][] = {
  47. {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
  48. {"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},
  49. {"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},{"Washington"},
  50. {"Bobcat"},{"Mr Whoopee"},{"BF Injection"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},
  51. {"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Trailer 1"},{"Previon"},
  52. {"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
  53. {"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Trailer 2"},{"Turismo"},
  54. {"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC Van"},
  55. {"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},
  56. {"Sanchez"},{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},
  57. {"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},
  58. {"Baggage"},{"Dozer"},{"Maverick"},{"News Chopper"},{"Rancher"},{"FBI Rancher"},{"Virgo"},{"Greenwood"},
  59. {"Jetmax"},{"Hotring"},{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},
  60. {"Mesa"},{"RC Goblin"},{"Hotring Racer A"},{"Hotring Racer B"},{"Bloodring Banger"},{"Rancher"},
  61. {"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stunt"},
  62. {"Tanker"}, {"Roadtrain"},{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},
  63. {"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},
  64. {"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},
  65. {"Blade"},{"Freight"},{"Streak"},{"Vortex"},{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},
  66. {"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},
  67. {"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},
  68. {"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},
  69. {"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Duneride"},{"Sweeper"},
  70. {"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},
  71. {"Tug"},{"Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Hotdog"},{"Club"},{"Freight Carriage"},
  72. {"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police Car (LSPD)"},{"Police Car (SFPD)"},
  73. {"Police Car (LVPD)"},{"Police Ranger"},{"Picador"},{"S.W.A.T. Van"},{"Alpha"},{"Phoenix"},{"Glendale"},
  74. {"Sadler"},{"Luggage Trailer A"},{"Luggage Trailer B"},{"Stair Trailer"},{"Boxville"},{"Farm Plow"},
  75. {"Utility Trailer"}
  76. };
  77.  
  78. new SpawnInfo[MAX_PLAYERS][sInfo];
  79. //==========================================================
  80. public OnFilterScriptInit()
  81. {
  82.     print("\n==========================================================");
  83.     print(" JewCaptain's Vehicle Spawner V"VERSION" has been successfully loaded.");
  84.     print("==========================================================\n");
  85.     return 1;
  86. }
  87. //==========================================================
  88. 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
  89. {
  90.     if (!strcmp(cmdtext, "/jcspawner", true))
  91.     {
  92.         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
  93.         ShowPlayerDialog(playerid, DIALOG_SPAWNER, DIALOG_STYLE_LIST, "{FFFFFF}JC's Spawner", "{FFFFFF}By ID\nBy Name", "Select", "Cancel");
  94.         return 1;
  95.     }
  96.     return 0;
  97. }
  98. //==========================================================
  99. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  100. {
  101.     switch (dialogid)
  102.     {
  103.         case DIALOG_SPAWNER: // Main menu
  104.         {
  105.             if (response)
  106.             {
  107.                 if (listitem == 0) // By ID
  108.                     ShowPlayerDialog(playerid, DIALOG_SPAWNER_1, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FFFFFF}Type in a vehicle ID to spawn (400-611):", "Spawn", "Cancel");
  109.                 else if (listitem == 1) // By name
  110.                     ShowPlayerDialog(playerid, DIALOG_SPAWNER_2, DIALOG_STYLE_INPUT, "{FFFFFF}JC's Spawner", "{FFFFFF}Type in a vehicle name to spawn:", "Spawn", "Cancel");
  111.             }
  112.             return 1;
  113.         }
  114.        
  115.         case DIALOG_SPAWNER_1: // By ID
  116.         {
  117.             if (response)
  118.             {
  119.                 SpawnInfo[playerid][sByID] = true;
  120.                 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");
  121.                 SpawnInfo[playerid][sCarID] = strval(inputtext);
  122.                 ShowPlayerDialog(playerid, DIALOG_SPAWNER_3, DIALOG_STYLE_LIST, "{FFFFFF}JC's Spawner | Choose a color", "{FFFFFF}White\n{000000}Black\n{FF0000}Red\n{33FF00}Green\n{FF00BF}Pink\n{0080FF}Blue\n{FFF700}Yellow", "Select", "Cancel");
  123.             }
  124.             return 1;
  125.         }
  126.        
  127.         case DIALOG_SPAWNER_2: // By Name
  128.         {
  129.             if (response)
  130.             {
  131.                 SpawnInfo[playerid][sByID] = false;
  132.                 format(SpawnInfo[playerid][sCarName], 50, "%s", inputtext);
  133.                 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");
  134.                 ShowPlayerDialog(playerid, DIALOG_SPAWNER_3, DIALOG_STYLE_LIST, "{FFFFFF}JC's Spawner | Choose a color", "{FFFFFF}White\n{000000}Black\n{FF0000}Red\n{33FF00}Green\n{FF00BF}Pink\n{0080FF}Blue\n{FFF700}Yellow", "Select", "Cancel");
  135.             }
  136.             return 1;
  137.         }
  138.        
  139.         case DIALOG_SPAWNER_3: // Car color
  140.         {
  141.             if (response)
  142.             {
  143.                 switch (listitem)
  144.                 {
  145.                     case 0: SpawnInfo[playerid][sCarColors][0] = 1, SpawnInfo[playerid][sCarColors][1] = 1; // white
  146.                     case 1: SpawnInfo[playerid][sCarColors][0] = 0, SpawnInfo[playerid][sCarColors][1] = 0; // black
  147.                     case 2: SpawnInfo[playerid][sCarColors][0] = 3, SpawnInfo[playerid][sCarColors][1] = 3; // red
  148.                     case 3: SpawnInfo[playerid][sCarColors][0] = 86, SpawnInfo[playerid][sCarColors][1] = 89; // green
  149.                     case 4: SpawnInfo[playerid][sCarColors][0] = 5, SpawnInfo[playerid][sCarColors][1] = 5; // pink
  150.                     case 5: SpawnInfo[playerid][sCarColors][0] = 7, SpawnInfo[playerid][sCarColors][1] = 7; // blue
  151.                     case 6: SpawnInfo[playerid][sCarColors][0] = 6, SpawnInfo[playerid][sCarColors][1] = 6; // yellow
  152.                 }
  153.                
  154.                 if (SpawnInfo[playerid][sByID] != false)
  155.                 {
  156.                     new CarSpawn, Float:pos[4];
  157.                     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  158.                     GetPlayerFacingAngle(playerid, pos[3]);
  159.                     CarSpawn = CreateVehicle(SpawnInfo[playerid][sCarID], pos[0], pos[1], pos[2], pos[3], 0, 0, 999999);
  160.                     ChangeVehicleColor(CarSpawn, SpawnInfo[playerid][sCarColors][0], SpawnInfo[playerid][sCarColors][1]);
  161.                     PutPlayerInVehicle(playerid, CarSpawn, 0);
  162.                     SendClientMessage(playerid, 0x33AA33AA, "The vehicle has been successfully spawned!");
  163.                 }
  164.                 else
  165.                 {
  166.                     new bool:found, carid;
  167.                     for (new i; i < sizeof(VehNames); i++)
  168.                     {
  169.                         if (!strcmp(VehNames[i], SpawnInfo[playerid][sCarName], true))
  170.                         {
  171.                             carid = i + 400;
  172.                             found = true;
  173.                         }
  174.                         if (i == sizeof(VehNames) + 1)
  175.                             found = false;
  176.                     }
  177.                     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");
  178.                     new CarSpawn, Float:pos[4];
  179.                     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  180.                     GetPlayerFacingAngle(playerid, pos[3]);
  181.                     CarSpawn = CreateVehicle(carid, pos[0], pos[1], pos[2], pos[3], 0, 0, 999999);
  182.                     ChangeVehicleColor(CarSpawn, SpawnInfo[playerid][sCarColors][0], SpawnInfo[playerid][sCarColors][1]);
  183.                     PutPlayerInVehicle(playerid, CarSpawn, 0);
  184.                     SendClientMessage(playerid, 0x33AA33AA, "The vehicle has been successfully spawned!");
  185.                 }
  186.             }
  187.             return 1;
  188.         }
  189.     }
  190.     return 0;
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement