Advertisement
Dolfwagos

Car_spawner_v1.0

Jun 7th, 2012
2,291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.48 KB | None | 0 0
  1. //-----Credits To-------//
  2. //-----Dolfwagos-------//
  3. //--------And---------//
  4. //---Matt_wilkinson--//
  5. //------------------//
  6.  
  7. //------Includes-------//
  8. #include <a_samp>
  9. //-------------------//
  10. //---------Defines--------//
  11. #define FILTERSCRIPT
  12. #if defined FILTERSCRIPT
  13. #define red 0xFF0000AA
  14. #define green 0x33FF33AA
  15. //--------------------//
  16. new aVehicleNames[212][] =
  17. {
  18.     {"Landstalker"},
  19.     {"Bravura"},
  20.     {"Buffalo"},
  21.     {"Linerunner"},
  22.     {"Perrenial"},
  23.     {"Sentinel"},
  24.     {"Dumper"},
  25.     {"Firetruck"},
  26.     {"Trashmaster"},
  27.     {"Stretch"},
  28.     {"Manana"},
  29.     {"Infernus"},
  30.     {"Voodoo"},
  31.     {"Pony"},
  32.     {"Mule"},
  33.     {"Cheetah"},
  34.     {"Ambulance"},
  35.     {"Leviathan"},
  36.     {"Moonbeam"},
  37.     {"Esperanto"},
  38.     {"Taxi"},
  39.     {"Washington"},
  40.     {"Bobcat"},
  41.     {"Mr Whoopee"},
  42.     {"BF Injection"},
  43.     {"Hunter"},
  44.     {"Premier"},
  45.     {"Enforcer"},
  46.     {"Securicar"},
  47.     {"Banshee"},
  48.     {"Predator"},
  49.     {"Bus"},
  50.     {"Rhino"},
  51.     {"Barracks"},
  52.     {"Hotknife"},
  53.     {"Trailer 1"},
  54.     {"Previon"},
  55.     {"Coach"},
  56.     {"Cabbie"},
  57.     {"Stallion"},
  58.     {"Rumpo"},
  59.     {"RC Bandit"},
  60.     {"Romero"},
  61.     {"Packer"},
  62.     {"Monster"},
  63.     {"Admiral"},
  64.     {"Squalo"},
  65.     {"Seasparrow"},
  66.     {"Pizzaboy"},
  67.     {"Tram"},
  68.     {"Trailer 2"},
  69.     {"Turismo"},
  70.     {"Speeder"},
  71.     {"Reefer"},
  72.     {"Tropic"},
  73.     {"Flatbed"},
  74.     {"Yankee"},
  75.     {"Caddy"},
  76.     {"Solair"},
  77.     {"Berkley's RC Van"},
  78.     {"Skimmer"},
  79.     {"PCJ-600"},
  80.     {"Faggio"},
  81.     {"Freeway"},
  82.     {"RC Baron"},
  83.     {"RC Raider"},
  84.     {"Glendale"},
  85.     {"Oceanic"},
  86.     {"Sanchez"},
  87.     {"Sparrow"},
  88.     {"Patriot"},
  89.     {"Quad"},
  90.     {"Coastguard"},
  91.     {"Dinghy"},
  92.     {"Hermes"},
  93.     {"Sabre"},
  94.     {"Rustler"},
  95.     {"ZR-350"},
  96.     {"Walton"},
  97.     {"Regina"},
  98.     {"Comet"},
  99.     {"BMX"},
  100.     {"Burrito"},
  101.     {"Camper"},
  102.     {"Marquis"},
  103.     {"Baggage"},
  104.     {"Dozer"},
  105.     {"Maverick"},
  106.     {"News Chopper"},
  107.     {"Rancher"},
  108.     {"FBI Rancher"},
  109.     {"Virgo"},
  110.     {"Greenwood"},
  111.     {"Jetmax"},
  112.     {"Hotring"},
  113.     {"Sandking"},
  114.     {"Blista Compact"},
  115.     {"Police Maverick"},
  116.     {"Boxville"},
  117.     {"Benson"},
  118.     {"Mesa"},
  119.     {"RC Goblin"},
  120.     {"Hotring Racer A"},
  121.     {"Hotring Racer B"},
  122.     {"Bloodring Banger"},
  123.     {"Rancher"},
  124.     {"Super GT"},
  125.     {"Elegant"},
  126.     {"Journey"},
  127.     {"Bike"},
  128.     {"Mountain Bike"},
  129.     {"Beagle"},
  130.     {"Cropdust"},
  131.     {"Stunt"},
  132.     {"Tanker"},
  133.     {"Roadtrain"},
  134.     {"Nebula"},
  135.     {"Majestic"},
  136.     {"Buccaneer"},
  137.     {"Shamal"},
  138.     {"Hydra"},
  139.     {"FCR-900"},
  140.     {"NRG-500"},
  141.     {"HPV1000"},
  142.     {"Cement Truck"},
  143.     {"Tow Truck"},
  144.     {"Fortune"},
  145.     {"Cadrona"},
  146.     {"FBI Truck"},
  147.     {"Willard"},
  148.     {"Forklift"},
  149.     {"Tractor"},
  150.     {"Combine"},
  151.     {"Feltzer"},
  152.     {"Remington"},
  153.     {"Slamvan"},
  154.     {"Blade"},
  155.     {"Freight"},
  156.     {"Streak"},
  157.     {"Vortex"},
  158.     {"Vincent"},
  159.     {"Bullet"},
  160.     {"Clover"},
  161.     {"Sadler"},
  162.     {"Firetruck LA"},
  163.     {"Hustler"},
  164.     {"Intruder"},
  165.     {"Primo"},
  166.     {"Cargobob"},
  167.     {"Tampa"},
  168.     {"Sunrise"},
  169.     {"Merit"},
  170.     {"Utility"},
  171.     {"Nevada"},
  172.     {"Yosemite"},
  173.     {"Windsor"},
  174.     {"Monster A"},
  175.     {"Monster B"},
  176.     {"Uranus"},
  177.     {"Jester"},
  178.     {"Sultan"},
  179.     {"Stratum"},
  180.     {"Elegy"},
  181.     {"Raindance"},
  182.     {"RC Tiger"},
  183.     {"Flash"},
  184.     {"Tahoma"},
  185.     {"Savanna"},
  186.     {"Bandito"},
  187.     {"Freight Flat"},
  188.     {"Streak Carriage"},
  189.     {"Kart"},
  190.     {"Mower"},
  191.     {"Duneride"},
  192.     {"Sweeper"},
  193.     {"Broadway"},
  194.     {"Tornado"},
  195.     {"AT-400"},
  196.     {"DFT-30"},
  197.     {"Huntley"},
  198.     {"Stafford"},
  199.     {"BF-400"},
  200.     {"Newsvan"},
  201.     {"Tug"},
  202.     {"Trailer 3"},
  203.     {"Emperor"},
  204.     {"Wayfarer"},
  205.     {"Euros"},
  206.     {"Hotdog"},
  207.     {"Club"},
  208.     {"Freight Carriage"},
  209.     {"Trailer 3"},
  210.     {"Andromada"},
  211.     {"Dodo"},
  212.     {"RC Cam"},
  213.     {"Launch"},
  214.     {"Police Car (LSPD)"},
  215.     {"Police Car (SFPD)"},
  216.     {"Police Car (LVPD)"},
  217.     {"Police Ranger"},
  218.     {"Picador"},
  219.     {"S.W.A.T. Van"},
  220.     {"Alpha"},
  221.     {"Phoenix"},
  222.     {"Glendale"},
  223.     {"Sadler"},
  224.     {"Luggage Trailer A"},
  225.     {"Luggage Trailer B"},
  226.     {"Stair Trailer"},
  227.     {"Boxville"},
  228.     {"Farm Plow"},
  229.     {"Utility Trailer"}
  230. };
  231.  
  232.  
  233. #endif
  234.  
  235. enum VehID
  236. {
  237.     VehId
  238. }
  239. new Veh[MAX_PLAYERS][VehID];
  240. public OnPlayerConnect(playerid)
  241. {
  242.     Veh[playerid][VehId] = -1;
  243.     return 1;
  244. }
  245. public OnPlayerCommandText(playerid, cmdtext[])
  246. {
  247.    
  248.     new cmd[200], idx;
  249.     cmd = strtok(cmdtext, idx);
  250.  
  251.     if(strcmp(cmd, "/car", true, 4) == 0)
  252.     {
  253.        
  254.  
  255.         new String[200];
  256.         new tmp[256];
  257.         new Float:x, Float:y, Float:z;
  258.         tmp = strtok(cmdtext, idx);
  259.         if(!strlen(tmp)) return SendClientMessage(playerid,red, "SYNTAX: /car [car name]");
  260.         new vehicle = GetVehicleModelIDFromName(tmp);
  261.         if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,red, "That vehicle name you have given was not found, please try again!");
  262.         if(Veh[playerid][VehId] == -1)
  263.         {
  264.             new Float:a;
  265.             GetPlayerFacingAngle(playerid, a);
  266.             GetPlayerPos(playerid, x, y, z);
  267.  
  268.             if(IsPlayerInAnyVehicle(playerid) == 1)
  269.             {
  270.                 GetXYInFrontOfPlayer(playerid, x, y, 8);
  271.             }
  272.             else
  273.             {
  274.                 GetXYInFrontOfPlayer(playerid, x, y, 5);
  275.             }
  276.  
  277.             new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
  278.             Veh[playerid][VehId] = PlayersVehicle;
  279.             LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
  280.         }
  281.         else
  282.         {
  283.             DestroyVehicle(Veh[playerid][VehId]);
  284.             new Float:a;
  285.             GetPlayerFacingAngle(playerid, a);
  286.             GetPlayerPos(playerid, x, y, z);
  287.  
  288.             if(IsPlayerInAnyVehicle(playerid) == 1)
  289.             {
  290.                 GetXYInFrontOfPlayer(playerid, x, y, 8);
  291.             }
  292.             else
  293.             {
  294.                 GetXYInFrontOfPlayer(playerid, x, y, 5);
  295.             }
  296.  
  297.             new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
  298.             Veh[playerid][VehId] = PlayersVehicle;
  299.             LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
  300.         }
  301.         format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
  302.         SendClientMessage(playerid,green, String);
  303.         return 1;
  304.     }
  305.     return 0;
  306. }
  307. public OnPlayerDisconnect(playerid)
  308. {
  309.     DestroyVehicle(Veh[playerid][VehId]);
  310.     return 1;
  311. }
  312. strtok(const string[], &index)
  313. {
  314.     new length = strlen(string);
  315.     while ((index < length) && (string[index] <= ' '))
  316.     {
  317.         index++;
  318.     }
  319.  
  320.     new offset = index;
  321.     new result[20];
  322.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  323.     {
  324.         result[index - offset] = string[index];
  325.         index++;
  326.     }
  327.     result[index - offset] = EOS;
  328.     return result;
  329. }
  330.  
  331. GetVehicleModelIDFromName(vname[])
  332. {
  333.     for(new i = 0; i < 211; i++)
  334.     {
  335.         if(strfind(aVehicleNames[i], vname, true) != -1)
  336.         return i + 400;
  337.     }
  338.     return -1;
  339. }
  340.  
  341. stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
  342. {
  343.     new Float:a;
  344.  
  345.     GetPlayerPos(playerid, x2, y2, a);
  346.     GetPlayerFacingAngle(playerid, a);
  347.  
  348.     if(GetPlayerVehicleID(playerid))
  349.     {
  350.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  351.     }
  352.  
  353.     x2 += (distance * floatsin(-a, degrees));
  354.     y2 += (distance * floatcos(-a, degrees));
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement