ammo.pwn 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /* Ammo Module
  2. Written by Dom
  3. */
  4. #include <YSI\y_hooks>
  5. GetAmmoType(iWeaponID)
  6. {
  7. switch(iWeaponID)
  8. {
  9. case WEAPON_SILENCED, WEAPON_COLT45, WEAPON_UZI, WEAPON_MP5, WEAPON_TEC9: return 0;
  10. case WEAPON_M4, WEAPON_SNIPER, WEAPON_RIFLE, WEAPON_AK47: return 1;
  11. case WEAPON_DEAGLE: return 2;
  12. case WEAPON_SHOTGUN, WEAPON_SAWEDOFF, WEAPON_SHOTGSPA: return 3;
  13. //case WEAPON_SHOTGUN, WEAPON_SAWEDOFF, WEAPON_SHOTGSPA: return 4;
  14. default: return -1;
  15. }
  16. return -1;
  17. }
  18. GetAmmoName(ammoType)
  19. {
  20. new ammo[30];
  21. switch(ammoType)
  22. {
  23. case 0: ammo = "Pistol Ammo";
  24. case 1: ammo = "Rifle Ammo";
  25. case 2: ammo = "Deagle Ammo";
  26. case 3: ammo = "Shotgun Ammo";
  27. //case 4: ammo = "12-gauge";
  28. default: ammo = "";
  29. }
  30. return ammo;
  31. }
  32. SyncPlayerAmmo(playerid, iWeaponID)
  33. {
  34. if(iWeaponID == WEAPON_SPRAYCAN || iWeaponID == WEAPON_CAMERA || iWeaponID == WEAPON_FIREEXTINGUISHER) return SetPlayerAmmo(playerid, iWeaponID, 99999);
  35. if(iWeaponID == WEAPON_MOLTOV || iWeaponID == WEAPON_GRENADE || iWeaponID == WEAPON_GRENADE) return SetPlayerAmmo(playerid, iWeaponID, 5);
  36. new iAmmoType = GetAmmoType(iWeaponID);
  37. if(GetPVarInt(playerid, "IsInArena") || GetPVarInt(playerid, "EventToken") != 0 || pTazer{playerid} != 0 || zombieevent) return 1;
  38. if(iAmmoType != -1)
  39. {
  40. if(arrAmmoData[playerid][awp_iAmmo][iAmmoType] > GetMaxAmmoAllowed(playerid, iAmmoType) && (PlayerInfo[playerid][pTogReports] == 1 || PlayerInfo[playerid][pAdmin] < 2))
  41. arrAmmoData[playerid][awp_iAmmo][iAmmoType] = GetMaxAmmoAllowed(playerid, iAmmoType);
  42. SetPlayerAmmo(playerid, iWeaponID, arrAmmoData[playerid][awp_iAmmo][iAmmoType]);
  43. //format(szMiscArray, sizeof(szMiscArray), "[debug] SyncPlayerAmmo - Values: ID %d - (iWeaponID) %d - (Ammo Type) %d", playerid, iWeaponID, iAmmoType);
  44. //SendClientMessageToAll(COLOR_WHITE, szMiscArray);
  45. //printf("[debug] SyncPlayerAmmo - Values: (playerid) %d - (iWeaponID) %d - (Ammo Type) %d", playerid, iWeaponID, iAmmoType);
  46. }
  47. return 1;
  48. }
  49. ResetVIPAmmoCount()
  50. {
  51. foreach(new i : Player)
  52. {
  53. PlayerInfo[i][pVIPGuncount] = 0;
  54. }
  55. mysql_tquery(MainPipeline, "UPDATE `accounts` SET `VIPGunsCount` = '0'", false, "", "");
  56. return 1;
  57. }
  58. GetMaxAmmoAllowed(playerid, iAmmoType) {
  59. new
  60. iSkinID = GetPlayerSkin(playerid);
  61. switch(iAmmoType) {
  62. case 0: { // Pistol Ammo
  63. if(iSkinID == 285 || iSkinID == 287)
  64. return 460;
  65. switch(PlayerInfo[playerid][pDonateRank]) {
  66. case 0, 1: return 220;
  67. case 2: return 280;
  68. case 3: return 340;
  69. default: return 340;
  70. }
  71. }
  72. case 1: { // Rifle Ammo
  73. if(iSkinID == 285 || iSkinID == 287)
  74. return 900;
  75. switch(PlayerInfo[playerid][pDonateRank]) {
  76. case 0, 1: return 600;
  77. case 2: return 660;
  78. case 3: return 800;
  79. default: return 800;
  80. }
  81. }
  82. case 2: { // Deagle Ammo
  83. if(iSkinID == 285 || iSkinID == 287)
  84. return 350;
  85. switch(PlayerInfo[playerid][pDonateRank]) {
  86. case 0, 1: return 120;
  87. case 2: return 170;
  88. case 3: return 230;
  89. default: return 230;
  90. }
  91. }
  92. case 3: { // Shotgun Ammo
  93. if(iSkinID == 285 || iSkinID == 287)
  94. return 210;
  95. switch(PlayerInfo[playerid][pDonateRank]) {
  96. case 0, 1: return 90;
  97. case 2: return 120;
  98. case 3: return 150;
  99. default: return 180;
  100. }
  101. }/*
  102. case 4: { // 12 gauge
  103. if(iSkinID == 285 || iSkinID == 287)
  104. return 160;
  105. switch(PlayerInfo[playerid][pDonateRank]) {
  106. case 0, 1: return 60;
  107. case 2: return 80;
  108. case 3: return 100;
  109. default: return 120;
  110. }
  111. }*/
  112. }
  113. return 0;
  114. }
  115. ShowAmmunationDialog(playerid)
  116. {
  117. return ShowPlayerDialogEx(playerid, DIALOG_AMMUNATION_MAIN, DIALOG_STYLE_LIST, "Ammunation Menu", "Weapons\nAmmo", "Select", "Cancel");
  118. }
  119. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  120. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  121. szMiscArray[0] = 0;
  122. switch(dialogid)
  123. {
  124. case DIALOG_AMMUNATION_MAIN:
  125. {
  126. if(!response)
  127. return SendClientMessageEx(playerid, COLOR_YELLOW, "Thank you for shopping at Ammunation! Come again!");
  128. switch(listitem)
  129. {
  130. case 0: { // weapons
  131. format(szMiscArray, sizeof(szMiscArray), "Weapon\tPrice\n9mm Pistol\t$%s\nPump Shotgun\t$%s\nDeagle\t$%s", number_format(GunPrices[0]), number_format(GunPrices[1]), number_format(GunPrices[2]));
  132. ShowPlayerDialogEx(playerid, DIALOG_AMMUNATION_GUNS, DIALOG_STYLE_TABLIST_HEADERS, "Ammunation Menu - Weapons", szMiscArray, "Select", "Back");
  133. }
  134. case 1: {// ammo
  135. format(szMiscArray, sizeof(szMiscArray), "Ammo Type\tPrice\nPistol Ammo\t$%s\nShotgun Ammo\t$%s\nDeagle Ammo\t$%s\nRifle Ammo\t$%s", number_format(GunPrices[3]), number_format(GunPrices[4]), number_format(GunPrices[5]), number_format(GunPrices[6]));
  136. ShowPlayerDialogEx(playerid, DIALOG_AMMUNATION_AMMO, DIALOG_STYLE_TABLIST_HEADERS, "Ammunation Menu - Ammo", szMiscArray, "Select", "Back");
  137. }
  138. }
  139. }
  140. case DIALOG_AMMUNATION_GUNS:
  141. {
  142. if(PlayerInfo[playerid][pGunLic] < gettime())
  143. return SendClientMessageEx(playerid, COLOR_GREY, "You must have an active license to purchase guns from a gun-shop!");
  144. if(!response)
  145. return ShowAmmunationDialog(playerid);
  146. switch(listitem)
  147. {
  148. case 0: // 9mm Pistol
  149. {
  150. new iWeaponMats = GetWeaponParam(WEAPON_COLT45, WeaponMats);
  151. new business = InBusiness(playerid);
  152. if(PlayerInfo[playerid][pCash] < GunPrices[0]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  153. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  154. Businesses[business][bInventory] -= iWeaponMats;
  155. Businesses[business][bTotalSales]++;
  156. Businesses[business][bLevelProgress]++;
  157. Businesses[business][bSafeBalance] += TaxSale(GunPrices[0]);
  158. SaveBusiness(business);
  159. GivePlayerCash(playerid, -GunPrices[0]);
  160. GivePlayerValidWeapon(playerid, WEAPON_COLT45, 0);
  161. format(szMiscArray, sizeof(szMiscArray), "%s has purchased 9mm pistol for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[0]), Businesses[business][bName]);
  162. SendClientMessageEx(playerid, -1, szMiscArray);
  163. Log("logs/business.log", szMiscArray);
  164. }
  165. case 1: // Pump Shotgun
  166. {
  167. new iWeaponMats = GetWeaponParam(WEAPON_SHOTGUN, WeaponMats);
  168. new business = InBusiness(playerid);
  169. if(PlayerInfo[playerid][pCash] < GunPrices[1]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  170. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  171. Businesses[business][bInventory] -= iWeaponMats;
  172. Businesses[business][bTotalSales]++;
  173. Businesses[business][bLevelProgress]++;
  174. Businesses[business][bSafeBalance] += TaxSale(GunPrices[1]);
  175. SaveBusiness(business);
  176. GivePlayerCash(playerid, -GunPrices[1]);
  177. GivePlayerValidWeapon(playerid, WEAPON_SHOTGUN, 0);
  178. format(szMiscArray, sizeof(szMiscArray), "%s has purchased shotgun for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[1]), Businesses[business][bName]);
  179. SendClientMessageEx(playerid, -1, szMiscArray);
  180. Log("logs/business.log", szMiscArray);
  181. }
  182. case 2: // Deagle
  183. {
  184. new iWeaponMats = GetWeaponParam(WEAPON_DEAGLE, WeaponMats);
  185. new business = InBusiness(playerid);
  186. if(PlayerInfo[playerid][pCash] < GunPrices[2]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  187. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  188. Businesses[business][bInventory] -= iWeaponMats;
  189. Businesses[business][bTotalSales]++;
  190. Businesses[business][bLevelProgress]++;
  191. Businesses[business][bSafeBalance] += TaxSale(GunPrices[2]);
  192. SaveBusiness(business);
  193. GivePlayerCash(playerid, -GunPrices[2]);
  194. GivePlayerValidWeapon(playerid, WEAPON_DEAGLE, 0);
  195. format(szMiscArray, sizeof(szMiscArray), "%s has purchased deagle for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[2]), Businesses[business][bName]);
  196. SendClientMessageEx(playerid, -1, szMiscArray);
  197. Log("logs/business.log", szMiscArray);
  198. }
  199. }
  200. }
  201. case DIALOG_AMMUNATION_AMMO:
  202. {
  203. if(!response)
  204. return ShowAmmunationDialog(playerid);
  205. switch(listitem)
  206. {
  207. case 0: // Pistol Ammo
  208. {
  209. new business = InBusiness(playerid);
  210. if(PlayerInfo[playerid][pCash] < GunPrices[3]) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money on you.");
  211. if(Businesses[business][bInventory] < (GunPrices[3]/1000)) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  212. if((arrAmmoData[playerid][awp_iAmmo][0] + 60) > GetMaxAmmoAllowed(playerid, 0)) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot carry any more magazines on you.");
  213. Businesses[business][bInventory] -= (GunPrices[3]/1000);
  214. Businesses[business][bTotalSales]++;
  215. Businesses[business][bLevelProgress]++;
  216. Businesses[business][bSafeBalance] += TaxSale(GunPrices[3]);
  217. SaveBusiness(business);
  218. GivePlayerCash(playerid, -GunPrices[3]);
  219. arrAmmoData[playerid][awp_iAmmo][0] += 60;
  220. for(new i = 0; i < 12; i++) {
  221. SyncPlayerAmmo(playerid, PlayerInfo[playerid][pGuns][i]);
  222. }
  223. format(szMiscArray, sizeof(szMiscArray), "%s has purchased Pistol Ammo for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[3]), Businesses[business][bName]);
  224. SendClientMessageEx(playerid, -1, szMiscArray);
  225. Log("logs/business.log", szMiscArray);
  226. }
  227. case 1: // Shotgun Ammo
  228. {
  229. new business = InBusiness(playerid);
  230. if(PlayerInfo[playerid][pCash] < GunPrices[4]) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money on you.");
  231. if(Businesses[business][bInventory] < (GunPrices[4]/1000)) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  232. if((arrAmmoData[playerid][awp_iAmmo][3] + 40) > GetMaxAmmoAllowed(playerid, 3)) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot carry any more magazines on you.");
  233. Businesses[business][bInventory] -= (GunPrices[4]/1000);
  234. Businesses[business][bTotalSales]++;
  235. Businesses[business][bLevelProgress]++;
  236. Businesses[business][bSafeBalance] += TaxSale(GunPrices[4]);
  237. SaveBusiness(business);
  238. GivePlayerCash(playerid, -GunPrices[4]);
  239. arrAmmoData[playerid][awp_iAmmo][3] += 40;
  240. for(new i = 0; i < 12; i++) {
  241. SyncPlayerAmmo(playerid, PlayerInfo[playerid][pGuns][i]);
  242. }
  243. format(szMiscArray, sizeof(szMiscArray), "%s has purchased Shotgun ammo for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[4]), Businesses[business][bName]);
  244. SendClientMessageEx(playerid, -1, szMiscArray);
  245. Log("logs/business.log", szMiscArray);
  246. }
  247. case 2: // Deagle ammo
  248. {
  249. new business = InBusiness(playerid);
  250. if(PlayerInfo[playerid][pCash] < GunPrices[5]) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money on you.");
  251. if(Businesses[business][bInventory] < (GunPrices[5]/1000)) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  252. if((arrAmmoData[playerid][awp_iAmmo][2] + 30) > GetMaxAmmoAllowed(playerid, 2)) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot carry any more magazines on you.");
  253. Businesses[business][bInventory] -= (GunPrices[5]/1000);
  254. Businesses[business][bTotalSales]++;
  255. Businesses[business][bLevelProgress]++;
  256. Businesses[business][bSafeBalance] += TaxSale(GunPrices[5]);
  257. SaveBusiness(business);
  258. GivePlayerCash(playerid, -GunPrices[5]);
  259. arrAmmoData[playerid][awp_iAmmo][2] += 30;
  260. for(new i = 0; i < 12; i++) {
  261. SyncPlayerAmmo(playerid, PlayerInfo[playerid][pGuns][i]);
  262. }
  263. format(szMiscArray, sizeof(szMiscArray), "%s has purchased Deagle Ammo for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[5]), Businesses[business][bName]);
  264. SendClientMessageEx(playerid, -1, szMiscArray);
  265. Log("logs/business.log", szMiscArray);
  266. }
  267. case 3: // Rifle ammo
  268. {
  269. new business = InBusiness(playerid);
  270. if(PlayerInfo[playerid][pCash] < GunPrices[6]) return SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money on you.");
  271. if(Businesses[business][bInventory] < (GunPrices[6]/1000)) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  272. if((arrAmmoData[playerid][awp_iAmmo][1] + 50) > GetMaxAmmoAllowed(playerid, 1)) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot carry any more magazines on you.");
  273. Businesses[business][bInventory] -= (GunPrices[6]/1000);
  274. Businesses[business][bTotalSales]++;
  275. Businesses[business][bLevelProgress]++;
  276. Businesses[business][bSafeBalance] += TaxSale(GunPrices[6]);
  277. SaveBusiness(business);
  278. GivePlayerCash(playerid, -GunPrices[6]);
  279. arrAmmoData[playerid][awp_iAmmo][1] += 50;
  280. for(new i = 0; i < 12; i++) {
  281. SyncPlayerAmmo(playerid, PlayerInfo[playerid][pGuns][i]);
  282. }
  283. format(szMiscArray, sizeof(szMiscArray), "%s has purchased Rifle Ammo for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[6]), Businesses[business][bName]);
  284. SendClientMessageEx(playerid, -1, szMiscArray);
  285. Log("logs/business.log", szMiscArray);
  286. }
  287. }
  288. }
  289. }
  290. return 0;
  291. }
  292. CMD:issuegl(playerid, params[]) return cmd_issuegunlicense(playerid, params);
  293. CMD:issuegunlicense(playerid, params[])
  294. {
  295. if((0 <= PlayerInfo[playerid][pLeader] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pLeader]][g_iGroupType] == GROUP_TYPE_GOV)
  296. {
  297. new iTargetID;
  298. szMiscArray[0] = 0;
  299. if(sscanf(params, "u", iTargetID)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /issuegunlicense [playerid]");
  300. PlayerInfo[iTargetID][pGunLic] = gettime() + (86400*30);
  301. format(szMiscArray, sizeof(szMiscArray), "%s has renewed %s's gun license.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID));
  302. foreach(new i : Player)
  303. if((0 <= PlayerInfo[i][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[i][pMember]][g_iGroupType] == GROUP_TYPE_GOV)
  304. SendClientMessageEx(i, COLOR_RED, szMiscArray);
  305. format(szMiscArray, sizeof(szMiscArray), "%s(%d) (%s) has issued %s(%d) (%s) a gun license.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), GetPlayerNameEx(iTargetID), GetPlayerSQLId(iTargetID), GetPlayerIpEx(iTargetID));
  306. Log("logs/licenses.log", szMiscArray);
  307. }
  308. else SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use this command!");
  309. return 1;
  310. }
  311. CMD:buygun(playerid, params[])
  312. {
  313. new business = InBusiness(playerid);
  314. if(business == INVALID_BUSINESS_ID || Businesses[business][bType] != BUSINESS_TYPE_GUNSHOP) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not at a gunshop!");
  315. if(PlayerInfo[playerid][pConnectHours] < 8) return SendClientMessageEx(playerid, COLOR_WHITE, "You have not played enough to obtain a weapon!");
  316. ShowAmmunationDialog(playerid);
  317. return 1;
  318. }
  319. CMD:loadammo(playerid, params[])
  320. {
  321. new iVehID = GetPlayerVehicleID(playerid);
  322. new iGroupID = PlayerInfo[playerid][pMember];
  323. szMiscArray[0] = 0;
  324. if(DynVeh[iVehID] == -1 || DynVehicleInfo[DynVeh[iVehID]][gv_iType] != 2) return SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle cannot be loaded with Ammo.");
  325. if(DynVehicleInfo[DynVeh[iVehID]][gv_iAmmoLoaded] > 0) return SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle has already been loaded with ammo.");
  326. if(0 <= iGroupID < MAX_GROUPS && (arrGroupData[iGroupID][g_iGroupType] == GROUP_TYPE_GOV || arrGroupData[iGroupID][g_iGroupType] == GROUP_TYPE_LEA))
  327. {
  328. for(new i = 0; i < MAX_BUSINESSES; i++)
  329. {
  330. if(IsPlayerInRangeOfPoint(playerid, 5.0, Businesses[i][bSupplyPos][0], Businesses[i][bSupplyPos][1], Businesses[i][bSupplyPos][2]) && Businesses[i][bType] == BUSINESS_TYPE_GUNSHOP)
  331. {
  332. DynVehicleInfo[DynVeh[iVehID]][gv_iAmmoLoaded] = 1;
  333. arrGroupData[iGroupID][g_iBudget] -= 400000;
  334. Businesses[i][bSafeBalance] += TaxSale(400000);
  335. SendClientMessageEx(playerid, COLOR_WHITE, "You have loaded ammo into your vehicle. Deliver it back to your HQ. ");
  336. format(szMiscArray, sizeof(szMiscArray), "%s has paid $400,000 for an ammo crate resupply at %s (%d).", GetPlayerNameEx(playerid), Businesses[i][bName], i);
  337. Log("logs/business.log", szMiscArray);
  338. format(szMiscArray, sizeof(szMiscArray), "%s has paid $400,000 for an ammo crate resupply.", GetPlayerNameEx(playerid));
  339. GroupLog(iGroupID, szMiscArray);
  340. break;
  341. }
  342. }
  343. }
  344. else SendClientMessageEx(playerid, COLOR_WHITE, "You must be a LEO to use this command");
  345. return 1;
  346. }
  347. CMD:deliverammo(playerid, params[])
  348. {
  349. new iVehID = GetPlayerVehicleID(playerid);
  350. new iGroupID = PlayerInfo[playerid][pMember];
  351. szMiscArray[0] = 0;
  352. if(DynVeh[iVehID] == -1 || DynVehicleInfo[DynVeh[iVehID]][gv_iType] != 2) return SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle is not designated to ammo transportation.");
  353. if(DynVehicleInfo[DynVeh[iVehID]][gv_iAmmoLoaded] == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle does not have any ammo in it.");
  354. if(0 <= iGroupID < MAX_GROUPS && (arrGroupData[iGroupID][g_iGroupType] == GROUP_TYPE_GOV || arrGroupData[iGroupID][g_iGroupType] == GROUP_TYPE_LEA))
  355. {
  356. for(new i = 0; i < MAX_GROUPS; i++)
  357. {
  358. if(IsPlayerInRangeOfPoint(playerid, 6, arrGroupData[i][g_fCratePos][0], arrGroupData[i][g_fCratePos][1], arrGroupData[i][g_fCratePos][2]))
  359. {
  360. if(arrGroupData[i][g_iAmmo][0] + 5000 <= 50000) arrGroupData[i][g_iAmmo][0] += 5000; else arrGroupData[i][g_iAmmo][0] += (50000 - arrGroupData[i][g_iAmmo][0]);
  361. if(arrGroupData[i][g_iAmmo][1] + 5000 <= 50000) arrGroupData[i][g_iAmmo][1] += 5000; else arrGroupData[i][g_iAmmo][1] += (50000 - arrGroupData[i][g_iAmmo][1]);
  362. if(arrGroupData[i][g_iAmmo][2] + 5000 <= 50000) arrGroupData[i][g_iAmmo][2] += 5000; else arrGroupData[i][g_iAmmo][2] += (50000 - arrGroupData[i][g_iAmmo][2]);
  363. if(arrGroupData[i][g_iAmmo][3] + 5000 <= 50000) arrGroupData[i][g_iAmmo][3] += 5000; else arrGroupData[i][g_iAmmo][3] += (50000 - arrGroupData[i][g_iAmmo][3]);
  364. //if(arrGroupData[i][g_iAmmo][4] + 5000 <= 10000) arrGroupData[i][g_iAmmo][4] += 5000; else arrGroupData[i][g_iAmmo][4] += (10000 - arrGroupData[i][g_iAmmo][4]);
  365. DynVehicleInfo[DynVeh[iVehID]][gv_iAmmoLoaded] = 0;
  366. format(szMiscArray, sizeof(szMiscArray), "%s delivered an ammo crate.", GetPlayerNameEx(playerid));
  367. GroupLog(iGroupID, szMiscArray);
  368. SendClientMessageEx(playerid, COLOR_WHITE, "You have delivered ammo to your HQ. ");
  369. break;
  370. }
  371. }
  372. }
  373. return 1;
  374. }
  375. ListAmmo(playerid, targetid)
  376. {
  377. szMiscArray[0] = 0;
  378. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  379. format(szMiscArray, sizeof(szMiscArray), "Ammo on %s:", GetPlayerNameEx(targetid));
  380. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  381. for(new i = 0; i != MAX_AMMO_TYPES; i++)
  382. {
  383. format(szMiscArray, sizeof(szMiscArray), "%s: %i / %i rounds", GetAmmoName(i), arrAmmoData[targetid][awp_iAmmo][i], GetMaxAmmoAllowed(targetid, i));
  384. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  385. }
  386. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  387. return 1;
  388. }
  389. CMD:myammo(playerid, params[]) return ListAmmo(playerid, playerid);
  390. CMD:seeammo(playerid, params[]) {
  391. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot use this command!");
  392. new target;
  393. if(sscanf(params, "u", target)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /seeammo [playerid]");
  394. if(!IsPlayerConnected(target)) return SendClientMessageEx(playerid, COLOR_GRAD2, "That player is not connected");
  395. return ListAmmo(playerid, target);
  396. }
  397. CMD:setammo(playerid, params[]) {
  398. szMiscArray[0] = 0;
  399. new
  400. iTargetID,
  401. iAmmoType,
  402. iAmount;
  403. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_WHITE, "You cannot use this command!");
  404. if(sscanf(params, "uii", iTargetID, iAmmoType, iAmount)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /setammo [playerid] [type (0 - 3)] [amount]");
  405. if(!IsPlayerConnected(iTargetID)) return SendClientMessageEx(playerid, COLOR_GRAD2, "That player is not connected.");
  406. if(iAmount < 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "The amount cannot be less than 1.");
  407. format(szMiscArray, sizeof(szMiscArray), "You have given %s %i ammo (type:%i)", GetPlayerNameEx(iTargetID), iAmount, iAmmoType);
  408. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  409. format(szMiscArray, sizeof(szMiscArray), "%s(%s) has given %s(%d) (%s) %i ammo (type:%i)", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid), GetPlayerNameEx(iTargetID), GetPlayerSQLId(iTargetID), GetPlayerIpEx(iTargetID), iAmount, iAmmoType);
  410. Log("logs/admingive.log", szMiscArray);
  411. arrAmmoData[iTargetID][awp_iAmmo][iAmmoType] = iAmount;
  412. return 1;
  413. }
  414. CMD:rld(playerid, params[]) {
  415. if(GetPVarInt(playerid, "Injured") || PlayerCuffed[playerid] > 0 || GetPVarInt(playerid, "IsInArena") || GetPVarInt(playerid, "EventToken") != 0 || PlayerInfo[playerid][pHospital] > 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot do this right now!");
  416. for(new i = 0; i < 12; i++)
  417. {
  418. GivePlayerWeapon(playerid, PlayerInfo[playerid][pGuns][i], 1);
  419. SyncPlayerAmmo(playerid, PlayerInfo[playerid][pGuns][i]);
  420. }
  421. ApplyAnimation(playerid, "PYTHON", "python_reload", 4.0, 0, 0, 0, 0, 0, 1);
  422. return 1;
  423. }
  424. CMD:vipgunsleft(playerid, params[]) {
  425. szMiscArray[0] = 0;
  426. if(PlayerInfo[playerid][pDonateRank] < 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not a VIP member.");
  427. switch(PlayerInfo[playerid][pDonateRank]) {
  428. case 4: format(szMiscArray, sizeof(szMiscArray), "%s has %d VIP gun withdraws left today!", GetPlayerNameEx(playerid), 8-PlayerInfo[playerid][pVIPGuncount]);
  429. default: format(szMiscArray, sizeof(szMiscArray), "%s has %d VIP gun withdraws left today!", GetPlayerNameEx(playerid), 4-PlayerInfo[playerid][pVIPGuncount]);
  430. }
  431. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  432. return 1;
  433. }
  434. CMD:editgsprices(playerid, params[]) {
  435. szMiscArray[0] = 0;
  436. new
  437. choice[32],
  438. amount;
  439. if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use that command!");
  440. if(sscanf(params, "s[32]d", choice, amount)) {
  441. SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /editgsprices [choice] [amount]");
  442. SendClientMessageEx(playerid, COLOR_WHITE, "Available choices: colt45, shotgun, deagle, pistolm, shotgunm, deaglem, riflem");
  443. format(szMiscArray, sizeof(szMiscArray), "colt45: $%s | shotgun: $%s | Deagle: $%s | Pistol Ammo: $%s | Shotgun Ammo: $%s | Deagle Ammo: $%s | Rifle Ammo: %s", number_format(GunPrices[0]), number_format(GunPrices[1]), number_format(GunPrices[2]), number_format(GunPrices[3]), number_format(GunPrices[4]), number_format(GunPrices[5]), number_format(GunPrices[6]));
  444. return SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  445. }
  446. if(strcmp(choice, "colt45", true) == 0) {
  447. GunPrices[0] = amount;
  448. format(szMiscArray, sizeof(szMiscArray), "%s has changed the colt45 price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  449. Log("logs/business.log", szMiscArray);
  450. g_mysql_SaveMOTD();
  451. }
  452. if(strcmp(choice, "shotgun", true) == 0) {
  453. GunPrices[1] = amount;
  454. format(szMiscArray, sizeof(szMiscArray), "%s has changed the shotgun price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  455. Log("logs/business.log", szMiscArray);
  456. g_mysql_SaveMOTD();
  457. }
  458. if(strcmp(choice, "deagle", true) == 0) {
  459. GunPrices[2] = amount;
  460. format(szMiscArray, sizeof(szMiscArray), "%s has changed the deagle price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  461. Log("logs/business.log", szMiscArray);
  462. g_mysql_SaveMOTD();
  463. }
  464. if(strcmp(choice, "pistolm", true) == 0) {
  465. GunPrices[3] = amount;
  466. format(szMiscArray, sizeof(szMiscArray), "%s has changed the Pistol Ammo price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  467. Log("logs/business.log", szMiscArray);
  468. g_mysql_SaveMOTD();
  469. }
  470. if(strcmp(choice, "shotgunm", true) == 0) {
  471. GunPrices[4] = amount;
  472. format(szMiscArray, sizeof(szMiscArray), "%s has changed the Shotgun Ammo price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  473. Log("logs/business.log", szMiscArray);
  474. g_mysql_SaveMOTD();
  475. }
  476. if(strcmp(choice, "deaglem", true) == 0) {
  477. GunPrices[5] = amount;
  478. format(szMiscArray, sizeof(szMiscArray), "%s has changed the Deagle Ammo price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  479. Log("logs/business.log", szMiscArray);
  480. g_mysql_SaveMOTD();
  481. }
  482. if(strcmp(choice, "riflem", true) == 0) {
  483. GunPrices[6] = amount;
  484. format(szMiscArray, sizeof(szMiscArray), "%s has changed the Rifle Ammo price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  485. Log("logs/business.log", szMiscArray);
  486. g_mysql_SaveMOTD();
  487. }
  488. g_mysql_SaveMOTD();
  489. return 1;
  490. }
  491. /*
  492. CMD:ammohelp(playerid, params[]) {
  493. SendClientMessageEx(playerid, COLOR_WHITE, "*** AMMO *** /rld /myammo /buygun");
  494. if((0 <= PlayerInfo[playerid][pLeader] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pLeader]][g_iGroupType] == GROUP_TYPE_GOV) SendClientMessageEx(playerid, COLOR_WHITE, "*** AMMO (GOV) *** /issuegunlicense");
  495. if(IsACop(playerid)) SendClientMessageEx(playerid, COLOR_WHITE, "*** AMMO (LEO) *** /loadammo /deliverammo");
  496. if(PlayerInfo[playerid][pDonateRank] > 2) SendClientMessageEx(playerid, COLOR_WHITE, "*** AMMO (VIP) *** /vipgunsleft");
  497. if(PlayerInfo[playerid][pAdmin] > 4) SendClientMessageEx(playerid, COLOR_WHITE, "*** AMMO (ADMIN) *** /editgsprices /setammo");
  498. return 1;
  499. }
  500. */
  501. /*CMD:oissuegl(playerid, params[]) return cmd_oissuegunlicense(playerid, params);
  502. CMD:oissuegunlicense(playerid, params[])
  503. {
  504. if((0 <= PlayerInfo[playerid][pLeader] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pLeader]][g_iGroupType] == GROUP_TYPE_GOV)
  505. {
  506. szMiscArray[0] = 0;
  507. new TargetName[MAX_PLAYERS];
  508. if(sscanf(params, "s[24]", TargetName)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /oissuegunlicense [playerid]");
  509. if(IsPlayerConnected(ReturnUser(TargetName))) return cmd_issuegunlicense(playerid, params);
  510. new PlayerName[MAX_PLAYERS];
  511. mysql_escape_string(TargetName, PlayerName);
  512. format(szMiscArray, sizeof(szMiscArray), "Attempting to offline issue %s a gun license.", PlayerName);
  513. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  514. SendClientMessageEx(playerid, COLOR_YELLOW, "Please wait...");
  515. format(szMiscArray, sizeof(szMiscArray), "SELECT `id`, `IP` FROM `accounts` WHERE `Username` = '%s'", PlayerName);
  516. mysql_tquery(MainPipeline, szMiscArray, true, "OnOfflineGunLicense", "iis", playerid, 1, PlayerName);
  517. }
  518. else SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use this command!");
  519. return 1;
  520. }*/
  521. CMD:orevokegl(playerid, params[]) return cmd_orevokegunlicense(playerid, params);
  522. CMD:orevokegunlicense(playerid, params[])
  523. {
  524. if((0 <= PlayerInfo[playerid][pLeader] < MAX_GROUPS) && arrGroupData[PlayerInfo[playerid][pLeader]][g_iGroupType] == GROUP_TYPE_GOV || PlayerInfo[playerid][pLeader] == 1)
  525. {
  526. szMiscArray[0] = 0;
  527. new TargetName[MAX_PLAYERS];
  528. if(sscanf(params, "s[24]", TargetName)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /orevokegunlicense [playerid]");
  529. if(IsPlayerConnected(ReturnUser(TargetName))) return cmd_issuegunlicense(playerid, params);
  530. new PlayerName[MAX_PLAYERS];
  531. mysql_escape_string(TargetName, PlayerName);
  532. format(szMiscArray, sizeof(szMiscArray), "Attempting to offline revoke %s a gun license.", PlayerName);
  533. SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  534. SendClientMessageEx(playerid, COLOR_YELLOW, "Please wait...");
  535. format(szMiscArray, sizeof(szMiscArray), "SELECT `id`, `IP` FROM `accounts` WHERE `Username` = '%s'", PlayerName);
  536. mysql_tquery(MainPipeline, szMiscArray, true, "OnOfflineGunLicense", "iis", playerid, 0, PlayerName);
  537. }
  538. else SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use this command!");
  539. return 1;
  540. }
  541. /*forward OnOfflineGunLicense(playerid, task, name[]);
  542. public OnOfflineGunLicense(playerid, task, name[])
  543. {
  544. if(cache_get_row_count(MainPipeline) == 0)
  545. return SendClientMessageEx(playerid, COLOR_RED, "Error - This account does not exist.");
  546. format(szMiscArray, sizeof(szMiscArray), "UPDATE `accounts` SET `GunLic` = %d WHERE `Username` = '%s'", task, name);
  547. mysql_tquery(MainPipeline, szMiscArray, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  548. format(szMiscArray, sizeof(szMiscArray), "%s has offline %s %s a gun license.", GetPlayerNameEx(playerid), task ? ("issued"):("revoked"), name);
  549. foreach(new i : Player)
  550. if((0 <= PlayerInfo[i][pMember] < MAX_GROUPS) && arrGroupData[PlayerInfo[i][pMember]][g_iGroupType] == GROUP_TYPE_GOV)
  551. SendClientMessageEx(i, COLOR_RED, szMiscArray);
  552. new ip_address[16];
  553. cache_get_field_content(0, "IP", ip_address, MainPipeline);
  554. format(szMiscArray, sizeof(szMiscArray), "%s(%d) (%s) has offline %s %s(%d) (%s) a gun license.", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), task ? ("issued"):("revoked"), name, cache_get_field_content_int(0, "id"), ip_address);
  555. Log("logs/licenses.log", szMiscArray);
  556. return 1;
  557. }*/
  558. ShowAmmoDialog(playerid, dialogid, title[], arr[])
  559. {
  560. szMiscArray[0] = 0;
  561. strcat(szMiscArray, "Ammo Type\tAmount\n");
  562. for(new i = 0; i != MAX_AMMO_TYPES; i++)
  563. {
  564. format(szMiscArray, sizeof(szMiscArray), "%s%s\t%d\n", szMiscArray, GetAmmoName(i), arr[i]);
  565. }
  566. return ShowPlayerDialogEx(playerid, dialogid, DIALOG_STYLE_TABLIST_HEADERS, title, szMiscArray, "Select", "Cancel");
  567. }