Advertisement
Guest User

VCControl

a guest
Aug 26th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Completely redesigned from scratch. //
  2. // @ Project Developer : Alexis1999 //
  3. // Vehicle Control System //
  4.  
  5. #include <a_samp>
  6.  
  7. #if defined _samp_include
  8.     #endinput
  9. #endif
  10.  
  11. #define _samp_include
  12.  
  13. new VCNames[212][] =
  14. {
  15.         {"Landstalker"},
  16.         {"Bravura"},
  17.         {"Buffalo"},
  18.         {"Linerunner"},
  19.         {"Perrenial"},
  20.         {"Sentinel"},
  21.         {"Dumper"},
  22.         {"Firetruck"},
  23.         {"Trashmaster"},
  24.         {"Stretch"},
  25.         {"Manana"},
  26.         {"Infernus"},
  27.         {"Voodoo"},
  28.         {"Pony"},
  29.         {"Mule"},
  30.         {"Cheetah"},
  31.         {"Ambulance"},
  32.         {"Leviathan"},
  33.         {"Moonbeam"},
  34.         {"Esperanto"},
  35.         {"Taxi"},
  36.         {"Washington"},
  37.         {"Bobcat"},
  38.         {"Mr Whoopee"},
  39.         {"BF Injection"},
  40.         {"Hunter"},
  41.         {"Premier"},
  42.         {"Enforcer"},
  43.         {"Securicar"},
  44.         {"Banshee"},
  45.         {"Predator"},
  46.         {"Bus"},
  47.         {"Rhino"},
  48.         {"Barracks"},
  49.         {"Hotknife"},
  50.         {"Trailer 1"},
  51.         {"Previon"},
  52.         {"Coach"},
  53.         {"Cabbie"},
  54.         {"Stallion"},
  55.         {"Rumpo"},
  56.         {"RC Bandit"},
  57.         {"Romero"},
  58.         {"Packer"},
  59.         {"Monster"},
  60.         {"Admiral"},
  61.         {"Squalo"},
  62.         {"Seasparrow"},
  63.         {"Pizzaboy"},
  64.         {"Tram"},
  65.         {"Trailer 2"},
  66.         {"Turismo"},
  67.         {"Speeder"},
  68.         {"Reefer"},
  69.         {"Tropic"},
  70.         {"Flatbed"},
  71.         {"Yankee"},
  72.         {"Caddy"},
  73.         {"Solair"},
  74.         {"Berkley's RC Van"},
  75.         {"Skimmer"},
  76.         {"PCJ-600"},
  77.         {"Faggio"},
  78.         {"Freeway"},
  79.         {"RC Baron"},
  80.         {"RC Raider"},
  81.         {"Glendale"},
  82.         {"Oceanic"},
  83.         {"Sanchez"},
  84.         {"Sparrow"},
  85.         {"Patriot"},
  86.         {"Quad"},
  87.         {"Coastguard"},
  88.         {"Dinghy"},
  89.         {"Hermes"},
  90.         {"Sabre"},
  91.         {"Rustler"},
  92.         {"ZR-350"},
  93.         {"Walton"},
  94.         {"Regina"},
  95.         {"Comet"},
  96.         {"BMX"},
  97.         {"Burrito"},
  98.         {"Camper"},
  99.         {"Marquis"},
  100.         {"Baggage"},
  101.         {"Dozer"},
  102.         {"Maverick"},
  103.         {"News Chopper"},
  104.         {"Rancher"},
  105.         {"FBI Rancher"},
  106.         {"Virgo"},
  107.         {"Greenwood"},
  108.         {"Jetmax"},
  109.         {"Hotring"},
  110.         {"Sandking"},
  111.         {"Blista Compact"},
  112.         {"Police Maverick"},
  113.         {"Boxville"},
  114.         {"Benson"},
  115.         {"Mesa"},
  116.         {"RC Goblin"},
  117.         {"Hotring Racer A"},
  118.         {"Hotring Racer B"},
  119.         {"Bloodring Banger"},
  120.         {"Rancher"},
  121.         {"Super GT"},
  122.         {"Elegant"},
  123.         {"Journey"},
  124.         {"Bike"},
  125.         {"Mountain Bike"},
  126.         {"Beagle"},
  127.         {"Cropdust"},
  128.         {"Stunt"},
  129.         {"Tanker"},
  130.         {"Roadtrain"},
  131.         {"Nebula"},
  132.         {"Majestic"},
  133.         {"Buccaneer"},
  134.         {"Shamal"},
  135.         {"Hydra"},
  136.         {"FCR-900"},
  137.         {"NRG-500"},
  138.         {"HPV1000"},
  139.         {"Cement Truck"},
  140.         {"Tow Truck"},
  141.         {"Fortune"},
  142.         {"Cadrona"},
  143.         {"FBI Truck"},
  144.         {"Willard"},
  145.         {"Forklift"},
  146.         {"Tractor"},
  147.         {"Combine"},
  148.         {"Feltzer"},
  149.         {"Remington"},
  150.         {"Slamvan"},
  151.         {"Blade"},
  152.         {"Freight"},
  153.         {"Streak"},
  154.         {"Vortex"},
  155.         {"Vincent"},
  156.         {"Bullet"},
  157.         {"Clover"},
  158.         {"Sadler"},
  159.         {"Firetruck LA"},
  160.         {"Hustler"},
  161.         {"Intruder"},
  162.         {"Primo"},
  163.         {"Cargobob"},
  164.         {"Tampa"},
  165.         {"Sunrise"},
  166.         {"Merit"},
  167.         {"Utility"},
  168.         {"Nevada"},
  169.         {"Yosemite"},
  170.         {"Windsor"},
  171.         {"Monster A"},
  172.         {"Monster B"},
  173.         {"Uranus"},
  174.         {"Jester"},
  175.         {"Sultan"},
  176.         {"Stratum"},
  177.         {"Elegy"},
  178.         {"Raindance"},
  179.         {"RC Tiger"},
  180.         {"Flash"},
  181.         {"Tahoma"},
  182.         {"Savanna"},
  183.         {"Bandito"},
  184.         {"Freight Flat"},
  185.         {"Streak Carriage"},
  186.         {"Kart"},
  187.         {"Mower"},
  188.         {"Duneride"},
  189.         {"Sweeper"},
  190.         {"Broadway"},
  191.         {"Tornado"},
  192.         {"AT-400"},
  193.         {"DFT-30"},
  194.         {"Huntley"},
  195.         {"Stafford"},
  196.         {"BF-400"},
  197.         {"Newsvan"},
  198.         {"Tug"},
  199.         {"Trailer 3"},
  200.         {"Emperor"},
  201.         {"Wayfarer"},
  202.         {"Euros"},
  203.         {"Hotdog"},
  204.         {"Club"},
  205.         {"Freight Carriage"},
  206.         {"Trailer 3"},
  207.         {"Andromada"},
  208.         {"Dodo"},
  209.         {"RC Cam"},
  210.         {"Launch"},
  211.         {"Police Car (LSPD)"},
  212.         {"Police Car (SFPD)"},
  213.         {"Police Car (LVPD)"},
  214.         {"Police Ranger"},
  215.         {"Picador"},
  216.         {"S.W.A.T. Van"},
  217.         {"Alpha"},
  218.         {"Phoenix"},
  219.         {"Glendale"},
  220.         {"Sadler"},
  221.         {"Luggage Trailer A"},
  222.         {"Luggage Trailer B"},
  223.         {"Stair Trailer"},
  224.         {"Boxville"},
  225.         {"Farm Plow"},
  226.         {"Utility Trailer"}
  227. };
  228.  
  229. stock VehicleControl(playerid, String[]) {
  230.     if(!strcmp(String, "ActivateEngine")) {
  231.         new Vehicle = GetPlayerVehicleID(playerid);
  232.         if(IsPlayerInVehicle(playerid, Vehicle)) {     
  233.             new engine, lights, alarm, doors, bonnet, boot, objective;
  234.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  235.             SetVehicleParamsEx(Vehicle, 1, lights, alarm, doors, bonnet, boot, objective);
  236.         }
  237.     }
  238.  
  239.     else if(!strcmp(String, "DeactivateEngine")) {
  240.         new Vehicle = GetPlayerVehicleID(playerid);
  241.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  242.             new engine, lights, alarm, doors, bonnet, boot, objective;
  243.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  244.             SetVehicleParamsEx(Vehicle, 0, lights, alarm, doors, bonnet, boot, objective);
  245.         }
  246.     }
  247.    
  248.     else if(!strcmp(String, "ActivateLights")) {
  249.         new Vehicle = GetPlayerVehicleID(playerid);
  250.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  251.             new engine2, lights2, alarm2, doors2, bonnet2, boot2, objective2;
  252.             GetVehicleParamsEx(Vehicle, engine2, lights2, alarm2, doors2, bonnet2, boot2, objective2)
  253.             SetVehicleParamsEx(Vehicle, engine2, 1, alarm2, doors2, bonnet2, boot2, objective2);
  254.         }
  255.     }
  256.    
  257.     else if(!strcmp(String, "DeactivateLights")) {
  258.         new Vehicle = GetPlayerVehicleID(playerid);
  259.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  260.             new engine2, lights2, alarm2, doors2, bonnet2, boot2, objective2;  
  261.             GetVehicleParamsEx(Vehicle, engine2, lights2, alarm2, doors2, bonnet2, boot2, objective2);
  262.             SetVehicleParamsEx(Vehicle, engine2, 0, alarm2, doors2, bonnet2, boot2, objective2);
  263.             SendClientMessage(playerid, -1, "test24");
  264.         }
  265.     }
  266.    
  267.     else if(!strcmp(String, "EnableAlarm")) {
  268.         new Vehicle = GetPlayerVehicleID(playerid);
  269.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  270.             new engine, lights, alarm, doors, bonnet, boot, objective;
  271.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  272.             SetVehicleParamsEx(Vehicle, engine, lights, 1, doors, bonnet, boot, objective);
  273.         }
  274.     }
  275.  
  276.     else if(!strcmp(String, "DisableAlarm")) {
  277.         new Vehicle = GetPlayerVehicleID(playerid);
  278.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  279.             new engine, lights, alarm, doors, bonnet, boot, objective;
  280.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  281.             SetVehicleParamsEx(Vehicle, engine, lights, 0, doors, bonnet, boot, objective);
  282.         }
  283.     }
  284.  
  285.     else if(!strcmp(String, "UnlockVehicle")) {
  286.         new Vehicle = GetPlayerVehicleID(playerid);
  287.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  288.             new engine, lights, alarm, doors, bonnet, boot, objective;
  289.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  290.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, 0, bonnet, boot, objective);
  291.         }
  292.     }
  293.  
  294.     else if(!strcmp(String, "LockVehicle")) {
  295.         new Vehicle = GetPlayerVehicleID(playerid);
  296.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  297.             new engine, lights, alarm, doors, bonnet, boot, objective;
  298.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  299.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, 1, bonnet, boot, objective);
  300.         }
  301.     }
  302.    
  303.     else if(!strcmp(String, "OpenBonnet")) {
  304.         new Vehicle = GetPlayerVehicleID(playerid);
  305.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  306.             new engine, lights, alarm, doors, bonnet, boot, objective;
  307.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  308.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, 1, boot, objective);
  309.         }
  310.     }
  311.  
  312.     else if(!strcmp(String, "CloseBonnet")) {
  313.         new Vehicle = GetPlayerVehicleID(playerid);
  314.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  315.             new engine, lights, alarm, doors, bonnet, boot, objective;
  316.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  317.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, 0, boot, objective);
  318.         }
  319.     }
  320.    
  321.     else if(!strcmp(String, "OpenBoot")) {
  322.         new Vehicle = GetPlayerVehicleID(playerid);
  323.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  324.             new engine, lights, alarm, doors, bonnet, boot, objective;
  325.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  326.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, 1, objective);
  327.         }
  328.     }
  329.  
  330.     else if(!strcmp(String, "CloseBoot")) {
  331.         new Vehicle = GetPlayerVehicleID(playerid);
  332.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  333.             new engine, lights, alarm, doors, bonnet, boot, objective;
  334.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  335.             SetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, 0, objective);
  336.         }
  337.     }
  338.    
  339.     else if(!strcmp(String, "DeleteVehicle")) {
  340.         new Vehicle = GetPlayerVehicleID(playerid);
  341.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  342.             DestroyVehicle(Vehicle);
  343.         }
  344.     }
  345.    
  346.     else {
  347.         SendClientMessage(playerid, -1, "{00FF99}Vehicle Control | {FFFFFF}Undefined Action Name ( VehicleControl ) KK?");
  348.     }
  349. }
  350.  
  351. stock VCBool(playerid, String[]) {
  352.     if(!strcmp(String, "IsVehicleEngineOn")) {
  353.         new Vehicle = GetPlayerVehicleID(playerid);
  354.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  355.             new engine, lights, alarm, doors, bonnet, boot, objective;
  356.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  357.             if(engine == 1) return 1;
  358.             else return 0;
  359.         }
  360.     }
  361.    
  362.     else if(!strcmp(String, "IsVehicleLightsOn")) {
  363.         new Vehicle = GetPlayerVehicleID(playerid);
  364.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  365.             new engine, lights, alarm, doors, bonnet, boot, objective;
  366.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  367.             if(lights == 1) return 1;
  368.             else return 0;
  369.         }
  370.     }
  371.    
  372.     else if(!strcmp(String, "IsVehicleBonnetOpen")) {
  373.         new Vehicle = GetPlayerVehicleID(playerid);
  374.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  375.             new engine, lights, alarm, doors, bonnet, boot, objective;
  376.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  377.             if(bonnet == 1) return 1;
  378.             else return 0;
  379.         }
  380.     }
  381.    
  382.     else if(!strcmp(String, "IsVehicleBootOpen")) {
  383.         new Vehicle = GetPlayerVehicleID(playerid);
  384.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  385.             new engine, lights, alarm, doors, bonnet, boot, objective;
  386.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  387.             if(boot == 1) return 1;
  388.             else return 0;
  389.         }
  390.     }
  391.    
  392.     else if(!strcmp(String, "IsVehicleAlarmOn")) {
  393.         new Vehicle = GetPlayerVehicleID(playerid);
  394.         if(IsPlayerInVehicle(playerid, Vehicle)) {
  395.             new engine, lights, alarm, doors, bonnet, boot, objective;
  396.             GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  397.             if(alarm == 1) return 1;
  398.             else return 0;
  399.         }
  400.     }
  401.    
  402.     else {
  403.         SendClientMessage(playerid, -1, "{00FF99}Vehicle Control Issue {FFFFFF}| Undefined Bool ( VCBool )");
  404.     }
  405.    
  406.     return 1;
  407. }
  408.  
  409. stock VCCreate(playerid, VCName[], ColorA, ColorB) {
  410.     new Vehicle = ConvertToVehicleID(VCName);
  411.     new Float: Pos[3];
  412.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  413.    
  414.     if(Vehicle != 0 && Vehicle >= 400 && Vehicle <= 611) {
  415.         CreateVehicle(Vehicle, Pos[0], Pos[1], Pos[2], 0, ColorA, ColorB, 0);
  416.     } else return SendClientMessage(playerid, -1, "Undefined Vehicle ( VCCreate )");
  417.    
  418.     return 1;
  419. }
  420.  
  421. stock VCCreateEx(playerid, VCFormat[], Vehicle[], ColorA, ColorB) {
  422.     format(VCFormat, 128, "%s", Vehicle);
  423.     new Float: Pos[3];
  424.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  425.     if(!IsNumeric(Vehicle)) {
  426.         new VehicleEx = ConvertToVehicleID(Vehicle);
  427.         if(VehicleEx != 0 && VehicleEx >= 400 && VehicleEx <= 611) {
  428.             CreateVehicle(VehicleEx, Pos[0], Pos[1], Pos[2], 0, ColorA, ColorB, 0);
  429.         }
  430.     } else {
  431.         if(strval(Vehicle) != 0 && strval(Vehicle) >= 400 && strval(Vehicle) <= 611) {
  432.             CreateVehicle(strval(Vehicle), Pos[0], Pos[1], Pos[2], 0, ColorA, ColorB, 0);
  433.         }
  434.     }
  435.     return 1;
  436. }
  437.  
  438. stock IsNumeric( string[ ] ) { for (new i = 0, j = strlen( string); i < j; i++) if ( string[i] > '9' || string[i] < '0') return 0; return 1; }
  439.  
  440. stock ConvertToVehicleID(VCName[]) {
  441.     for(new j = 0; j < 211; j++) {
  442.         if(strfind(VCNames[j], VCName, true) != -1)
  443.         return j + 400;
  444.     }
  445.    
  446.     return 1;
  447. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement