groupweapons.pwn 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Group Weapons Handler (Locker)
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. new LockerReq[MAX_PLAYERS][3];
  35. hook OnPlayerConnect(playerid) {
  36. LockerReq[playerid][0] = 0; // Gun ID
  37. LockerReq[playerid][1] = -1; // Slot
  38. LockerReq[playerid][2] = gettime(); // Time of request
  39. return 1;
  40. }
  41. stock ShowGroupWeapons(playerid, group) {
  42. if(!ValidGroup(group)) return 1;
  43. new title[54];
  44. format(title, sizeof(title), "Weapon Safe - Mats: %s", number_format(arrGroupData[group][g_iLockerStock]));
  45. Dialog_Show(playerid, wep_option, DIALOG_STYLE_LIST, title, "Withdraw Weapon\nDeposit Weapon", "Select", "Go Back");
  46. return 1;
  47. }
  48. stock WeaponMenu(playerid, group, crate = 0) {
  49. szMiscArray[0] = 0;
  50. new title[54];
  51. if(!ValidGroup(group)) return 1;
  52. format(title, sizeof(title), "Safe Weapon Withdraw - Mats: %s", number_format(arrGroupData[group][g_iLockerStock]));
  53. format(szMiscArray, sizeof(szMiscArray), "Weapon\tCost\n");
  54. for(new i = 0; i != MAX_GROUP_WEAPONS; ++i) {
  55. if(arrGroupData[group][g_iLockerGuns][i]) {
  56. format(szMiscArray, sizeof szMiscArray, "%s\n%s\t%d", szMiscArray, Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][i]), arrGroupData[group][g_iLockerCost][i]);
  57. }
  58. else strcat(szMiscArray, "\nEmpty\t--");
  59. }
  60. if(crate) {
  61. Dialog_Show(playerid, crate_withdraw, DIALOG_STYLE_TABLIST_HEADERS, "Transfer to Crate", szMiscArray, "Select", "Go Back");
  62. } else {
  63. Dialog_Show(playerid, weapon_withdraw, DIALOG_STYLE_TABLIST_HEADERS, title, szMiscArray, "Select", "Go Back");
  64. }
  65. return 1;
  66. }
  67. stock DepositMenu(playerid, group) {
  68. szMiscArray[0] = 0;
  69. if(!ValidGroup(group)) return 1;
  70. for(new g = 0; g < 12; g++) {
  71. if(PlayerInfo[playerid][pGuns][g] != 0 && PlayerInfo[playerid][pAGuns][g] == 0) {
  72. if(CanDeposit(PlayerInfo[playerid][pGuns][g])) {
  73. format(szMiscArray, sizeof(szMiscArray), "%s\n(%i) %s", szMiscArray, PlayerInfo[playerid][pGuns][g], Weapon_ReturnName(PlayerInfo[playerid][pGuns][g]));
  74. }
  75. }
  76. }
  77. if(isnull(szMiscArray)) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can only deposit: Spas12, AK-47, M4 & Sniper Rifle."), ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  78. return Dialog_Show(playerid, weapon_deposit, DIALOG_STYLE_LIST, "Safe Weapon Deposit", szMiscArray, "Deposit", "Go Back");
  79. }
  80. Dialog:wep_option(playerid, response, listitem, inputtext[]) {
  81. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  82. if(response) {
  83. switch(listitem) {
  84. case 0: {
  85. //if(PlayerInfo[playerid][pRank] < arrGroupData[PlayerInfo[playerid][pMember]][g_iWithdrawRank][3]) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to withdraw weapons from the locker!"), ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  86. WeaponMenu(playerid, PlayerInfo[playerid][pMember]);
  87. }
  88. case 1: {
  89. DepositMenu(playerid, PlayerInfo[playerid][pMember]);
  90. }
  91. }
  92. } else {
  93. return cmd_locker(playerid, "");
  94. }
  95. return 1;
  96. }
  97. Dialog:weapon_withdraw(playerid, response, listitem, inputtext[]) {
  98. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  99. new group = PlayerInfo[playerid][pMember];
  100. if(response) {
  101. szMiscArray[0] = 0;
  102. if(PlayerInfo[playerid][pAccountRestricted] != 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "Your account is restricted!");
  103. if(PlayerInfo[playerid][pWRestricted] > 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "You can't take weapons out as you're currently weapon restricted!");
  104. new GunID = arrGroupData[group][g_iLockerGuns][listitem];
  105. if(!GunID) return SendClientMessageEx(playerid, COLOR_WHITE, "Theres no weapon assigned to that slot!"), WeaponMenu(playerid, PlayerInfo[playerid][pMember]);
  106. if(PlayerInfo[playerid][pRank] < LockerWep[group][lwRank][listitem]) {
  107. if(LockerReq[playerid][2] > gettime()) return SendClientMessageEx(playerid, COLOR_YELLOW, "A request was already sent please wait %d seconds before trying again!", LockerReq[playerid][2]-gettime()), WeaponMenu(playerid, PlayerInfo[playerid][pMember]);
  108. SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to withdraw a %s from the locker! (Requires rank %d+)", Weapon_ReturnName(GunID), LockerWep[group][lwRank][listitem]);
  109. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* A request was sent to the leaders who may grant you access. - Ensure you don't move away from the locker!");
  110. LockerReq[playerid][0] = GunID;
  111. LockerReq[playerid][1] = listitem;
  112. LockerReq[playerid][2] = gettime()+60;
  113. foreach(new p: Player) {
  114. if(PlayerInfo[p][pLeader] == PlayerInfo[playerid][pMember]) {
  115. SendClientMessageEx(p, COLOR_YELLOW, "* %s is requesting to withdraw a %s from the locker. (( /allow %d ))", GetPlayerNameEx(playerid), Weapon_ReturnName(GunID), playerid);
  116. }
  117. }
  118. return 1;
  119. }
  120. if(arrGroupData[group][g_iLockerStock] < arrGroupData[group][g_iLockerCost][listitem]) return SendClientMessageEx(playerid, COLOR_RED, "Your locker doesn't have the materials to craft a %s.", Weapon_ReturnName(GunID));
  121. if(PlayerInfo[playerid][pGuns][GetWeaponSlot(GunID)] != GunID) {
  122. arrGroupData[group][g_iLockerStock] -= arrGroupData[group][g_iLockerCost][listitem];
  123. GivePlayerValidWeapon(playerid, GunID);
  124. SendClientMessageEx(playerid, COLOR_WHITE, "You withdraw a %s from the locker.", Weapon_ReturnName(GunID));
  125. format(szMiscArray, sizeof(szMiscArray), "%s has withdrawn a %s from the weapon locker (Cost: %d)", GetPlayerNameEx(playerid), Weapon_ReturnName(GunID), arrGroupData[group][g_iLockerCost][listitem]);
  126. GroupLog(PlayerInfo[playerid][pMember], szMiscArray);
  127. return WeaponMenu(playerid, PlayerInfo[playerid][pMember]);
  128. } else {
  129. SendClientMessageEx(playerid, COLOR_RED, "You already have a %s on you!", Weapon_ReturnName(GunID));
  130. return WeaponMenu(playerid, PlayerInfo[playerid][pMember]);
  131. }
  132. } else {
  133. ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  134. }
  135. return 1;
  136. }
  137. Dialog:weapon_deposit(playerid, response, listitem, inputtext[]) {
  138. if(response) {
  139. szMiscArray[0] = 0;
  140. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  141. new stpos = strfind(inputtext, "(");
  142. new fpos = strfind(inputtext, ")");
  143. new gid[6], id, slot;
  144. strmid(gid, inputtext, stpos+1, fpos);
  145. id = strval(gid);
  146. if(PlayerInfo[playerid][pGuns][GetWeaponSlot(id)] == 0) return SendClientMessageEx(playerid, COLOR_RED, "The weapon you tried to deposit doesn't exist!"), ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  147. if(!CanDeposit(PlayerInfo[playerid][pGuns][GetWeaponSlot(id)])) return SendClientMessageEx(playerid, COLOR_RED, "You can't deposit that weapon!"), ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  148. IsInSlot(PlayerInfo[playerid][pMember], id, slot);
  149. if(slot == -1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Your locker doesn't have that weapon so it can't be stored!"), DepositMenu(playerid, PlayerInfo[playerid][pMember]);
  150. PlayerInfo[playerid][pGuns][GetWeaponSlot(id)] = 0;
  151. SetPlayerWeaponsEx(playerid);
  152. SendClientMessageEx(playerid, COLOR_WHITE, "You have deposited a %s into the locker.", Weapon_ReturnName(id));
  153. format(szMiscArray, sizeof(szMiscArray), "%s has deposited a %s into the locker.", GetPlayerNameEx(playerid), Weapon_ReturnName(id));
  154. GroupLog(PlayerInfo[playerid][pMember], szMiscArray);
  155. arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock] += arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerCost][slot];
  156. DepositMenu(playerid, PlayerInfo[playerid][pMember]);
  157. } else {
  158. ShowGroupWeapons(playerid, PlayerInfo[playerid][pMember]);
  159. }
  160. return 1;
  161. }
  162. stock SaveLockerRanks(i) {
  163. new query[2048], wep[12];
  164. format(query, 2048, "UPDATE `locker_restrict` SET ");
  165. for(new w = 0; w < 16; w++) {
  166. format(wep, sizeof(wep), "%d", w+1);
  167. SaveInteger(query, "locker_restrict", i+1, wep, LockerWep[i][lwRank][w]);
  168. }
  169. SQLUpdateFinish(query, "locker_restrict", i+1);
  170. return 1;
  171. }
  172. stock SaveWeapons(i) {
  173. new query[2048], wep[12];
  174. format(query, 2048, "UPDATE `gweaponsnew` SET ");
  175. for(new w = 0; w < 46; w++) {
  176. format(wep, sizeof(wep), "%d", w+1);
  177. SaveInteger(query, "gweaponsnew", i+1, wep, LockerWep[i][lwWep][w]);
  178. }
  179. SQLUpdateFinish(query, "gweaponsnew", i+1);
  180. return 1;
  181. }
  182. stock CrateTransferOption(playerid, group) {
  183. if(!ValidGroup(group)) return 1;
  184. if(PlayerInfo[playerid][pLeader] == group) {
  185. Dialog_Show(playerid, crate_tran_option, DIALOG_STYLE_LIST, "Crate Transfer", "Deploy Crate Box\nTransfer to Crate\nDeposit Crate\nRecall Crate", "Select", "Go Back");
  186. } else {
  187. Dialog_Show(playerid, crate_tran_option, DIALOG_STYLE_LIST, "Crate Transfer", "Deposit Crate", "Select", "Go Back");
  188. }
  189. return 1;
  190. }
  191. Dialog:crate_tran_option(playerid, response, listitem, inputtext[]) {
  192. if(response) {
  193. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  194. szMiscArray[0] = 0;
  195. new gbox;
  196. GetGroupCrate(playerid, gbox);
  197. if(PlayerInfo[playerid][pLeader] == PlayerInfo[playerid][pMember]) {
  198. switch(listitem) {
  199. case 0: {
  200. if(gbox == -1) {
  201. szMiscArray = "{FFFFFF}_______________________________________________________________________________________________________________________________________________________\n\n\n";
  202. strcat(szMiscArray, "{F69500}WARNING: Are you sure you want to deply a transfer crate?{FFFFFF}\n\n");
  203. strcat(szMiscArray, "Deploying a transfer crate will allow you to sell weapons to another group\n\n");
  204. strcat(szMiscArray, "You must be careful with the crate as anyone is able to steal it from you and dump the contents into their locker - Only leaders can deploy a transfer crate.\n");
  205. strcat(szMiscArray, "Anyone within the group has the ability to deposit any crate they come across or mange to steal from another group into your own group locker.\n\n");
  206. strcat(szMiscArray, "There is no time limit for when the crate will despawn, you must wait 24 hours before you can 'recall' it so be careful with the crate.\n");
  207. strcat(szMiscArray, "The only time the crate will despawned if it's been deposited into any locker or you recall it.\n\n");
  208. strcat(szMiscArray, "Note: You can recall the crate after 24 hours if you've lost it but all contents of the crate will be lost!\n\n");
  209. strcat(szMiscArray, "{FFFFFF}_______________________________________________________________________________________________________________________________________________________");
  210. Dialog_Show(playerid, deploy_transfer_crate, DIALOG_STYLE_MSGBOX, "Deploy Transfer Crate?", szMiscArray, "Deploy", "Go Back");
  211. } else {
  212. SendClientMessageEx(playerid, COLOR_YELLOW, "There is already a transfer crate in use find it or wait until you can recall it.");
  213. return CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  214. }
  215. }
  216. case 1: {
  217. if(CarryCrate[playerid] == -1) return SendClientMessageEx(playerid, COLOR_RED, "Your not carrying a group crate!"), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  218. if(CarryCrate[playerid] != gbox) return SendClientMessageEx(playerid, COLOR_RED, "You can't transfer items to a crate not owned by your group!"), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  219. return WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  220. }
  221. case 2: { // Deposit Crate
  222. if(CarryCrate[playerid] == -1) return SendClientMessageEx(playerid, COLOR_RED, "You need to be holding a crate to deposit!"), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  223. return DepositCrateContents(playerid, CarryCrate[playerid]);
  224. }
  225. case 3: {
  226. if(gbox == -1) return SendClientMessageEx(playerid, COLOR_YELLOW, "SMS: There was no response from the signal. (( No active crate )), Sender: MOLE (555)");
  227. if(CrateBox[gbox][cbLifespan] > gettime()) return SendClientMessageEx(playerid, COLOR_YELLOW, "SMS: Signal will be active after %s, Sender: MOLE (555)", date(CrateBox[gbox][cbLifespan], 1));
  228. strcat(szMiscArray, "{F69500}WARNING: Are you sure you want to recall your group crate?{FFFFFF}\n\n");
  229. strcat(szMiscArray, "By recalling the crate it will be destroyed along with all of it's contents!\n");
  230. Dialog_Show(playerid, recall_box_check, DIALOG_STYLE_MSGBOX, "Recall Crate?", szMiscArray, "Recall", "Cancel");
  231. }
  232. }
  233. } else {
  234. switch(listitem) {
  235. case 0: {
  236. if(CarryCrate[playerid] == -1) return SendClientMessageEx(playerid, COLOR_RED, "You need to be holding a crate to deposit!"), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  237. return DepositCrateContents(playerid, CarryCrate[playerid]);
  238. }
  239. }
  240. }
  241. } else {
  242. return cmd_locker(playerid, "");
  243. }
  244. return 1;
  245. }
  246. Dialog:recall_box_check(playerid, response, listitem, inputtext[]) {
  247. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  248. if(response) {
  249. new gbox;
  250. GetGroupCrate(playerid, gbox);
  251. if(gbox == -1) return SendClientMessageEx(playerid, COLOR_GRAD2, "Appears your group crate has already been recalled."), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  252. DestroyCrate(gbox);
  253. SendClientMessageEx(playerid, COLOR_YELLOW, "You have recalled your group crate, all contents were removed.");
  254. CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  255. } else {
  256. CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  257. }
  258. return 1;
  259. }
  260. Dialog:deploy_transfer_crate(playerid, response, listitem, inputtext[]) {
  261. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  262. if(response) {
  263. szMiscArray[0] = 0;
  264. new Float: pcbPos[3];
  265. if(CarryCrate[playerid] != -1) return SendClientMessageEx(playerid, COLOR_RED, "Your carrying a crate put it down before deploying a transfer crate!"), CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  266. GetPlayerPos(playerid, pcbPos[0], pcbPos[1], pcbPos[2]);
  267. GetXYInFrontOfPlayer(playerid, pcbPos[0], pcbPos[1], 1);
  268. for(new c = 0; c < MAX_CRATES; c++) {
  269. if(CrateBox[c][cbFacility] == -1 && CrateBox[c][cbGroup] == -1) {
  270. CrateBox[c][cbGroup] = PlayerInfo[playerid][pMember];
  271. CrateBox[c][cbPos][0] = pcbPos[0];
  272. CrateBox[c][cbPos][1] = pcbPos[1];
  273. CrateBox[c][cbPos][2] = pcbPos[2]-1.0;
  274. CrateBox[c][cbInt] = GetPlayerInterior(playerid);
  275. CrateBox[c][cbVw] = GetPlayerVirtualWorld(playerid);
  276. CrateBox[c][cbPlacedBy] = GetPlayerNameEx(playerid);
  277. if(PlayerHoldingObject[playerid][8] != 0 || IsPlayerAttachedObjectSlotUsed(playerid, 8))
  278. RemovePlayerAttachedObject(playerid, 8), PlayerHoldingObject[playerid][8] = 0;
  279. SetPlayerAttachedObject(playerid, 8, 964, 1, -0.071, 0.536, -0.026999, -2.19999, 87.1999, 0.699999, 0.479999, 0.538999, 0.419999);
  280. if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_CARRY) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
  281. CarryCrate[playerid] = c;
  282. BeingMoved[c] = playerid;
  283. CrateBox[c][cbLifespan] = gettime()+86400; // 24 hours.
  284. CrateBox[c][cbActive] = 1;
  285. SaveCrate(c);
  286. UpdateCrateBox(c);
  287. break;
  288. }
  289. }
  290. SendClientMessageEx(playerid, COLOR_YELLOW, "You take out a transfer crate from the locker!");
  291. Streamer_Update(playerid);
  292. CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  293. } else {
  294. CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  295. }
  296. return 1;
  297. }
  298. Dialog:crate_withdraw(playerid, response, listitem, inputtext[]) {
  299. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  300. szMiscArray[0] = 0;
  301. if(response) {
  302. new group = PlayerInfo[playerid][pMember];
  303. new GunID = arrGroupData[group][g_iLockerGuns][listitem];
  304. if(!GunID) return SendClientMessageEx(playerid, COLOR_WHITE, "Theres no weapon assigned to that slot!"), WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  305. if(PlayerInfo[playerid][pRank] < LockerWep[group][lwRank][listitem]) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to withdraw a %s from the locker! (Requires rank %d+)", Weapon_ReturnName(GunID), LockerWep[group][lwRank][listitem]), WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  306. if(!CanTransferToCrate(GunID)) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't transfer that item to the crate!"), WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  307. if(arrGroupData[group][g_iLockerStock] < arrGroupData[group][g_iLockerCost][listitem]) return SendClientMessageEx(playerid, COLOR_RED, "Your locker doesn't have the materials to craft a %s.", Weapon_ReturnName(GunID)), WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  308. SetPVarInt(playerid, "GunCrateID", GunID);
  309. SetPVarInt(playerid, "GunCrateSlot", listitem);
  310. format(szMiscArray, sizeof(szMiscArray), "Please enter the amount you would like to transfer to the crate.\n\nLocker Stock: %s\nCost Per %s: %s", number_format(arrGroupData[group][g_iLockerStock]), Weapon_ReturnName(GunID), number_format(arrGroupData[group][g_iLockerCost][listitem]));
  311. Dialog_Show(playerid, crate_tran_amount, DIALOG_STYLE_INPUT, "How many to withdraw?", szMiscArray, "Submit", "Go Back");
  312. } else {
  313. CrateTransferOption(playerid, PlayerInfo[playerid][pMember]);
  314. }
  315. return 1;
  316. }
  317. Dialog:crate_tran_amount(playerid, response, listitem, inputtext[]) {
  318. szMiscArray[0] = 0;
  319. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  320. if(response) {
  321. new gbox, amount = floatround(strval(inputtext));
  322. GetGroupCrate(playerid, gbox);
  323. if(CarryCrate[playerid] != gbox) return SendClientMessageEx(playerid, COLOR_RED, "Your no longer holding the group crate.");
  324. new total = (arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerCost][GetPVarInt(playerid, "GunCrateSlot")] * amount);
  325. if(amount < 1 || total > arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock]) {
  326. format(szMiscArray, sizeof(szMiscArray), "Please enter the amount you would like to transfer to the crate.\n\nLocker Stock: %s\nCost Per %s: %s\n\n{FF0000}Error: You can't go below 0 or you don't have enough materials.", number_format(arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock]), Weapon_ReturnName(GetPVarInt(playerid, "GunCrateID")), number_format(arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerCost][GetPVarInt(playerid, "GunCrateSlot")]));
  327. Dialog_Show(playerid, crate_tran_amount, DIALOG_STYLE_INPUT, "How many to transfer?", szMiscArray, "Submit", "Go Back");
  328. return 1;
  329. }
  330. CrateBox[CarryCrate[playerid]][cbWep][GetPVarInt(playerid, "GunCrateSlot")] = GetPVarInt(playerid, "GunCrateID");
  331. CrateBox[CarryCrate[playerid]][cbWepAmount][GetPVarInt(playerid, "GunCrateSlot")] += amount;
  332. arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock] -= total;
  333. SendClientMessageEx(playerid, COLOR_WHITE, "You transferred %s %s(s) to the crate.", number_format(amount), Weapon_ReturnName(GetPVarInt(playerid, "GunCrateID")));
  334. SaveGroup(PlayerInfo[playerid][pMember]);
  335. SaveCrate(CarryCrate[playerid]);
  336. format(szMiscArray, sizeof(szMiscArray), "%s has withdrawn %d %ss from the weapon locker into the transfer crate (Cost: %d)", GetPlayerNameEx(playerid), amount, Weapon_ReturnName(GetPVarInt(playerid, "GunCrateID")), total);
  337. GroupLog(PlayerInfo[playerid][pMember], szMiscArray);
  338. WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  339. } else {
  340. DeletePVar(playerid, "GunCrateID");
  341. DeletePVar(playerid, "GunCrateSlot");
  342. WeaponMenu(playerid, PlayerInfo[playerid][pMember], 1);
  343. }
  344. return 1;
  345. }
  346. stock DepositCrateContents(playerid, boxid) {
  347. if(!ValidGroup(PlayerInfo[playerid][pMember])) return 1;
  348. if(CrateBox[boxid][cbGroup] != -1) {
  349. for(new c = 0; c < 16; c++) {
  350. if(CrateBox[boxid][cbWep][c] > 0) {
  351. for(new l = 0; l < 16; l++) {
  352. if(CrateBox[boxid][cbWep][c] == arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerGuns][l]) {
  353. arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock] += (CrateBox[boxid][cbWepAmount][c] * arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerCost][l]);
  354. CrateBox[boxid][cbWep][c] = 0;
  355. }
  356. }
  357. }
  358. }
  359. format(szMiscArray, sizeof(szMiscArray), "* %s has unloaded the contents of the crate into the locker.", GetPlayerNameEx(playerid));
  360. ProxDetector(25.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  361. DestroyCrate(boxid);
  362. } else {
  363. if(CrateBox[boxid][cbGroup] == -1 && CrateFacility[CrateBox[boxid][cbFacility]][cfGroup] == PlayerInfo[playerid][pMember] && !CrateBox[boxid][cbPaid]) {
  364. SendClientMessageEx(playerid, COLOR_GRAD2, "You can't deposit this crate as it's unpaid!");
  365. SendClientMessageEx(playerid, COLOR_GRAD2, "Please have the group leader order crates if you need to stock up.");
  366. } else {
  367. arrGroupData[PlayerInfo[playerid][pMember]][g_iLockerStock] += floatround(CrateBox[boxid][cbMats] * CrateFacility[CrateBox[boxid][cbFacility]][cfProdMulti]);
  368. DestroyCrate(boxid);
  369. format(szMiscArray, sizeof(szMiscArray), "* %s has unloaded the contents of the crate into the locker.", GetPlayerNameEx(playerid));
  370. ProxDetector(25.0, playerid, szMiscArray, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  371. }
  372. }
  373. return 1;
  374. }
  375. stock CanTransferToCrate(WepID) {
  376. switch(WepID) {
  377. case 1: return 1; // Brass Knuckle
  378. case 2: return 1; // Golf Club
  379. case 3: return 1; // Nitestick
  380. case 5: return 1; // Bat
  381. case 6: return 1; // Shovel
  382. case 7: return 1; // Pool Cue
  383. case 8: return 1; // Katana Sword
  384. case 10: return 1; // Dildo (Purple)
  385. case 11: return 1; // Dildo
  386. case 12: return 1; // Vibrator
  387. case 13: return 1; // Silver Vibrator
  388. case 14: return 1; // Flower
  389. case 15: return 1; // Cane
  390. case 17: return 1; // Tear Gas
  391. case 22: return 1; // 9MM
  392. case 23: return 1; // Silenced 9mm
  393. case 24: return 1; // Desert Eagle
  394. case 25: return 1; // Pump Shotgun
  395. case 26: return 1; // Sawnoff Shotgun
  396. case 27: return 1; // Combat Shotgun
  397. case 28: return 1; // Micro SMG
  398. case 29: return 1; // MP5
  399. case 30: return 1; // AK-47
  400. case 31: return 1; // M4
  401. case 32: return 1; // Tec9
  402. case 33: return 1; // Rifle
  403. case 34: return 1; // Sniper Rifle
  404. case 46: return 1; // Parachute
  405. default: return 0;
  406. }
  407. return 0;
  408. }
  409. stock CanDeposit(WepID) {
  410. switch(WepID) {
  411. case 27: return 1; // Combat Shotgun
  412. case 30: return 1; // AK-47
  413. case 31: return 1; // M4
  414. case 34: return 1; // Sniper Rifle
  415. default: return 0;
  416. }
  417. return 0;
  418. }
  419. CMD:editweprank(playerid, params[]) {
  420. if(!IsGroupLeader(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Only group leaders can use this command!");
  421. WeaponRankList(playerid);
  422. return 1;
  423. }
  424. stock WeaponRankList(playerid) {
  425. szMiscArray[0] = 0;
  426. if(!IsGroupLeader(playerid)) return 1;
  427. new group = PlayerInfo[playerid][pMember];
  428. format(szMiscArray, sizeof(szMiscArray), "Weapon\tRank\n");
  429. for(new i = 0; i != MAX_GROUP_WEAPONS; ++i) {
  430. if(arrGroupData[group][g_iLockerGuns][i]) {
  431. format(szMiscArray, sizeof szMiscArray, "%s\n%s\t%d", szMiscArray, Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][i]), LockerWep[group][lwRank][i]);
  432. }
  433. else strcat(szMiscArray, "\nEmpty\t--");
  434. }
  435. Dialog_Show(playerid, wep_restrict, DIALOG_STYLE_TABLIST_HEADERS, "Weapon Restriction", szMiscArray, "Select", "Close");
  436. return 1;
  437. }
  438. Dialog:wep_restrict(playerid, response, listitem, inputtext[]) {
  439. szMiscArray[0] = 0;
  440. if(!IsGroupLeader(playerid)) return 1;
  441. new group = PlayerInfo[playerid][pMember];
  442. if(response) {
  443. if(!arrGroupData[group][g_iLockerGuns][listitem]) return SendClientMessageEx(playerid, COLOR_GRAD1, "The selected slot is currently empty!"), WeaponRankList(playerid);
  444. SetPVarInt(playerid, "RGunID", listitem);
  445. format(szMiscArray, sizeof(szMiscArray), "Please specify what rank & above can access the %s.\n\nCurrent Rank: %d+", Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][listitem]), LockerWep[group][lwRank][listitem]);
  446. Dialog_Show(playerid, set_weprank, DIALOG_STYLE_INPUT, "Restrict Weapon Withdraw", szMiscArray, "Ok", "Go Back");
  447. }
  448. return 1;
  449. }
  450. Dialog:set_weprank(playerid, response, listitem, inputtext[]) {
  451. szMiscArray[0] = 0;
  452. if(!IsGroupLeader(playerid)) return 1;
  453. new group = PlayerInfo[playerid][pMember];
  454. if(response) {
  455. if(isnull(inputtext)) {
  456. format(szMiscArray, sizeof(szMiscArray), "Please specify what rank & above can access the %s.\n\nCurrent Rank: %d+\n\n{FF0000}ERROR: You must specify a rank number!", Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][GetPVarInt(playerid, "RGunID")]), LockerWep[group][lwRank][GetPVarInt(playerid, "RGunID")], MAX_GROUP_RANKS-1);
  457. Dialog_Show(playerid, set_weprank, DIALOG_STYLE_INPUT, "Restrict Weapon Withdraw", szMiscArray, "Ok", "Go Back");
  458. return 1;
  459. }
  460. if(!IsNumeric(inputtext)) {
  461. format(szMiscArray, sizeof(szMiscArray), "Please specify what rank & above can access the %s.\n\nCurrent Rank: %d+\n\n{FF0000}ERROR: You can only use numeric values.", Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][GetPVarInt(playerid, "RGunID")]), LockerWep[group][lwRank][GetPVarInt(playerid, "RGunID")], MAX_GROUP_RANKS-1);
  462. Dialog_Show(playerid, set_weprank, DIALOG_STYLE_INPUT, "Restrict Weapon Withdraw", szMiscArray, "Ok", "Go Back");
  463. return 1;
  464. }
  465. if(!(0 <= strval(inputtext) < MAX_GROUP_RANKS)) {
  466. format(szMiscArray, sizeof(szMiscArray), "Please specify what rank & above can access the %s.\n\nCurrent Rank: %d+\n\n{FF0000}ERROR: Invalid rank ID (0 - %d only!)", Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][GetPVarInt(playerid, "RGunID")]), LockerWep[group][lwRank][GetPVarInt(playerid, "RGunID")], MAX_GROUP_RANKS-1);
  467. Dialog_Show(playerid, set_weprank, DIALOG_STYLE_INPUT, "Restrict Weapon Withdraw", szMiscArray, "Ok", "Go Back");
  468. return 1;
  469. }
  470. format(szMiscArray, sizeof(szMiscArray), "%s has set %s weapon restriction from rank %d+ to %d.", GetPlayerNameEx(playerid), Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][GetPVarInt(playerid, "RGunID")]), LockerWep[group][lwRank][GetPVarInt(playerid, "RGunID")], strval(inputtext));
  471. GroupLog(group, szMiscArray);
  472. LockerWep[group][lwRank][GetPVarInt(playerid, "RGunID")] = strval(inputtext);
  473. SendClientMessageEx(playerid, COLOR_YELLOW, "You have set the %s weapon restriction to %d+ only.", Weapon_ReturnName(arrGroupData[group][g_iLockerGuns][GetPVarInt(playerid, "RGunID")]), strval(inputtext));
  474. SaveLockerRanks(group);
  475. DeletePVar(playerid, "RGunID");
  476. WeaponRankList(playerid);
  477. } else {
  478. DeletePVar(playerid, "RGunID");
  479. WeaponRankList(playerid);
  480. }
  481. return 1;
  482. }
  483. stock IsInSlot(group, id, &wep)
  484. {
  485. wep = -1;
  486. if(ValidGroup(group)) {
  487. for(new i = 0; i != MAX_GROUP_WEAPONS; i++) {
  488. if(arrGroupData[group][g_iLockerGuns][i] == id) {
  489. wep = i; // Slot ID.
  490. break;
  491. }
  492. }
  493. }
  494. }
  495. CMD:allow(playerid, params[]) {
  496. new target, locker = -1;
  497. if(!IsGroupLeader(playerid)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Only group leaders can use this command!");
  498. if(sscanf(params, "u", target)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /allow [player]");
  499. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GRAD2, "The player selected isn't connected!");
  500. if(PlayerInfo[playerid][pMember] != PlayerInfo[target][pMember]) return SendClientMessageEx(playerid, COLOR_GRAD2, "%s isn't apart of your group!", GetPlayerNameEx(target));
  501. if(playerid == target) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can't use this weapon on yourself!");
  502. if(!LockerReq[target][0]) return SendClientMessageEx(playerid, COLOR_GRAD2, "%s hasn't requested to withdraw a weapon!", GetPlayerNameEx(target));
  503. if(LockerReq[target][2] < gettime()) return SendClientMessageEx(playerid, COLOR_GRAD2, "%s's request either expired or one wasn't made!", GetPlayerNameEx(target));
  504. if(PlayerInfo[target][pAccountRestricted] != 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "Unable to process weapon - The player is restricted.");
  505. if(PlayerInfo[target][pWRestricted] > 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "Unable to process weapon - The player is currently weapon restricted!");
  506. if(PlayerBusy(playerid) || PlayerInfo[target][pJailTime] > 0 || PlayerCuffed[target] != 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "Unable to process weapon - The player is currently busy!");
  507. for(new i; i < MAX_GROUPS; i++)
  508. {
  509. for(new j; j < MAX_GROUP_LOCKERS; j++)
  510. {
  511. if(IsPlayerInRangeOfPoint(target, 3.0, arrGroupLockers[i][j][g_fLockerPos][0], arrGroupLockers[i][j][g_fLockerPos][1], arrGroupLockers[i][j][g_fLockerPos][2]) && arrGroupLockers[i][j][g_iLockerVW] == GetPlayerVirtualWorld(target))
  512. {
  513. if(i == PlayerInfo[target][pMember] || (arrGroupData[i][g_iGroupType] == arrGroupData[PlayerInfo[target][pMember]][g_iGroupType] && arrGroupLockers[i][j][g_iLockerShare]))
  514. {
  515. locker = j;
  516. }
  517. }
  518. }
  519. }
  520. if(locker == -1) return SendClientMessageEx(playerid, COLOR_GRAD2, "%s is no longer at a locker!", GetPlayerNameEx(target)), SendClientMessageEx(target, COLOR_GRAD2, "Your weapon request failed - Your not near any lockers!");
  521. if(arrGroupData[PlayerInfo[target][pMember]][g_iLockerStock] < arrGroupData[PlayerInfo[target][pMember]][g_iLockerCost][LockerReq[target][1]]) return SendClientMessageEx(playerid, COLOR_RED, "Your locker doesn't have the materials to craft a %s.", Weapon_ReturnName(LockerReq[target][0]));
  522. if(PlayerInfo[target][pGuns][GetWeaponSlot(LockerReq[target][0])] != LockerReq[target][0]) {
  523. arrGroupData[PlayerInfo[target][pMember]][g_iLockerStock] -= arrGroupData[PlayerInfo[target][pMember]][g_iLockerCost][LockerReq[target][1]];
  524. GivePlayerValidWeapon(target, LockerReq[target][0]);
  525. SendClientMessageEx(target, COLOR_WHITE, "You withdraw a %s from the locker - authorized by %s.", Weapon_ReturnName(LockerReq[target][0]), GetPlayerNameEx(playerid));
  526. SendClientMessageEx(playerid, COLOR_WHITE, "You have authorized %s to withdraw a %s from the locker.", GetPlayerNameEx(target), Weapon_ReturnName(LockerReq[target][0]));
  527. format(szMiscArray, sizeof(szMiscArray), "%s has authorized %s to withdraw a %s from the weapon locker (Cost: %d)", GetPlayerNameEx(playerid), GetPlayerNameEx(target), Weapon_ReturnName(LockerReq[target][0]), arrGroupData[PlayerInfo[target][pMember]][g_iLockerCost][LockerReq[target][1]]);
  528. GroupLog(PlayerInfo[target][pMember], szMiscArray);
  529. } else {
  530. SendClientMessageEx(playerid, COLOR_RED, "%s already has an %s!", GetPlayerNameEx(target), Weapon_ReturnName(LockerReq[target][0]));
  531. SendClientMessageEx(target, COLOR_RED, "You already have a %s on you!", Weapon_ReturnName(LockerReq[target][0]));
  532. }
  533. LockerReq[target][0] = 0;
  534. LockerReq[target][1] = -1;
  535. return 1;
  536. }
  537. ptask LockerTimer[1000](i) {
  538. if(LockerReq[i][0] > 0) {
  539. if(LockerReq[i][2] > gettime()) {
  540. if(PlayerBusy(i) || PlayerInfo[i][pJailTime] > 0 || PlayerCuffed[i] != 0) {
  541. SendClientMessageEx(i, COLOR_LIGHTBLUE, "* Your weapon withdraw request for the %s was interrupted.", Weapon_ReturnName(LockerReq[i][0]));
  542. LockerReq[i][0] = 0;
  543. LockerReq[i][1] = -1;
  544. }
  545. }
  546. if(LockerReq[i][2] == gettime()) {
  547. SendClientMessageEx(i, COLOR_LIGHTBLUE, "* Your weapon withdraw request for the %s has expired.", Weapon_ReturnName(LockerReq[i][0]));
  548. LockerReq[i][0] = 0;
  549. LockerReq[i][1] = -1;
  550. }
  551. }
  552. return 1;
  553. }
  554. CMD:convertlocker(playerid, params[]) {
  555. if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pASM] > 0 || PlayerInfo[playerid][pFactionModerator] > 0) {
  556. new group, total, amount;
  557. if(sscanf(params, "i", group)) return SendClientMessageEx(playerid, COLOR_GREY, "Usage: /convertlocker [groupid]");
  558. if(!ValidGroup(group)) return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid group specified!");
  559. for(new l = 0; l < MAX_GROUP_WEAPONS; l++) {
  560. if(arrGroupData[group][g_iLockerGuns][l] > 0) {
  561. if(LockerWep[group][lwWep][arrGroupData[group][g_iLockerGuns][l]-1] > 0) {
  562. total += LockerWep[group][lwWep][arrGroupData[group][g_iLockerGuns][l]-1];
  563. amount += (LockerWep[group][lwWep][arrGroupData[group][g_iLockerGuns][l]-1] * arrGroupData[group][g_iLockerCost][l]);
  564. }
  565. }
  566. }
  567. SetPVarInt(playerid, "converttotal", total);
  568. SetPVarInt(playerid, "convertamount", amount);
  569. SetPVarInt(playerid, "convertgroup", group);
  570. format(szMiscArray, sizeof(szMiscArray), "You're about to convert %s's old locker into \"High Grade Materials\"!\n\nHave you finished setting up the group lockers & costs via /editgroup?\n\nTotal Weapons: %s\nTotal Materials: %s", arrGroupData[group][g_szGroupName], number_format(total), number_format(amount));
  571. if(amount > 0) {
  572. Dialog_Show(playerid, convert_locker, DIALOG_STYLE_MSGBOX, "Are you sure?", szMiscArray, "Yes", "No");
  573. } else {
  574. Dialog_Show(playerid, -1, DIALOG_STYLE_MSGBOX, "No materials to convert", "There is no weapons to convert from the old locker.", "Close", "");
  575. }
  576. } else {
  577. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!");
  578. }
  579. return 1;
  580. }
  581. Dialog:convert_locker(playerid, response, listitem, inputtext[]) {
  582. if(response) {
  583. if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pASM] > 0 || PlayerInfo[playerid][pFactionModerator] > 0) {
  584. arrGroupData[GetPVarInt(playerid, "convertgroup")][g_iLockerStock] += GetPVarInt(playerid, "convertamount");
  585. SendClientMessageEx(playerid, COLOR_YELLOW, "%s weapons have been converted into materials (Amount: %s)", number_format(GetPVarInt(playerid, "converttotal")), number_format(GetPVarInt(playerid, "convertamount")));
  586. for(new w = 0; w < 46; w++) {
  587. LockerWep[GetPVarInt(playerid, "convertgroup")][lwWep][w] = 0;
  588. }
  589. //SaveWeapons(GetPVarInt(playerid, "convertgroup"));
  590. DeletePVar(playerid, "converttotal");
  591. DeletePVar(playerid, "convertamount");
  592. DeletePVar(playerid, "convertgroup");
  593. }
  594. } else {
  595. DeletePVar(playerid, "converttotal");
  596. DeletePVar(playerid, "convertamount");
  597. DeletePVar(playerid, "convertgroup");
  598. }
  599. return 1;
  600. }