newshipment.pwn 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Re-vamped Trucker Job
  11. Westen
  12. Next Generation Gaming, LLC
  13. (created by Next Generation Gaming Development Team)
  14. * Copyright (c) 2016, Next Generation Gaming, LLC
  15. *
  16. * All rights reserved.
  17. *
  18. * Redistribution and use in source and binary forms, with or without modification,
  19. * are not permitted in any case.
  20. *
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. [NOTE: OED approved revamp. Submitted to devcp via Bando. Documentation: https://docs.google.com/document/d/1nsrKfBYtC7BSN6Z36r1lkoi_ipjVjRBW3YlfHZdBpB4]
  34. NR - pending feedback from Sundawn.
  35. LSPD - pending feedback.
  36. AddPlayerClass(7,1535.3512,-1675.4783,13.3828,269.3415,0,0,0,0,0,0); // Bando
  37. Add Matthew's thing from <18:51:49> "Matthew": AddPlayerClass(172,999.1709,-1131.7074,23.8281,358.4189,0,0,0,0,0,0); // Cattle
  38. <18:54:17> "Matthew": AddPlayerClass(172,1662.7423,-1563.4584,13.3906,356.6844,0,0,0,0,0,0); // Fertilizer
  39. */
  40. #include <YSI\y_hooks>
  41. #define MAX_SHIPMENTS 24
  42. new Float:fTruckLoad[3] = {90.0156, -298.8802, 1.5781};
  43. new Float:fTrailerLoad[3] = {277.5990, 1355.1257, 10.5859};
  44. // FF0000 - illegal
  45. // 02CF09 - legals
  46. new ShipmentContents[MAX_SHIPMENTS][4][] =
  47. {
  48. {"{02CF09}Electronics", "Blueberry Gas Station", "1", "100"},
  49. {"{02CF09}Alcohol", "Ten Green Bottles, San Fierro", "2", "720"},
  50. {"{02CF09}Groceries & Clothing", "Dillimore General Store", "2", "400"},
  51. {"{FF0000}Body Parts", "Zombotech Inc, San Fierro", "1", "800"},
  52. {"{02CF09}Construction Materials", "San Fierro Construction", "1", "650"},
  53. {"{02CF09}Medical Equipment", "FDSA Headquarters", "2", "750"},
  54. {"{FF0000}Illegal Hunting Equipment", "Ammunation, St Lawrence Blvd", "1", "925"},
  55. {"{02CF09}Paper Targets", "Ammunation, St Lawrence Blvd", "1", "700"},
  56. {"{02CF09}Kerosene", "Los Santos International", "3", "500"}, // Fuel prices are lower for fuel runs because of how much larger the cargo is.
  57. {"{02CF09}Old Clothing", "Victim, San Fierro", "2", "685"},
  58. {"{FF0000}Red Diesel", "Xoomer Gas, San Fierro", "3", "1025"},
  59. {"{FF0000}NOS Canisters", "URL Race Track, San Fierro", "1", "700"},
  60. {"{02CF09}Paper & Stationary", "FBI Academy, Queen's", "1", "600"},
  61. {"{02CF09}Tracking Equipment", "FBI HQ, Rodeo", "1", "680"},
  62. {"{FF0000}Methamphetamine", "FBI HQ, Rodeo", "1", "1200"}, // A lot more money as delivery to the fbi hq is rather risky.
  63. {"{02CF09}Hay Bales", "Blueberry Farm", "2", "450"},
  64. {"{FF0000}Corpses", "Hunter Quarry", "2", "960"}, // Change rot on this.
  65. {"{FF0000}Explosives & Rifles", "Montgomery", "1", "600"},
  66. {"{02CF09}Alcohol", "Big S' Liquor Store", "1", "500"},
  67. {"{02CF09}Condoms", "Cam's Brothel", "1", "550"}, // Request by Cam
  68. {"{02CF09}Sushi", "Black Hand Triads HQ", "1", "675"},
  69. {"{FF0000}Firearms", "LV Gun Store", "2", "1010"},
  70. {"{02CF09}Gas", "LV Xoomer Gas", "3", "858"},
  71. {"{02CF09}Car Parts", "LV PnS", "1", "750"}
  72. };
  73. new Float:ShipmentLocations[MAX_SHIPMENTS][6] =
  74. {
  75. {115.8548, -135.9694, 1.6385}, // Electronics
  76. {-1810.1267, -352.6231, 20.3371, -1813.4424, -348.0277, 21.3356}, // Alcohol
  77. {698.8000, -594.9865, 16.3359, 698.5775, -590.7156, 16.3359}, // G & C
  78. {-1997.0857, 700.9221, 45.2969}, // Body Parts
  79. {-2022.8159, 389.8372, 35.1719}, // Construction Materials
  80. {673.3553, -1571.2716, 15.6281, 664.3707, -1572.0260, 15.6281}, // Medical Equipment
  81. {1383.7051, -1246.2075, 13.5469}, // Illegal Hunting Equip
  82. {1383.7051, -1246.2075, 13.5469}, // Paper Targets
  83. {277.5990, 1355.1257, 10.5859, 1910.1041, -2272.8960, 13.5469},// Kerosene
  84. {-1683.3289, 938.1293, 24.7422, -1691.6877, 947.9648, 24.8906}, // Old clothing
  85. {277.5990, 1355.1257, 10.5859, -1706.5154, 385.7684, 7.1872}, // Red Diesel
  86. {-2074.8513, -89.8175, 35.1641}, // NOS Canisters.
  87. {-2406.5376, 315.9322, 35.1719}, // Paper Stationary
  88. {277.0599, -1573.6721, 33.0922}, //FBI LEGAL
  89. {277.0599, -1573.6721, 33.0922}, // FBI illegal
  90. {-34.6157, 81.0343, 3.1096, -60.1936, 83.7532, 3.1172}, // Hay Bales
  91. {684.2184, 801.8275, -30.2051, 681.3965, 823.9722, -26.7837}, // Corpses
  92. {1321.7809, 333.0775, 19.4084}, // Requested by Joseph Greaves.
  93. {873.9268, -1570.9594, 13.5391}, // Requested by Thomas
  94. {-175.7383, 1124.4711, 19.7500}, // Requested by Cam
  95. {1567.8481, -1876.9060, 13.3828}, // bht sushi
  96. {2177.3010, 968.3670, 10.6783, 2177.5491, 961.0823, 10.8203}, // firearms
  97. {277.5990, 1355.1257, 10.5859, 2120.0247, 904.4611, 10.8203}, // xoomer gas lv
  98. {2414.4277, 1486.7198, 10.8271} // pns lv
  99. };
  100. /*new ShipmentPrices[MAX_SHIPMENTS] =
  101. {
  102. 100,
  103. 720,
  104. 400,
  105. 800,
  106. 650,
  107. 750
  108. };
  109. new ShipmentTypes[MAX_SHIPMENTS] =
  110. {
  111. 1,
  112. 2,
  113. 2,
  114. 1,
  115. 1,
  116. 1
  117. };
  118. */
  119. new ShipmentTrucks[13][3]; // 0 = id, 1 = model, 2 = cargo max amt.
  120. stock IsATrucker(playerid)
  121. {
  122. if(PlayerInfo[playerid][pJob] != 20 && PlayerInfo[playerid][pJob2] != 20 && PlayerInfo[playerid][pJob3] != 20) return 0;
  123. return 1;
  124. }
  125. stock IsATruck(vehicleid)
  126. {
  127. new model = GetVehicleModel(vehicleid);
  128. switch(model)
  129. {
  130. case 403, 414, 440, 455, 456, 499, 515: return 1; // Mule, Yankee, Benson, Rumpo
  131. default: return 0;
  132. }
  133. }
  134. stock IsTrailer(vehicleid)
  135. {
  136. new model = GetVehicleModel(vehicleid);
  137. switch(model)
  138. {
  139. case 584, 450, 435, 591: return 1;
  140. default: return 0;
  141. }
  142. return 0;
  143. }
  144. stock IsTruckingVehicle(vehicleid)
  145. {
  146. for(new i = 0; i < sizeof ShipmentTrucks; i++)
  147. {
  148. if(vehicleid == ShipmentTrucks[i][0]) return 1;
  149. }
  150. return 0;
  151. }
  152. stock GetVehicleCargoSize(modelid)
  153. {
  154. // This function takes a vehicle's model and returns the cargo size for that vehicle.
  155. switch(modelid)
  156. {
  157. case 403: return 60;
  158. case 414: return 30;
  159. case 440: return 15;
  160. case 455: return 80;
  161. case 456: return 35;
  162. case 499: return 25;
  163. case 515: return 60;
  164. default: return 20;
  165. }
  166. return 0;
  167. }
  168. stock GetVehicleCargo(vehicleid)
  169. {
  170. format(szMiscArray, sizeof szMiscArray, "%s\n", ShipmentContents[TruckHolding[vehicleid]]);
  171. return szMiscArray;
  172. }
  173. stock ShowLoadTruckDialog(playerid)
  174. {
  175. // Generate a random set of 10 values from the current ones.
  176. for(new i = 0; i < 10; i++)
  177. {
  178. new iRand = random(sizeof ShipmentContents);
  179. PlayerInfo[playerid][pShipmentOptions][i] = iRand;
  180. }
  181. szMiscArray[0] = 0; // Reset the string so we don't have any funky string bugs.
  182. format(szMiscArray, sizeof szMiscArray, "Contents\tLocation\tPrice Per Kilogram\n");
  183. new string[1024];
  184. for(new i = 0; i < 10; i++)
  185. {
  186. format(string, sizeof string, "%s\t%s\t$%s/kg\n", ShipmentContents[PlayerInfo[playerid][pShipmentOptions][i]][0], ShipmentContents[PlayerInfo[playerid][pShipmentOptions][i]][1], number_format(strval(ShipmentContents[PlayerInfo[playerid][pShipmentOptions][i]][3])));
  187. strcat(szMiscArray, string, sizeof szMiscArray);
  188. }
  189. ShowPlayerDialogEx(playerid, DIALOG_SHIPMENT_OPTIONS, DIALOG_STYLE_TABLIST_HEADERS, "Shipment Contractor - Loading", szMiscArray, "Select", "Cancel");
  190. }
  191. hook OnGameModeInit()
  192. {
  193. printf("Loading re-vamped trucker data.");
  194. ShipmentTrucks[0][0] = CreateVehicle(414, 132.8109, -250.2448, 1.6718, 90.0, 0, 0, 300, 0);
  195. ShipmentTrucks[0][1] = GetVehicleModel(ShipmentTrucks[0][0]);
  196. ShipmentTrucks[0][2] = GetVehicleCargoSize(ShipmentTrucks[0][1]);
  197. ShipmentTrucks[1][0] = CreateVehicle(414, 132.5210, -256.6861, 1.6719, 90.0, 0, 0, 300, 0);
  198. ShipmentTrucks[1][1] = GetVehicleModel(ShipmentTrucks[1][0]);
  199. ShipmentTrucks[1][2] = GetVehicleCargoSize(ShipmentTrucks[1][1]);
  200. ShipmentTrucks[2][0] = CreateVehicle(456, 131.9196, -262.5940, 1.7513, 90.0, 0, 0, 300, 0);
  201. ShipmentTrucks[2][1] = GetVehicleModel(ShipmentTrucks[2][0]);
  202. ShipmentTrucks[2][2] = GetVehicleCargoSize(ShipmentTrucks[2][1]);
  203. ShipmentTrucks[3][0] = CreateVehicle(456, 131.9602, -269.1464, 1.7521, 90.0, 0, 0, 300, 0);
  204. ShipmentTrucks[3][1] = GetVehicleModel(ShipmentTrucks[3][0]);
  205. ShipmentTrucks[3][2] = GetVehicleCargoSize(ShipmentTrucks[3][1]);
  206. ShipmentTrucks[4][0] = CreateVehicle(499, 132.9803, -275.3911, 1.5695, 90.0, 0, 0, 300, 0);
  207. ShipmentTrucks[4][1] = GetVehicleModel(ShipmentTrucks[4][0]);
  208. ShipmentTrucks[4][2] = GetVehicleCargoSize(ShipmentTrucks[4][1]);
  209. ShipmentTrucks[5][0] = CreateVehicle(499, 133.1511, -280.7554, 1.5690, 90.0, 0, 0, 300, 0);
  210. ShipmentTrucks[5][1] = GetVehicleModel(ShipmentTrucks[5][0]);
  211. ShipmentTrucks[5][2] = GetVehicleCargoSize(ShipmentTrucks[5][1]);
  212. ShipmentTrucks[6][0] = CreateVehicle(440, 124.9999, -240.6001, 1.6956, 180.0, 0, 0, 300, 0);
  213. ShipmentTrucks[6][1] = GetVehicleModel(ShipmentTrucks[6][0]);
  214. ShipmentTrucks[6][2] = GetVehicleCargoSize(ShipmentTrucks[6][1]);
  215. ShipmentTrucks[7][0] = CreateVehicle(403, 45.5410, -225.8415, 2.2696, 280.0, 0, 0, 300, 0);
  216. ShipmentTrucks[7][1] = GetVehicleModel(ShipmentTrucks[7][0]);
  217. ShipmentTrucks[7][2] = GetVehicleCargoSize(ShipmentTrucks[7][1]);
  218. ShipmentTrucks[8][0] = CreateVehicle(403, 45.3290, -230.3412, 2.2714, 280.0, 0, 0, 300, 0);
  219. ShipmentTrucks[8][1] = GetVehicleModel(ShipmentTrucks[8][0]);
  220. ShipmentTrucks[8][2] = GetVehicleCargoSize(ShipmentTrucks[8][1]);
  221. ShipmentTrucks[9][0] = CreateVehicle(403, 44.9574, -235.0874, 2.2764, 280.0, 0, 0, 300, 0);
  222. ShipmentTrucks[9][1] = GetVehicleModel(ShipmentTrucks[9][0]);
  223. ShipmentTrucks[9][2] = GetVehicleCargoSize(ShipmentTrucks[9][1]);
  224. ShipmentTrucks[10][0] = CreateVehicle(515, 45.1748, -241.6218, 2.6877, 280, 0, 0, 300, 0);
  225. ShipmentTrucks[10][1] = GetVehicleModel(ShipmentTrucks[10][0]);
  226. ShipmentTrucks[10][2] = GetVehicleCargoSize(ShipmentTrucks[10][1]);
  227. ShipmentTrucks[11][0] = CreateVehicle(515, 44.7679, -247.3265, 2.6832, 280, 0, 0, 300, 0);
  228. ShipmentTrucks[11][1] = GetVehicleModel(ShipmentTrucks[11][0]);
  229. ShipmentTrucks[11][2] = GetVehicleCargoSize(ShipmentTrucks[11][1]);
  230. ShipmentTrucks[12][0] = CreateVehicle(455, 114.0116, -296.5753, 1.5781, 360.0, 0, 0, 300, 0);
  231. ShipmentTrucks[12][1] = GetVehicleModel(ShipmentTrucks[12][0]);
  232. ShipmentTrucks[12][2] = GetVehicleCargoSize(ShipmentTrucks[12][1]);
  233. for(new i = 0; i < sizeof ShipmentTrucks; i++)
  234. {
  235. TruckUsedBy[ShipmentTrucks[i][0]] = -1;
  236. TruckHolding[ShipmentTrucks[i][0]] = -1;
  237. }
  238. printf("Trucker vehicles loaded.");
  239. CreateDynamic3DTextLabel("Truck Loading Location\n{33CCFF}/loadtruck", COLOR_YELLOW, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2], 25.0);
  240. CreateDynamicPickup(1239, 1, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2]);
  241. }
  242. hook OnVehicleDeath(vehicleid, killerid)
  243. {
  244. if(IsTruckingVehicle(vehicleid))
  245. {
  246. TruckHolding[vehicleid] = -1;
  247. TruckUsedBy[vehicleid] = -1;
  248. foreach(new i: Player)
  249. {
  250. if(PlayerInfo[i][pUsingTruck] == vehicleid)
  251. {
  252. PlayerInfo[i][pUsingTruck] = INVALID_VEHICLE_ID;
  253. PlayerInfo[i][pCurrentShipment] = -1;
  254. SendClientMessage(i, COLOR_LIGHTRED, "Your shipment was destroyed!");
  255. if(GetPVarInt(i, "DeliveryStage") > 0 || GetPVarInt(i, "FinishShipment"))
  256. {
  257. DisablePlayerCheckpoint(i);
  258. DeletePVar(i, "DeliveryStage");
  259. DeletePVar(i, "FinishShipment");
  260. }
  261. break;
  262. }
  263. }
  264. }
  265. foreach(new i: Player)
  266. {
  267. if(GetPVarInt(i, "DeliveryTrailer") == vehicleid)
  268. {
  269. SendClientMessage(i, COLOR_LIGHTRED, "Your shipment trailer was destroyed! Your shipment has been cancelled.");
  270. PlayerInfo[i][pUsingTruck] = INVALID_VEHICLE_ID;
  271. PlayerInfo[i][pCurrentShipment] = -1;
  272. SendClientMessage(i, COLOR_LIGHTRED, "Your shipment was destroyed!");
  273. if(GetPVarInt(i, "DeliveryStage") > 0 || GetPVarInt(i, "FinishShipment"))
  274. {
  275. DisablePlayerCheckpoint(i);
  276. DeletePVar(i, "DeliveryStage");
  277. DeletePVar(i, "FinishShipment");
  278. }
  279. }
  280. }
  281. }
  282. hook OnPlayerEnterCheckpoint(playerid)
  283. {
  284. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  285. new shipment = PlayerInfo[playerid][pCurrentShipment];
  286. if(GetPVarInt(playerid, "TruckingCPSet"))
  287. {
  288. DisablePlayerCheckpoint(playerid);
  289. DeletePVar(playerid, "TruckingCPSet");
  290. }
  291. else if(GetPVarInt(playerid, "DeliveryStage") == 1 && shipment != -1 && IsPlayerInRangeOfPoint(playerid, 10.0, ShipmentLocations[shipment][0], ShipmentLocations[shipment][1], ShipmentLocations[shipment][2]))
  292. {
  293. if(!IsPlayerInAnyVehicle(playerid)) return 1;
  294. if(!IsPlayerInVehicle(playerid, PlayerInfo[playerid][pUsingTruck]) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You can only make deliveries in your shipment vehicle.");
  295. DisablePlayerCheckpoint(playerid);
  296. if(/*ShipmentTypes[PlayerInfo[playerid][pCurrentShipment]] == 1*/strval(ShipmentContents[PlayerInfo[playerid][pCurrentShipment]][2]) == 1) // Their shipment is only 1 stage.
  297. {
  298. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have delivered your shipment.");
  299. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Take your truck back to the loading bay and /finishshipment to receive your pay.");
  300. SetPVarInt(playerid, "FinishShipment", 1);
  301. DisablePlayerCheckpoint(playerid);
  302. SetPlayerCheckpoint(playerid, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2], 25.0);
  303. DeletePVar(playerid, "UnloadingCrates");
  304. DeletePVar(playerid, "TruckingCrates");
  305. DeletePVar(playerid, "DeliveryStage");
  306. TruckHolding[PlayerInfo[playerid][pUsingTruck]] = -1;
  307. }
  308. else if(strval(ShipmentContents[PlayerInfo[playerid][pCurrentShipment]][2]) == 2)
  309. {
  310. switch(shipment) // Now because some shipments are unique, we have to specify them here. There's probably a better way to do this but oh well.
  311. {
  312. case 1, 2, 5, 9, 21:
  313. {
  314. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must unload your truck to continue. Open the trunk and then use /unloadshipment.");
  315. new crates = floatround(GetVehicleCargoSize(GetVehicleModel(GetPlayerVehicleID(playerid))) / 10, floatround_ceil) + 1; // Want a minimum of 2 crates.
  316. format(szMiscArray, sizeof szMiscArray, "There are %d crates in the back of the truck. You must deliver them all to proceed.", crates);
  317. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  318. SetPVarInt(playerid, "TruckingCrates", crates);
  319. SetPVarInt(playerid, "DeliveryStage", 2);
  320. }
  321. case 15:
  322. {
  323. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must unload your truck to continue. Open the trunk and then use /unloadshipment.");
  324. new crates = floatround(GetVehicleCargoSize(GetVehicleModel(GetPlayerVehicleID(playerid))) / 10, floatround_ceil) - 1;
  325. if(crates <= 1) crates = 2;
  326. format(szMiscArray, sizeof szMiscArray, "There are %d hay bales in the back of the truck. You must deliver them all to proceed.", crates);
  327. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  328. SetPVarInt(playerid, "TruckingCrates", crates);
  329. SetPVarInt(playerid, "DeliveryStage", 2);
  330. }
  331. case 16:
  332. {
  333. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You must unload your truck to continue. Open the trunk and then use /unloadshipment.");
  334. new crates = floatround(GetVehicleCargoSize(GetVehicleModel(GetPlayerVehicleID(playerid))) / 10, floatround_ceil) + 1;
  335. format(szMiscArray, sizeof szMiscArray, "There are %d body bags in the back of the truck. You must deliver them all to proceed.", crates);
  336. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  337. SetPVarInt(playerid, "TruckingCrates", crates);
  338. SetPVarInt(playerid, "DeliveryStage", 2);
  339. }
  340. default:
  341. {
  342. SendClientMessage(playerid, COLOR_GREY, "There was an error processing your shipment. The second stage was not defined.");
  343. }
  344. }
  345. }
  346. else
  347. {
  348. // It's a fuel run.
  349. switch(shipment)
  350. {
  351. case 8, 10, 22:
  352. {
  353. DisablePlayerCheckpoint(playerid);
  354. TogglePlayerControllable(playerid, false);
  355. new Float:X, Float:Y, Float:Z;
  356. GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
  357. new Float:fAngle;
  358. GetVehicleZAngle(GetPlayerVehicleID(playerid), fAngle);
  359. new trailer = CreateVehicle(584, X, Y+3, Z, fAngle, 1, 1, 300, 0);
  360. SetPVarInt(playerid, "DeliveryTrailer", trailer);
  361. AttachTrailerToVehicle(trailer, GetPlayerVehicleID(playerid));
  362. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The fuel is being loaded into your tank...");
  363. GameTextForPlayer(playerid, "~b~Loading Fuel...", 8000, 6);
  364. SetTimerEx("DeliveryLoadingFuel", 8000, false, "d", playerid);
  365. }
  366. default:
  367. {
  368. SendClientMessage(playerid, COLOR_GREY, "There was an error processing your shipment. The fuel stage was not defined.");
  369. }
  370. }
  371. }
  372. }
  373. /*else if(GetPVarInt(playerid, "DeliveryStage") == 3 && IsPlayerInRangeOfPoint(playerid, 25.0, ShipmentLocations[shipment][3], ShipmentLocations[shipment][4], ShipmentLocations[shipment][5]))
  374. {
  375. switch(shipment)
  376. {
  377. case 8:
  378. {
  379. TogglePlayerControllable(playerid, false);
  380. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The fuel is being unloaded from your tank...");
  381. SetTimerEx("DeliveryUnloadingFuel", 8000, false, "d", playerid);
  382. }
  383. default: SendClientMessage(playerid, COLOR_GREY, "There was an error processing your fuel run.");
  384. }
  385. }*/
  386. else printf("Error.");
  387. return 1;
  388. }
  389. CMD:unloadfuel(playerid, params[])
  390. {
  391. if(!IsPlayerInVehicle(playerid, PlayerInfo[playerid][pUsingTruck]) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GRAD2, "You must be driving your shipment vehicle to use this command.");
  392. if(PlayerInfo[playerid][pUsingTruck] == INVALID_VEHICLE_ID || PlayerInfo[playerid][pCurrentShipment] == -1 || !GetPVarInt(playerid, "DeliveryStage")) return SendClientMessage(playerid, COLOR_GRAD2, "You do not have an active shipment.");
  393. if(!IsTrailerAttachedToVehicle(PlayerInfo[playerid][pUsingTruck])) return SendClientMessage(playerid, COLOR_GREY, "You do not have your fuel trailer attached.");
  394. if(GetVehicleTrailer(PlayerInfo[playerid][pUsingTruck]) != GetPVarInt(playerid, "DeliveryTrailer")) return SendClientMessage(playerid, COLOR_GREY, "You are carrying the wrong trailer.");
  395. new iShipment = PlayerInfo[playerid][pCurrentShipment];
  396. if(!IsPlayerInRangeOfPoint(playerid, 10.0, ShipmentLocations[iShipment][3], ShipmentLocations[iShipment][4], ShipmentLocations[iShipment][5])) return SendClientMessage(playerid, COLOR_GREY, "You're not close enough to the unload point.");
  397. if(strval(ShipmentContents[iShipment][2]) != 3) return SendClientMessage(playerid, COLOR_GREY, "Your shipment type does not support fuel.");
  398. if(GetPVarInt(playerid, "DeliveryStage") != 3) return SendClientMessage(playerid, COLOR_GREY, "You cannot unload your fuel yet.");
  399. TogglePlayerControllable(playerid, false);
  400. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The fuel is being unloaded from your tank...");
  401. GameTextForPlayer(playerid, "~b~Unloading fuel...", 8000, 6);
  402. SetTimerEx("DeliveryUnloadingFuel", 8000, false, "d", playerid);
  403. return 1;
  404. }
  405. forward DeliveryUnloadingFuel(playerid);
  406. public DeliveryUnloadingFuel(playerid)
  407. {
  408. DisablePlayerCheckpoint(playerid);
  409. TogglePlayerControllable(playerid, true);
  410. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Your fuel has been unloaded and your trailer has been detatched. Drive back to the loading bay and /finishshipment.");
  411. DetachTrailerFromVehicle(PlayerInfo[playerid][pUsingTruck]);
  412. DestroyVehicle(GetPVarInt(playerid, "DeliveryTrailer"));
  413. DeletePVar(playerid, "DeliveryTrailer");
  414. DeletePVar(playerid, "DeliveryStage");
  415. SetPVarInt(playerid, "FinishShipment", 1);
  416. SetPlayerCheckpoint(playerid, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2], 25.0);
  417. return 1;
  418. }
  419. forward DeliveryLoadingFuel(playerid);
  420. public DeliveryLoadingFuel(playerid)
  421. {
  422. TogglePlayerControllable(playerid, true);
  423. new iShipment = PlayerInfo[playerid][pCurrentShipment];
  424. TruckHolding[GetPVarInt(playerid, "DeliveryTrailer")] = iShipment;
  425. format(szMiscArray, sizeof szMiscArray, "%s{33CCFF} has been loaded into the tank. You must deliver this to %s to continue with your delivery.", ShipmentContents[iShipment][0], ShipmentContents[iShipment][1]);
  426. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  427. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drive to the checkpoint on your map and /unloadfuel to continue.");
  428. SetPlayerCheckpoint(playerid, ShipmentLocations[iShipment][3], ShipmentLocations[iShipment][4], ShipmentLocations[iShipment][4], 10.0);
  429. SetPVarInt(playerid, "DeliveryStage", 3);
  430. return 1;
  431. }
  432. CMD:loadtruck(playerid, params[])
  433. {
  434. if(!IsATrucker(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be a shipment contractor to use this command.");
  435. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GRAD2, "You must be driving a vehicle to use this command.");
  436. new vehicleid = GetPlayerVehicleID(playerid);
  437. if(!IsTruckingVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be in a shipment vehicle to use this command.");
  438. if(PlayerInfo[playerid][pUsingTruck] == INVALID_VEHICLE_ID || !IsValidVehicle(PlayerInfo[playerid][pUsingTruck]))
  439. {
  440. if(!IsPlayerInRangeOfPoint(playerid, 15.0, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2]))
  441. {
  442. SendClientMessage(playerid, COLOR_GRAD3, "A checkpoint has been set to the loading bay.");
  443. SetPlayerCheckpoint(playerid, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2], 25.0);
  444. SetPVarInt(playerid, "TruckingCPSet", 1);
  445. }
  446. else if(!GetPVarInt(playerid, "DeliveryStage"))
  447. {
  448. SendClientMessage(playerid, COLOR_LIGHTBLUE, " Select an option to load your truck.");
  449. ShowLoadTruckDialog(playerid);
  450. }
  451. else SendClientMessage(playerid, COLOR_GRAD2, "You already have an active shipment.");
  452. }
  453. else SendClientMessage(playerid, COLOR_GRAD2, "You already have a truck. Complete your delivery to continue.");
  454. return 1;
  455. }
  456. stock GetTrunkPos(vehicleid, &Float:fX, &Float:fY, &Float:fZ)
  457. {
  458. new model = GetVehicleModel(vehicleid);
  459. new Float:X, Float:Y, Float:Z;
  460. GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_SIZE, X, Y, Z);
  461. new Float:X2, Float:Y2, Float:Z2;
  462. GetVehiclePos(vehicleid, X2, Y2, Z2);
  463. fX = X2;
  464. fY = Y2 + Y / 2;
  465. fZ = Z2;
  466. }
  467. CMD:unloadshipment(playerid, params[])
  468. {
  469. if(IsATrucker(playerid))
  470. {
  471. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "You must be on foot to use this command.");
  472. if(PlayerInfo[playerid][pUsingTruck] == INVALID_VEHICLE_ID || PlayerInfo[playerid][pCurrentShipment] == -1 || !GetPVarInt(playerid, "DeliveryStage")) return SendClientMessage(playerid, COLOR_GRAD2, "You do not have an active shipment.");
  473. new Float:X, Float:Y, Float:Z;
  474. GetVehiclePos(PlayerInfo[playerid][pUsingTruck], X, Y, Z);
  475. if(!IsPlayerInRangeOfPoint(playerid, 6.0, X, Y, Z)) return SendClientMessage(playerid, COLOR_GRAD2, "You're not close enough to your shipment vehicle to do this.");
  476. new engine, lights, alarm, doors, bonnet, boot, objective;
  477. GetVehicleParamsEx(PlayerInfo[playerid][pUsingTruck], engine, lights, alarm, doors, bonnet, boot, objective);
  478. if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET)
  479. {
  480. SendClientMessageEx(playerid, COLOR_GRAD2, "The vehicle's trunk must be opened to unload crates.");
  481. return 1;
  482. }
  483. if(GetPVarInt(playerid, "DeliveryStage") == 2)
  484. {
  485. if(!GetPVarInt(playerid, "TruckingCrates")) return SendClientMessage(playerid, COLOR_GRAD2, "You do not have any more crates to unload.");
  486. TogglePlayerControllable(playerid, false);
  487. ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
  488. new iShipment = PlayerInfo[playerid][pCurrentShipment];
  489. if(iShipment == 15) SetTimerEx("UnloadingDeliveryCrate", 1000, false, "dd", playerid, 1454);
  490. else if(iShipment == 16) SetTimerEx("UnloadingDeliveryCrate", 1000, false, "dd", playerid, 19944);
  491. else SetTimerEx("UnloadingDeliveryCrate", 1000, false, "dd", playerid, 2912);
  492. }
  493. else SendClientMessage(playerid, COLOR_GREY, "You do not need to unload crates right now.");
  494. }
  495. else SendClientMessage(playerid, COLOR_GRAD2, "You must be a shipment contractor to use this command.");
  496. return 1;
  497. }
  498. CMD:dropshipment(playerid, params[])
  499. {
  500. if(IsATrucker(playerid))
  501. {
  502. if(!GetPVarInt(playerid, "UnloadingCrates")) return SendClientMessage(playerid, COLOR_GREY, "You are not currently unloading a crate.");
  503. new iShipment = PlayerInfo[playerid][pCurrentShipment];
  504. if(!IsPlayerInRangeOfPoint(playerid, 1.5, ShipmentLocations[iShipment][3], ShipmentLocations[iShipment][4], ShipmentLocations[iShipment][5])) return SendClientMessage(playerid, COLOR_GRAD2, "You're not close enough to the unload point.");
  505. ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
  506. RemovePlayerAttachedObject(playerid, GetPVarInt(playerid, "CrateSlot"));
  507. SetPVarInt(playerid, "TruckingCrates", GetPVarInt(playerid, "TruckingCrates") - 1);
  508. new crates = GetPVarInt(playerid, "TruckingCrates");
  509. DisablePlayerCheckpoint(playerid);
  510. TogglePlayerControllable(playerid, false);
  511. SetTimerEx("DropCrateUnfreeze", 1600, false, "d", playerid);
  512. if(crates > 1)
  513. {
  514. format(szMiscArray, sizeof szMiscArray, "Run completed. There are %d remaining.", GetPVarInt(playerid, "TruckingCrates"));
  515. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  516. }
  517. else if(crates == 1)
  518. {
  519. SendClientMessage(playerid, COLOR_LIGHTBLUE, "There is 1 remaining.");
  520. }
  521. else if(crates == 0)
  522. {
  523. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have unloaded your truck. It is now empty.");
  524. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Take your truck back to the loading bay and /finishshipment to receive your pay.");
  525. SetPVarInt(playerid, "FinishShipment", 1);
  526. DisablePlayerCheckpoint(playerid);
  527. // SetPlayerCheckpoint(playerid, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2], 25.0);
  528. DeletePVar(playerid, "UnloadingCrates");
  529. DeletePVar(playerid, "TruckingCrates");
  530. DeletePVar(playerid, "DeliveryStage");
  531. TruckHolding[PlayerInfo[playerid][pUsingTruck]] = -1;
  532. }
  533. }
  534. else SendClientMessage(playerid, COLOR_GRAD2, "You must be a shipment contractor to use this command.");
  535. return 1;
  536. }
  537. forward DropCrateUnfreeze(playerid);
  538. public DropCrateUnfreeze(playerid)
  539. {
  540. TogglePlayerControllable(playerid, true);
  541. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
  542. ClearAnimationsEx(playerid);
  543. return 1;
  544. }
  545. CMD:finishshipment(playerid, params[])
  546. {
  547. if(IsATrucker(playerid))
  548. {
  549. if(!IsPlayerInVehicle(playerid, PlayerInfo[playerid][pUsingTruck]) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You can only make deliveries in your shipment vehicle.");
  550. if(!GetPVarInt(playerid, "FinishShipment")) return SendClientMessage(playerid, COLOR_GRAD2, "You haven't completed your shipment run yet.");
  551. if(!IsPlayerInRangeOfPoint(playerid, 10.0, fTruckLoad[0], fTruckLoad[1], fTruckLoad[2])) return SendClientMessage(playerid, COLOR_GRAD2, "You're not close enough to the loading bay to do this.");
  552. GameTextForPlayer(playerid, "~g~Shipment Completed!", 4, 2000);
  553. new shipment = PlayerInfo[playerid][pCurrentShipment];
  554. new ppk = strval(ShipmentContents[shipment][3]);
  555. new cargo = GetVehicleCargoSize(GetVehicleModel(PlayerInfo[playerid][pUsingTruck]));
  556. new pay = cargo * ppk;
  557. format(szMiscArray, sizeof szMiscArray, "You have completed your shipment and have been paid $%s.", number_format(pay));
  558. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  559. GivePlayerCash(playerid, pay);
  560. PlayerInfo[playerid][pTruckSkill]++;
  561. TruckUsedBy[PlayerInfo[playerid][pUsingTruck]] = -1;
  562. SetVehicleToRespawn(PlayerInfo[playerid][pUsingTruck]);
  563. PlayerInfo[playerid][pUsingTruck] = INVALID_VEHICLE_ID;
  564. PlayerInfo[playerid][pCurrentShipment] = -1;
  565. DisablePlayerCheckpoint(playerid);
  566. }
  567. else SendClientMessage(playerid, COLOR_GRAD2, "You must be a shipment contractor to use this command.");
  568. return 1;
  569. }
  570. forward UnloadingDeliveryCrate(playerid, crate);
  571. public UnloadingDeliveryCrate(playerid, crate)
  572. {
  573. TogglePlayerControllable(playerid, true);
  574. new Float:X, Float:Y, Float:Z;
  575. GetPlayerPos(playerid, X, Y, Z);
  576. printf("crate %d", crate);
  577. // Assigning the objects correctly.
  578. new slot = -1;
  579. for(new i = 0; i < 10; i++)
  580. {
  581. if(!IsPlayerAttachedObjectSlotUsed(playerid, i))
  582. {
  583. slot = i;
  584. break;
  585. }
  586. }
  587. if(slot == -1)
  588. {
  589. RemovePlayerAttachedObject(playerid, 9);
  590. slot = 9;
  591. }
  592. SetPVarInt(playerid, "CrateSlot", slot);
  593. if(crate == 1454) // Hay bale.
  594. {
  595. SetPlayerAttachedObject(playerid, slot, 1454, 1, 0.3, 0.6, 0, 90, 0, 0, 0.5, 0.5, 0.5, 0, 0);
  596. }
  597. else if(crate == 19944) // Corpses.
  598. {
  599. SetPlayerAttachedObject(playerid, slot, 19944, 1, -0.05, 0.55, 0, 90, 90, 0, 0.65, 0.65, 0.65, 0, 0);
  600. }
  601. else // Other.
  602. {
  603. SetPlayerAttachedObject(playerid, slot, crate, 1, 0.23, 0.6, -0.28, 0, 0.0, 0.0, 0.8, 0.8, 0.8, 0, 0);
  604. }
  605. SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  606. SendClientMessage(playerid, COLOR_WHITE, "You have unloaded an item. Take it to the checkpoint on your map and /dropshipment.");
  607. new iShipment = PlayerInfo[playerid][pCurrentShipment];
  608. SetPlayerCheckpoint(playerid, ShipmentLocations[iShipment][3], ShipmentLocations[iShipment][4], ShipmentLocations[iShipment][5], 1.5);
  609. SetPVarInt(playerid, "UnloadingCrates", 1);
  610. return 1;
  611. }
  612. CMD:cleartruck(playerid, params[])
  613. {
  614. if(IsACop(playerid) || IsATrucker(playerid))
  615. {
  616. new carid = GetPlayerVehicleID(playerid);
  617. new closestcar = GetClosestCar(playerid, carid);
  618. if(!IsTruckingVehicle(closestcar) && !IsTrailer(closestcar)) return SendClientMessage(playerid, COLOR_GREY, "That vehicle is not a valid shipment vehicle.");
  619. new engine, lights, alarm, doors, bonnet, boot, objective;
  620. GetVehicleParamsEx(closestcar, engine, lights, alarm, doors, bonnet, boot, objective);
  621. if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET && !IsTrailer(closestcar))
  622. {
  623. SendClientMessageEx(playerid, COLOR_GRAD1, "The vehicle's trunk must be opened to search it.");
  624. return 1;
  625. }
  626. if(TruckHolding[closestcar] != -1) // The truck has some cargo.
  627. {
  628. format(szMiscArray, sizeof szMiscArray, "You have confiscated the truck's %s.", ShipmentContents[TruckHolding[closestcar]][0]);
  629. SendClientMessage(playerid, COLOR_GRAD1, szMiscArray);
  630. TruckHolding[closestcar] = -1;
  631. foreach(new i: Player)
  632. {
  633. if(PlayerInfo[i][pUsingTruck] == closestcar)
  634. {
  635. PlayerInfo[i][pCurrentShipment] = -1;
  636. PlayerInfo[i][pUsingTruck] = INVALID_VEHICLE_ID;
  637. }
  638. }
  639. format(szMiscArray, sizeof szMiscArray, "%s has confiscated the contents of the truck.", GetPlayerNameEx(playerid));
  640. ProxDetector(30.0, playerid, szMiscArray, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  641. }
  642. else
  643. {
  644. SendClientMessage(playerid, COLOR_GREY, "You cannot remove this truck's cargo as it is empty.");
  645. }
  646. }
  647. else SendClientMessage(playerid, COLOR_GREY, "You must be a law enforcement officer or shipment contractor to use this command.");
  648. return 1;
  649. }
  650. CMD:searchtruck(playerid, params[])
  651. {
  652. if(IsACop(playerid) || IsATrucker(playerid))
  653. {
  654. new carid = GetPlayerVehicleID(playerid);
  655. new closestcar = GetClosestCar(playerid, carid);
  656. if(!IsTruckingVehicle(closestcar) && !IsTrailer(closestcar)) return SendClientMessage(playerid, COLOR_GREY, "That vehicle is not a valid shipment vehicle.");
  657. new engine, lights, alarm, doors, bonnet, boot, objective;
  658. GetVehicleParamsEx(closestcar, engine, lights, alarm, doors, bonnet, boot, objective);
  659. if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET && !IsTrailer(closestcar))
  660. {
  661. SendClientMessageEx(playerid, COLOR_GRAD1, "The vehicle's trunk must be opened to search it.");
  662. return 1;
  663. }
  664. SendClientMessage(playerid, COLOR_GREEN, "________________________________");
  665. SendClientMessage(playerid, COLOR_GRAD3, "Vehicle Cargo:");
  666. if(TruckHolding[closestcar] != -1) // The truck has some cargo.
  667. {
  668. format(szMiscArray, sizeof szMiscArray, "This vehicle is holding %s.", ShipmentContents[TruckHolding[closestcar]][0]);
  669. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  670. format(szMiscArray, sizeof szMiscArray, "The manifesto shows the destination as {A9C4E4}%s{FFFFFF}.", ShipmentContents[TruckHolding[closestcar]][1]);
  671. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  672. }
  673. else
  674. {
  675. SendClientMessage(playerid, COLOR_GREY, "This vehicle is empty. It has not been loaded or its cargo has already been delivered.");
  676. }
  677. SendClientMessage(playerid, COLOR_GREEN, "________________________________");
  678. }
  679. else SendClientMessage(playerid, COLOR_GRAD2, "You are not a shipment contractor or a Law Enforcement Officer.");
  680. return 1;
  681. }
  682. forward TruckAbuseCheck(playerid, vehicleid);
  683. public TruckAbuseCheck(playerid, vehicleid)
  684. {
  685. if(GetPVarInt(playerid, "TruckAbuse"))
  686. {
  687. SetVehicleToRespawn(vehicleid);
  688. SendClientMessage(playerid, COLOR_LIGHTRED, " Your shipment vehicle has been respawned! You did not load a shipment within 2 minutes.");
  689. }
  690. return 1;
  691. }
  692. hook OnPlayerStateChange(playerid, newstate, oldstate)
  693. {
  694. if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT && IsTruckingVehicle(GetPlayerVehicleID(playerid)))
  695. {
  696. if(!IsATrucker(playerid))
  697. {
  698. SendClientMessage(playerid, COLOR_GREY, "You must be a shipment contractor to drive this vehicle.");
  699. RemovePlayerFromVehicle(playerid);
  700. return 1;
  701. }
  702. new vehicleid = GetPlayerVehicleID(playerid);
  703. if(TruckUsedBy[vehicleid] == -1)
  704. {
  705. // Truck abuse should only trigger on non-owned trucks, as this would open up the doors for an exploit.
  706. SetTimerEx("TruckAbuseCheck", 120000, false, "dd", playerid, GetPlayerVehicleID(playerid)); // To stop people using a truck and driving it around in lieu of buying a car.
  707. SetPVarInt(playerid, "TruckAbuse", 1);
  708. SendClientMessage(playerid, COLOR_YELLOW, "NOTE: You are driving an unused shipment vehicle. To start a shipment, use /loadtruck.");
  709. }
  710. else
  711. {
  712. if(TruckHolding[vehicleid] == -1)
  713. {
  714. if(vehicleid == PlayerInfo[playerid][pUsingTruck])
  715. {
  716. SendClientMessage(playerid, COLOR_GRAD2, "This is your shipment vehicle. It is currently empty.");
  717. }
  718. else
  719. {
  720. SendClientMessage(playerid, COLOR_YELLOW, "NOTE: You are driving a used shipment vehicle. It is currently empty.");
  721. SendClientMessage(playerid, COLOR_YELLOW, "NOTE: To claim it, drive it back to the shipment location at Blueberry.");
  722. }
  723. }
  724. else
  725. {
  726. if(vehicleid == PlayerInfo[playerid][pUsingTruck])
  727. {
  728. format(szMiscArray, sizeof szMiscArray, "This is your shipment vehicle. It is currently carrying %s{BFC0C2}.", ShipmentContents[TruckHolding[vehicleid]][0]);
  729. SendClientMessage(playerid, COLOR_GRAD2, szMiscArray);
  730. }
  731. else
  732. {
  733. format(szMiscArray, sizeof szMiscArray, "NOTE: You are driving a used shipment vehicle. It is currently carrying %s{FFFF00}.", ShipmentContents[TruckHolding[vehicleid]][0]);
  734. SendClientMessage(playerid, COLOR_YELLOW, szMiscArray);
  735. if(PlayerInfo[playerid][pUsingTruck] == INVALID_VEHICLE_ID || !IsValidVehicle(PlayerInfo[playerid][pUsingTruck]))
  736. {
  737. SendClientMessage(playerid, COLOR_YELLOW, "NOTE: To claim it, use /claimtruck.");
  738. }
  739. else
  740. {
  741. SendClientMessage(playerid, COLOR_YELLOW, "NOTE: You are already on a delivery and therefore unable to claim this truck's cargo.");
  742. }
  743. }
  744. }
  745. }
  746. }
  747. return 1;
  748. }
  749. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  750. {
  751. if(dialogid == DIALOG_SHIPMENT_OPTIONS)
  752. {
  753. if(!response) return SendClientMessage(playerid, COLOR_GRAD2, "You have stopped loading your shipment.");
  754. // The listitem is the index of the player's pShipmentOptions.
  755. // Which in turn is the corresponding value of the ShipmentOptions.
  756. new ShipmentID = PlayerInfo[playerid][pShipmentOptions][listitem];
  757. // The below ensures they cannot do fuel shipments using a mule, and vice versa.
  758. new type = strval(ShipmentContents[ShipmentID][2]);
  759. new model = GetVehicleModel(GetPlayerVehicleID(playerid));
  760. if(type == 1 || type == 2)
  761. {
  762. switch(model)
  763. {
  764. case 403, 515: return SendClientMessage(playerid, COLOR_GREY, "Your vehicle is incompatible for this delivery type.");
  765. }
  766. }
  767. if(type == 3)
  768. {
  769. switch(model)
  770. {
  771. case 414, 456, 499, 440, 455: return SendClientMessage(playerid, COLOR_GREY, "Your vehicle is incompatible for this delivery type.");
  772. default:
  773. {
  774. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Drive to the fuel depot in Las Venturas to get a trailer.");
  775. SetPlayerCheckpoint(playerid, fTrailerLoad[0], fTrailerLoad[1], fTrailerLoad[2], 10.0);
  776. SetPVarInt(playerid, "DeliveryStage", 1);
  777. PlayerInfo[playerid][pUsingTruck] = GetPlayerVehicleID(playerid);
  778. TruckUsedBy[GetPlayerVehicleID(playerid)] = playerid;
  779. PlayerInfo[playerid][pCurrentShipment] = ShipmentID;
  780. DeletePVar(playerid, "TruckAbuse");
  781. return 1;
  782. }
  783. }
  784. }
  785. PlayerInfo[playerid][pUsingTruck] = GetPlayerVehicleID(playerid);
  786. TruckUsedBy[GetPlayerVehicleID(playerid)] = playerid;
  787. // Freeze the player for X seconds, tell them their vehicle is being loaded with Y.
  788. // The time should be calculated by the size of their cargo.
  789. new time = 5000 + floatround(GetVehicleCargoSize(GetVehicleModel(GetPlayerVehicleID(playerid))) / 10);
  790. TogglePlayerControllable(playerid, false);
  791. format(szMiscArray, sizeof szMiscArray, "Your vehicle is now being loaded with %s{FFFFFF}.", ShipmentContents[ShipmentID][0]);
  792. SendClientMessage(playerid, COLOR_WHITE, szMiscArray);
  793. GameTextForPlayer(playerid, "~g~Loading shipment...", time, 6);
  794. SetTimerEx("LoadPlayerShipment", time, false, "dd", playerid, ShipmentID);
  795. }
  796. return 1;
  797. }
  798. forward LoadPlayerShipment(playerid, shipment);
  799. public LoadPlayerShipment(playerid, shipment)
  800. {
  801. TogglePlayerControllable(playerid, true);
  802. DisablePlayerCheckpoint(playerid);
  803. format(szMiscArray, sizeof szMiscArray, " Your truck has been loaded. Drive to %s to proceed with your delivery.", ShipmentContents[shipment][1]);
  804. SendClientMessage(playerid, COLOR_LIGHTBLUE, szMiscArray);
  805. SetPVarInt(playerid, "DeliveryStage", 1);
  806. PlayerInfo[playerid][pCurrentShipment] = shipment;
  807. TruckHolding[GetPlayerVehicleID(playerid)] = shipment;
  808. SetPlayerCheckpoint(playerid, ShipmentLocations[shipment][0], ShipmentLocations[shipment][1], ShipmentLocations[shipment][2], 10.0);
  809. DeletePVar(playerid, "TruckAbuse");
  810. return 1;
  811. }