Advertisement
Guest User

Untitled

a guest
Jun 30th, 2011
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.57 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define CARGO_CP_COORDS 1717.7792, 1238.7043, 34.9700
  4. #define LOC_MARKER 87
  5.  
  6. #define CRATE_OBJ 2977
  7. #define INCLUDE_MAP
  8. #define INCLUDE_MAP_VEHICLES
  9.  
  10.  
  11. #define PRESSED(%0) \
  12.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  13.  
  14. /**
  15.     Some random ass filterscript by blewert.
  16.  
  17.     Cargo FS. I released this because it really wasn't going to much
  18.     use; and to be honest, people liked it when I was testing it.
  19.    
  20.     eggs.
  21.    
  22. **/
  23.  
  24. forward cargoOnFail( playerid );
  25.  
  26. new Text3D:gCText,
  27.            gCPlayerObj[ MAX_PLAYERS ];
  28.    
  29. enum C_INFO
  30. {
  31.  
  32.     /* Position */
  33.     Float:CPosX,
  34.         Float:CPosY,
  35.             Float:CPosZ,
  36.    
  37.     /* Strings */
  38.     szCLocName [ 128 ],
  39.         szCItemName[ 128 ],
  40.    
  41.     /* Prices */
  42.     CiPrice,
  43.    
  44. }
  45.  
  46. new bool:   gbCInCargo    [ MAX_PLAYERS ],
  47.             gCCurrentItem [ MAX_PLAYERS ][ C_INFO ],
  48.             gCMultiplier  [ MAX_PLAYERS ];
  49.    
  50. new const _CARGO_LOCATIONS_[ ][ C_INFO ] =
  51. {
  52.  
  53.     /*HOLY SHIT ITS HUEG!*/
  54.  
  55.     /* FOOD OUTLETS */
  56.     { 1872.0398,2086.5945,16.2689, "Burger Shot",           "Burger Buns",                           600 },
  57.     { 1872.0398,2086.5945,16.2689, "Burger Shot",           "Burgers",                               500 },
  58.     { 1872.0398,2086.5945,16.2689, "Burger Shot",           "Cooking Oil",                           400 },
  59.     { 1872.0398,2086.5945,16.2689, "Burger Shot",           "Spatulas",                              500 },
  60.     { 1872.0398,2086.5945,16.2689, "Burger Shot",           "Underage Employees",                   1000 },
  61.    
  62.     { 2481.2671,2022.0551,16.2671, "Burger Shot",           "Burgers",                               500 },
  63.     { 2481.2671,2022.0551,16.2671, "Burger Shot",           "Burger Buns",                           600 },
  64.     { 2481.2671,2022.0551,16.2671, "Burger Shot",           "Cooking Oil",                           400 },
  65.     { 2481.2671,2022.0551,16.2671, "Burger Shot",           "Spatulas",                              500 },
  66.     { 2481.2671,2022.0551,16.2671, "Burger Shot",           "Underage Employees",                   1000 },
  67.    
  68.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Chicken Bones",                         300 },
  69.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Chicken Wings",                         600 },
  70.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Seeded Buns",                           500 },
  71.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Factory Waste",                         400 },
  72.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Cooking Oil",                           400 },
  73.     { 2388.3362,2035.2205,20.7600, \"Cluckin' Bell",        "Underage Employees",                   1000 },
  74.  
  75.     /* GARAGES, ETC */
  76.     { 1976.4663,2163.6094,17.5110, \"Pay 'n Spray",         "Spray Paint Cans",                      500 },
  77.     { 2386.8640,1049.1097,18.5032, "Transfender",           "Car Parts",                            1600 },
  78.     { 2386.8640,1049.1097,18.5032, "Transfender",           "Quality Paint",                         600 },
  79.     { 1162.4761,1348.6008,14.7590, "the Bike School",       "Helmets",                               500 },
  80.     { 1162.4761,1348.6008,14.7590, "the Bike School",       "Spare Wheels",                          500 },
  81.  
  82.     /* HOUSES AND APARTMENTS */
  83.     { 2079.7483,2171.4097,10.9659, "Some Apartments",       "BedSheets",                             600 },
  84.     { 2079.7483,2171.4097,10.9659, "Some Apartments",       "Mail",                                  400 },
  85.     { 2079.7483,2171.4097,10.9659, "Some Apartments",       "Curtains",                              500 },
  86.     { 2079.7483,2171.4097,10.9659, "Some Apartments",       "Dirty Socks",                           500 },
  87.    
  88.     { 1970.5187,1915.0750,131.1205,"the Visage",            "Air Freshener",                         500 },
  89.     { 1970.5187,1915.0750,131.1205,"the Visage",            "Quality Bed Sheets",                   1200 },
  90.    
  91.     { 2813.9641,2141.0579,19.5484, "Some Apartments",       "Candles",                               500 },
  92.     { 2813.9641,2141.0579,19.5484, "Some Apartments",       "Housemaids",                           1500 },
  93.     { 2813.9641,2141.0579,19.5484, "Some Apartments",       "Mail",                                  400 },
  94.     { 2813.9641,2141.0579,19.5484, "Some Apartments",       "Dirty Socks",                           400 },
  95.    
  96.     { 2000.6158,1564.7700,15.5439, "the Pirate Ship",       "Broadswords",                           900 },
  97.     { 2000.6158,1564.7700,15.5439, "the Pirate Ship",       "Scurvy Oranges",                        600 },
  98.     { 2000.6158,1564.7700,15.5439, "the Pirate Ship",       "Pirate Flags",                          700 },
  99.     { 2000.6158,1564.7700,15.5439, "the Pirate Ship",       "Eyepatches",                            500 },
  100.     { 2000.6158,1564.7700,15.5439, "the Pirate Ship",       "Trained Parrots",                       800 },
  101.  
  102.     /* SEXSHOP & STRIP CLUBS */
  103.     { 2075.5208,2060.0713,26.7196, "the Sex Shop",          \"Popz' Dildos",                        1500 },
  104.     { 2075.5208,2060.0713,26.7196, "the Sex Shop",          "Gimpsuits",                            1500 },
  105.     { 2075.5208,2060.0713,26.7196, "the Sex Shop",          "XXL Dildos",                           1500 },
  106.     { 2075.5208,2060.0713,26.7196, "the Sex Shop",          "Creepy Old Men",                        700 },
  107.    
  108.     { 702.0735,1945.0063,5.7520,   "the Strip Club",        "Thongs",                                500 },
  109.     { 702.0735,1945.0063,5.7520,   "the Strip Club",        "Imported Whores",                       800 },
  110.     { 702.0735,1945.0063,5.7520,   "the Strip Club",        "Steel Poles",                           800 },
  111.     { 702.0735,1945.0063,5.7520,   "the Strip Club",        "slappertassus",                         900 },
  112.  
  113.     /* BANKS + GENERAL STORES */
  114.     { 2199.3818,1991.1266,16.9405, "the Bank",              "Haxed Cash",                            750 },
  115.     { 2254.5508,2386.3472,19.8632, "the Bank",              \"Neonkiller's Milk",                     700 },
  116.     { 2254.5508,2386.3472,19.8632, "the Bank",              "Sprunk",                                500 },
  117.     { 2254.5508,2386.3472,19.8632, "the Bank",              \"Wong's Noodels",                       500 },
  118.     { 2254.5508,2386.3472,19.8632, "the Bank",              \"Pig's Ears",                           400 },
  119.  
  120.     /* AMMUNATIONS */
  121.     { 2548.8655,2081.3513,15.8636, "North Ammunation",      \"Guns n' Stuff",                       2000 },
  122.     { 2176.1409,943.4987,15.8532,  "South Ammunation",      \"Guns n' Stuff",                       2000 },
  123.     { 766.7244,1871.6785,8.2699,   "Desert Ammunation",     \"Guns n' Stuff",                       2000 },
  124.     { 2548.8655,2081.3513,15.8636, "North Ammunation",      "Sawnoff Shotguns",                      700 },
  125.     { 2176.1409,943.4987,15.8532,  "South Ammunation",      "Sawnoff Shotguns",                      700 },
  126.     { 766.7244,1871.6785,8.2699,   "Desert Ammunation",     "Sawnoff Shotguns",                      700 },
  127.  
  128.     /* CONSTRUCTION SITES */
  129.     { 2458.3743,1918.7761,11.0690, "the Construction Site", "Cement Mixers",                         600 },
  130.     { 2458.3743,1918.7761,11.0690, "the Construction Site", "Bricks",                                400 },
  131.     { 2458.3743,1918.7761,11.0690, "the Construction Site", "Steel Pipes",                           700 },
  132.     { 2458.3743,1918.7761,11.0690, "the Construction Site", "Cement",                                900 },
  133.     { 2458.3743,1918.7761,11.0690, "the Construction Site", \"dugi's Hardhats",                      600 },
  134.  
  135.     /* CHURCHES */
  136.     { 2447.7117,1273.7064,10.9958, "the Church",            "Bridal Dresses",                       1500 },
  137.     { 2447.7117,1273.7064,10.9958, "the Church",            "Holy Water",                            700 },
  138.     { 2447.7117,1273.7064,10.9958, "the Church",            "Blessed Crosses",                       700 },
  139.    
  140.     { 1533.4536,776.9311,10.9976,  "the Church",            "Bobblehead Jesus Figurines",            400 },
  141.     { 1533.4536,776.9311,10.9976,  "the Church",            "Vicar Robes",                           800 },
  142.     { 1533.4536,776.9311,10.9976,  "the Church",            "Leaflets",                              200 },
  143.    
  144.     { 2477.0249,921.7415,10.9957,  "the Church",            "Vicar Robes",                           800 },
  145.     { 2477.0249,921.7415,10.9957,  "the Church",            "Leaflets",                              200 },
  146.     { 2477.0249,921.7415,10.9957,  "the Church",            "Holy Water",                            700 },
  147.  
  148.     /* CLUBS */
  149.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Fluorescent Tops",                      500 },
  150.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Vodka",                                 600 },
  151.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Sprunk",                                500 },
  152.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Icecubes",                              400 },
  153.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Tequila",                               900 },
  154.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Shot Glasses",                          500 },
  155.     { 2506.0129,1238.0909,20.4913, "the Nightclub",         "Gay Bartenders",                       1100 },
  156.  
  157.  
  158.     /* CASINOS*/
  159.     { 1998.8507,1000.7745,39.2668, "4 Dragons Casino",      "Casino Chips",                          900 },
  160.     { 1998.8507,1000.7745,39.2668, "4 Dragons Casino",      \"Wong's Noodels",                       500 },
  161.     { 1998.8507,1000.7745,39.2668, "4 Dragons Casino",      "Cheating Dealers",                     1100 },
  162.    
  163.     { 2198.2810,1715.6333,34.6896, \"Caligula's Casino",    "Casino Chips",                          900 },
  164.     { 2198.2810,1715.6333,34.6896, \"Caligula's Casino",    "Cheating Dealers",                     1100 },
  165.    
  166.     { 2227.8196,1838.5157,20.2101, \"The Clown's Pocket",   "Novelty Horns",                         600 },
  167.     { 2227.8196,1838.5157,20.2101, \"The Clown's Pocket",   "Never Ending Hankerchiefs",             800 },
  168.     { 2227.8196,1838.5157,20.2101, \"The Clown's Pocket",   "Cheating Dealers",                     1100 },
  169.    
  170.     { 1936.7249,1362.6162,16.0038, "The High Roller",       "Casino Chips",                          900 },
  171.     { 1936.7249,1362.6162,16.0038, "The High Roller",       "Cheating Dealers",                     1100 },
  172.  
  173.  
  174.     /* PUBLIC SERVICES (COPS, HOSPITALS ETC) */
  175.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Surgeon Masks",                         600 },
  176.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Defibrillators",                       1600 },
  177.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Beds",                                 1000 },
  178.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Antiseptic Fluid",                      600 },
  179.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Piss Bags",                             400 },
  180.     { 1612.3298,1771.7421,37.4908, "the Hospital",          "Mops",                                  500 },
  181.    
  182.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       \"Guns n' Stuff",                       2000 },
  183.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       "Donuts",                                600 },
  184.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       "Vibrators",                             700 },
  185.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       "Planted Evidence",                     1000 },
  186.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       "Sirens",                                700 },
  187.     { 2268.0715,2452.0437,47.1515, "the Cop Station",       "Radios",                                500 },
  188.  
  189.     /* STADIUMS */
  190.     { 1455.6696,2228.6482,33.3648, "the Baseball Stadium",  "Foam Fingers",                          800 },
  191.     { 1455.6696,2228.6482,33.3648, "the Baseball Stadium",  "Signed Bats",                          1000 },
  192.     { 1455.6696,2228.6482,33.3648, "the Baseball Stadium",  "Mitts",                                 700 },
  193.     { 1455.6696,2228.6482,33.3648, "the Baseball Stadium",  "Baseballs",                             200 },
  194.  
  195.     /* INDUSTRIAL */
  196.     { 2617.0955,2721.3472,36.7162, "K.A.C.C",               "Oil Drums",                             400 },
  197.     { 2617.0955,2721.3472,36.7162, "K.A.C.C",               "Waste Containers",                      700 },
  198.     { 2843.5806,1618.4302,10.9968, "the Train Depo",        "Train Bits",                           1300 },
  199.  
  200.     /* AIRPORTS & BASES */
  201.     { 1285.3234,1609.7433,20.0825, "LV Airport",            "Rustler Wings",                        1400 },
  202.     { 1285.3234,1609.7433,20.0825, "LV Airport",            "Lost Luggage",                          300 },
  203.    
  204.     { 227.1653,1891.8550,17.8501,  "Area 51",               "Green Goo",                            3000 },
  205.     { 227.1653,1891.8550,17.8501,  "Area 51",               "Secret Documents",                     5000 },
  206.     { 227.1653,1891.8550,17.8501,  "Area 51",               "UFO Parts",                            2000 },
  207.    
  208.     { 361.2246,2536.4172,16.8709,  "Verdant Meadows",       "Maverick Rotors",                      1200 },
  209.     { 361.2246,2536.4172,16.8709,  "Verdant Meadows",       "Broken Plane Parts",                    700 },
  210.  
  211.     /* TRAIN STATIONS */
  212.     { 2875.9961,1298.2185,11.0695, "the Train Station",     "Crap Magazines",                        300 },
  213.     { 2875.9961,1298.2185,11.0695, "the Train Station",     "Sprunk",                                500 },
  214.  
  215.     /* MARINAS, JETTIES ETC */
  216.     { 2292.6072,531.5341,1.9708,   "the Marina",            "Rudders",                              1000 },
  217.     { 2292.6072,531.5341,1.9708,   "the Marina",            "Boat Engines",                         2000 },
  218.     { 2292.6072,531.5341,1.9708,   "the Marina",            "Anchors",                               500 },
  219.  
  220.     /* TRAILER PARKS */
  221.     { 776.3238,1984.6252,5.5130,   "the Trailer Park",      "Moonshine",                             200 },
  222.     { 776.3238,1984.6252,5.5130,   "the Trailer Park",      "NASCAR Posters",                        500 },
  223.     { 776.3238,1984.6252,5.5130,   "the Trailer Park",      "White Trash",                           600 },
  224.  
  225.     /* SPORTS */
  226.     { 1340.0388,2772.2456,11.0011, "the Golf Course",       "Golf Clubs",                            600 },
  227.     { 1340.0388,2772.2456,11.0011, "the Golf Course",       "Golf Bags",                             500 },
  228.     { 1340.0388,2772.2456,11.0011, "the Golf Course",       "Caddy Engines",                         600 },
  229.     { 1340.0388,2772.2456,11.0011, "the Golf Course",       "Golf Balls",                            400 },
  230.    
  231.     { 1900.3693,2860.7280,11.0120, "the Tennis Courts",     "Tennis Balls",                          400 },
  232.     { 1900.3693,2860.7280,11.0120, "the Tennis Courts",     "Tennis Racquets",                       500 },
  233.  
  234.     /* FARMS ETC */
  235.     { 1929.0171,177.0101,37.1758,  "the Farm",              "Corn",                                  400 },
  236.     { 1929.0171,177.0101,37.1758,  "the Farm",              "Hay",                                   300 },
  237.     { 1929.0171,177.0101,37.1758,  "the Farm",              "Manure",                                500 },
  238.     { 1929.0171,177.0101,37.1758,  "the Farm",              \"ACE's Sheep",                          2000 }
  239.    
  240.    
  241.    
  242. };
  243.  
  244.  
  245. public OnFilterScriptInit()
  246. {
  247.  
  248.  
  249.     print( "[cargoheli] Helicopter Cargo missions by blewert loaded." );
  250.  
  251.     #if defined INCLUDE_MAP
  252.    
  253.         print( "[cargoheli] You have included the map." );
  254.        
  255.         #if defined INCLUDE_MAP_VEHICLES
  256.        
  257.             print( "[cargoheli] You have included the map vehicles." );
  258.            
  259.         #endif
  260.        
  261.     #endif
  262.  
  263.     #if defined CARGO_CP_COORDS
  264.    
  265.         printf( "[cargoheli] The cargo checkpoint will display at %f, %f, %f.", CARGO_CP_COORDS );
  266.        
  267.     #endif
  268.    
  269.     gCText = Create3DTextLabel( "{247550}Helicopter Cargo Missions\nPress {C90000}SPACE", 0xFFFFFFFF, CARGO_CP_COORDS, 100.0, 0 );
  270.    
  271.     #if defined INCLUDE_MAP
  272.    
  273.         #if defined INCLUDE_MAP_VEHICLES
  274.        
  275.             AddStaticVehicleEx(548,1692.83618164,1203.63134766,36.68912506,272.00000000,-1,-1,15); //Cargobob
  276.             AddStaticVehicleEx(548,1692.44140625,1185.74121094,36.68912506,271.99951172,-1,-1,15); //Cargobob
  277.            
  278.         #endif
  279.        
  280.         CreateObject(10184,1706.46606445,1250.02600098,11.82454872,0.00000000,0.00000000,90.00000000); //object(sfcopdr) (1)
  281.         CreateObject(16775,1729.51342773,1235.25329590,30.18077087,0.00000000,0.00000000,0.00000000); //object(door_savhangr2) (1)
  282.         CreateObject(2977,1728.21057129,1248.39697266,33.78906250,0.00000000,0.00000000,0.00000000); //object(kmilitary_crate) (1)
  283.         CreateObject(2977,1726.20996094,1248.42675781,33.78906250,0.00000000,0.00000000,0.00000000); //object(kmilitary_crate) (3)
  284.         CreateObject(2886,1733.17932129,1235.15075684,31.18988419,0.00000000,0.00000000,0.00000000); //object(sec_keypad) (1)
  285.         CreateObject(7025,1686.70214844,1236.80249023,37.21684265,0.00000000,0.00000000,0.00000000); //object(plantbox1) (1)
  286.         CreateObject(2973,1735.52465820,1241.35546875,33.78358459,0.00000000,0.00000000,0.00000000); //object(k_cargo2) (1)
  287.         CreateObject(2973,1735.52648926,1238.18359375,33.78906250,0.00000000,0.00000000,0.00000000); //object(k_cargo2) (2)
  288.         CreateObject(2973,1735.52001953,1241.36035156,36.24449158,0.00000000,0.00000000,0.00000000); //object(k_cargo2) (3)
  289.         CreateObject(8885,1695.55883789,1168.70568848,37.21684265,0.00000000,0.00000000,0.00000000); //object(vgsefrght03) (1)
  290.         CreateObject(1391,1668.65917969,1253.14111328,42.20217896,0.00000000,0.00000000,0.00000000); //object(twrcrane_s_03) (1)
  291.         CreateObject(1388,1668.57116699,1253.28210449,54.75437927,0.00000000,0.00000000,226.00000000); //object(twrcrane_s_04) (1)
  292.         CreateObject(11406,1690.99340820,1231.56359863,54.08903122,0.00000000,0.00000000,316.00000000); //object(acwinch1b_sfs01) (1)
  293.         CreateObject(8885,1690.62902832,1245.88879395,37.21684265,0.00000000,0.00000000,0.00000000); //object(vgsefrght03) (2)
  294.         CreateObject(3934,1693.35351562,1204.00622559,33.78906631,0.00000000,0.00000000,0.00000000); //object(helipad01) (1)
  295.         CreateObject(3934,1693.63769531,1185.82226562,33.78906250,0.00000000,0.00000000,0.00000000); //object(helipad01) (2)
  296.         CreateObject(7025,1683.77551270,1221.69226074,37.21684265,0.00000000,0.00000000,270.00000000); //object(plantbox1) (2)
  297.        
  298.     #endif
  299.  
  300.  
  301.  
  302.  
  303.     return 1;
  304. }
  305.  
  306. public OnFilterScriptExit()
  307. {
  308.  
  309.     Delete3DTextLabel( gCText );
  310.     return 1;
  311.    
  312. }
  313.  
  314. public OnPlayerDisconnect(playerid, reason)
  315. {
  316.  
  317.     purgePlayerCargoVars( playerid );
  318.  
  319.     return 1;
  320.    
  321. }
  322.  
  323. stock purgePlayerCargoVars( playerid )
  324. {
  325.  
  326.     /* Set the pos var to 0 */
  327.     gCCurrentItem[ playerid ][ CPosX ] = float(0);
  328.     gCCurrentItem[ playerid ][ CPosY ] = float(0);
  329.     gCCurrentItem[ playerid ][ CPosZ ] = float(0);
  330.    
  331.     format(gCCurrentItem[ playerid ][ szCItemName ], 128, "%s", "");
  332.     format(gCCurrentItem[ playerid ][ szCLocName  ], 128, "%s", "");
  333.  
  334.     gCCurrentItem[ playerid ][ CiPrice ] = 0;
  335.     gCMultiplier [ playerid ]            = 0;
  336.     gbCInCargo   [ playerid ]            = false;
  337.    
  338.     if( IsValidObject( gCPlayerObj[ playerid ] ) )
  339.     {
  340.         DestroyObject( gCPlayerObj[ playerid ] );
  341.        
  342.     }
  343.    
  344. }
  345.  
  346. public cargoOnFail( playerid )
  347. {
  348.  
  349.     if( gbCInCargo[ playerid ] )
  350.     {
  351.    
  352.         //They're in a mission
  353.  
  354.         //Delete player variables.
  355.         purgePlayerCargoVars( playerid );
  356.  
  357.         //Remove checkpoint
  358.         DisablePlayerCheckpoint( playerid );
  359.  
  360.         SendClientMessage( playerid, 0xFFFFFFFF, \"You have failed the {247550}cargo mission.");
  361.         GameTextForPlayer( playerid, \"~r~Cargo Mission Failed.", 3000, 3 );
  362.  
  363.     }
  364.  
  365.  
  366. }
  367.  
  368. public OnPlayerDeath(playerid, killerid, reason)
  369. {
  370.  
  371.     cargoOnFail( playerid );
  372.     return 1;
  373.    
  374. }
  375.  
  376. public OnPlayerSpawn(playerid)
  377. {
  378.  
  379.     cargoOnFail( playerid );
  380.     return 1;
  381.    
  382. }
  383.  
  384. public OnPlayerExitVehicle(playerid, vehicleid)
  385. {
  386.  
  387.     cargoOnFail( playerid );
  388.     return 1;
  389.    
  390. }
  391.  
  392. public OnPlayerStateChange(playerid, newstate, oldstate)
  393. {
  394.  
  395.     if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
  396.     {
  397.         //They got in a car
  398.  
  399.         if( IsValidCargoHeli( playerid ) )
  400.         {
  401.        
  402.             if( !gbCInCargo[ playerid ] )
  403.             {
  404.            
  405.                 SendClientMessage( playerid, 0xFFFFFFFF, "This helicopter is a valid {247550}cargo helicopter.{FFFFFF} You can transport cargo with it." );
  406.  
  407.             }
  408.  
  409.         }
  410.        
  411.     }
  412.     else if( oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT )
  413.     {
  414.    
  415.         //If they somehow magically got out without calling OnPlayerExitVehicle
  416.         cargoOnFail( playerid );
  417.        
  418.     }
  419.    
  420.     return 1;
  421. }
  422.  
  423. public OnPlayerEnterCheckpoint(playerid)
  424. {
  425.  
  426.     if( gbCInCargo[ playerid ] )
  427.     {
  428.    
  429.         //Remove checkpoint
  430.         DisablePlayerCheckpoint( playerid );
  431.  
  432.         //Give them the cash, the dough, the dosh, the moolah, the wonga
  433.         GivePlayerMoney( playerid, ( gCMultiplier[ playerid ] * gCCurrentItem[ playerid ][ CiPrice ]) );
  434.  
  435.         new szMessage[  128 ],
  436.             szGameText[ 128 ];
  437.  
  438.         //Format client message
  439.         format(
  440.        
  441.                 szMessage,
  442.                 sizeof( szMessage ),
  443.                 "Success! You transported %d crate(s) of {247550}%s{FFFFFF} to %s for {247550}$%d!",
  444.                 gCMultiplier[ playerid ],
  445.                 gCCurrentItem[ playerid ][ szCItemName ],
  446.                 gCCurrentItem[ playerid ][ szCLocName  ],
  447.                 ( gCMultiplier[ playerid ] * gCCurrentItem[ playerid ][ CiPrice ] )
  448.                
  449.               );
  450.  
  451.         //Format gametext message
  452.         format( szGameText, sizeof( szGameText ), \"~r~Cargo Mission Completed.~n~~n~~w~$%d", ( gCMultiplier[ playerid ] * gCCurrentItem[ playerid ][ CiPrice ] ) );
  453.        
  454.         GameTextForPlayer( playerid, szGameText, 3000, 3 );
  455.         //Send client message.
  456.         SendClientMessage( playerid, 0xFFFFFFFF, szMessage );
  457.        
  458.         //Play mission complete sound
  459.         PlayerPlaySound( playerid,  1058, 0, 0, 0 );
  460.        
  461.         //Set them not to be in cargo mission
  462.         purgePlayerCargoVars( playerid );
  463.        
  464.     }
  465.     return 1;
  466.    
  467. }
  468.  
  469. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  470. {
  471.  
  472.     if( IsPlayerInAnyVehicle(playerid) )
  473.     {
  474.    
  475.         if( PRESSED(KEY_HANDBRAKE) )
  476.         {
  477.        
  478.             //If they pressed sprint
  479.  
  480.             if( IsPlayerInRangeOfPoint( playerid, 9.0, CARGO_CP_COORDS ) )
  481.             {
  482.            
  483.                 if( gbCInCargo[ playerid ] )           return SendClientMessage( playerid, 0xFFFFFFFF, "You're already in a {247550}cargo mission." );
  484.                 if( !IsValidCargoHeli( playerid ) )     return SendClientMessage( playerid, 0xFFFFFFFF, "You need a valid {247550}cargo helicopter." );
  485.  
  486.                 //If they're in a valid heli and not in cargo mission
  487.  
  488.                 new nItemRandMax;
  489.  
  490.                 switch( GetVehicleModel( GetPlayerVehicleID( playerid ) ) )
  491.                 {
  492.                
  493.                     case 497, 487: nItemRandMax = 3; //Mavericks
  494.                     case 469:      nItemRandMax = 2; //Sparrow
  495.                     case 548, 417: nItemRandMax = 15; //Cargobob, Leviathan
  496.                     case 563:      nItemRandMax = 10; //Raindance
  497.  
  498.                 }
  499.  
  500.                 new nItemRand = ( random(nItemRandMax) + 1 ), //Random amount of items
  501.                     nArrRand  = random( sizeof( _CARGO_LOCATIONS_ ) ), //Random position in array
  502.                     szMessage[ 128 ];
  503.  
  504.  
  505.                 //Put them in mission
  506.                 gbCInCargo[ playerid ] = true;
  507.  
  508.                 gCMultiplier[ playerid ]  = nItemRand;
  509.                 gCCurrentItem[ playerid ] = _CARGO_LOCATIONS_[ nArrRand ];
  510.  
  511.                 //Format client message
  512.                 format( szMessage, sizeof( szMessage ),
  513.  
  514.                         "Transport %d crate(s) of {247550}%s{FFFFFF} to %s for {247550}$%d!",
  515.  
  516.                         gCMultiplier[ playerid ],
  517.                         gCCurrentItem[ playerid ][ szCItemName ],
  518.                         gCCurrentItem[ playerid ][ szCLocName  ],
  519.                         ( gCCurrentItem[ playerid ][ CiPrice ] * gCMultiplier[ playerid ] ) );
  520.  
  521.                 //Send client message.
  522.                 SendClientMessage( playerid, 0xFFFFFFFF, szMessage );
  523.  
  524.                 //Set their checkpoint
  525.                 SetPlayerCheckpoint( playerid,
  526.                                   gCCurrentItem[ playerid ][ CPosX ],
  527.                                   gCCurrentItem[ playerid ][ CPosY ],
  528.                                   gCCurrentItem[ playerid ][ CPosZ ],
  529.                                   5.0 );
  530.  
  531.                 gCPlayerObj[ playerid ] = CreateObject( CRATE_OBJ, 5000.0, 0.0, 1550.0, 0.0, 0.0, 0.0 );
  532.  
  533.                 AttachObjectToVehicle(gCPlayerObj[ playerid ], GetPlayerVehicleID(playerid), 0.000000, 0.700000, -0.410001, 0.000000, 180.000000, 0.000000);
  534.  
  535.             }
  536.            
  537.         }
  538.        
  539.     }
  540.    
  541.     return 1;
  542. }
  543.  
  544. stock IsValidCargoHeli( playerid )
  545. {
  546.  
  547.     if( !IsPlayerInAnyVehicle( playerid ) ) return false;
  548.  
  549.     new bool:bResult;
  550.        
  551.     switch( GetVehicleModel( GetPlayerVehicleID( playerid ) ) )
  552.     {
  553.    
  554.         case 548, 417, 487, 497, 563, 469: bResult = true ;
  555.         default:                           bResult = false;
  556.        
  557.     }
  558.     return bResult;
  559.    
  560. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement