ammunation.pwn 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #include <YSI\y_hooks>
  2. CMD:buygun(playerid, params[])
  3. {
  4. szMiscArray[0] = 0;
  5. new business = InBusiness(playerid);
  6. if(business == INVALID_BUSINESS_ID || Businesses[business][bType] != BUSINESS_TYPE_GUNSHOP) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not at a gunshop!");
  7. if(PlayerInfo[playerid][pConnectHours] < 8) return SendClientMessageEx(playerid, COLOR_WHITE, "You have not played enough to obtain a weapon!");
  8. 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]));
  9. ShowPlayerDialogEx(playerid, DIALOG_AMMUNATION_GUNS, DIALOG_STYLE_TABLIST_HEADERS, "Ammunation Menu - Weapons", szMiscArray, "Select", "Back");
  10. return 1;
  11. }
  12. CMD:editgsprices(playerid, params[]) {
  13. szMiscArray[0] = 0;
  14. new
  15. choice[32],
  16. amount;
  17. if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_WHITE, "You are not authorized to use that command!");
  18. if(sscanf(params, "s[32]d", choice, amount)) {
  19. SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /editgsprices [choice] [amount]");
  20. SendClientMessageEx(playerid, COLOR_WHITE, "Available choices: colt45, shotgun, deagle");
  21. format(szMiscArray, sizeof(szMiscArray), "colt45: $%s | shotgun: $%s | Deagle: $%s", number_format(GunPrices[0]), number_format(GunPrices[1]), number_format(GunPrices[2]));
  22. return SendClientMessageEx(playerid, COLOR_WHITE, szMiscArray);
  23. }
  24. if(strcmp(choice, "colt45", true) == 0) {
  25. GunPrices[0] = amount;
  26. format(szMiscArray, sizeof(szMiscArray), "%s has changed the colt45 price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  27. Log("logs/business.log", szMiscArray);
  28. g_mysql_SaveMOTD();
  29. }
  30. if(strcmp(choice, "shotgun", true) == 0) {
  31. GunPrices[1] = amount;
  32. format(szMiscArray, sizeof(szMiscArray), "%s has changed the shotgun price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  33. Log("logs/business.log", szMiscArray);
  34. g_mysql_SaveMOTD();
  35. }
  36. if(strcmp(choice, "deagle", true) == 0) {
  37. GunPrices[2] = amount;
  38. format(szMiscArray, sizeof(szMiscArray), "%s has changed the deagle price to $%s", GetPlayerNameEx(playerid), number_format(amount));
  39. Log("logs/business.log", szMiscArray);
  40. g_mysql_SaveMOTD();
  41. }
  42. g_mysql_SaveMOTD();
  43. return 1;
  44. }
  45. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  46. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  47. szMiscArray[0] = 0;
  48. switch(dialogid)
  49. {
  50. case DIALOG_AMMUNATION_GUNS:
  51. {
  52. if(PlayerInfo[playerid][pGunLic] < gettime())
  53. return SendClientMessageEx(playerid, COLOR_GREY, "You must have an active license to purchase guns from a gun-shop!");
  54. if(!response)
  55. return 1;
  56. switch(listitem)
  57. {
  58. case 0: // 9mm Pistol
  59. {
  60. new iWeaponMats = GetWeaponParam(WEAPON_COLT45, WeaponMats);
  61. new business = InBusiness(playerid);
  62. if(PlayerInfo[playerid][pCash] < GunPrices[0]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  63. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  64. Businesses[business][bInventory] -= iWeaponMats;
  65. Businesses[business][bTotalSales]++;
  66. Businesses[business][bLevelProgress]++;
  67. Businesses[business][bSafeBalance] += TaxSale(GunPrices[0]);
  68. SaveBusiness(business);
  69. GivePlayerCash(playerid, -GunPrices[0]);
  70. GivePlayerValidWeapon(playerid, WEAPON_COLT45);
  71. format(szMiscArray, sizeof(szMiscArray), "%s has purchased 9mm pistol for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[0]), Businesses[business][bName]);
  72. SendClientMessageEx(playerid, -1, szMiscArray);
  73. Log("logs/business.log", szMiscArray);
  74. }
  75. case 1: // Pump Shotgun
  76. {
  77. new iWeaponMats = GetWeaponParam(WEAPON_SHOTGUN, WeaponMats);
  78. new business = InBusiness(playerid);
  79. if(PlayerInfo[playerid][pCash] < GunPrices[1]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  80. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  81. Businesses[business][bInventory] -= iWeaponMats;
  82. Businesses[business][bTotalSales]++;
  83. Businesses[business][bLevelProgress]++;
  84. Businesses[business][bSafeBalance] += TaxSale(GunPrices[1]);
  85. SaveBusiness(business);
  86. GivePlayerCash(playerid, -GunPrices[1]);
  87. GivePlayerValidWeapon(playerid, WEAPON_SHOTGUN);
  88. format(szMiscArray, sizeof(szMiscArray), "%s has purchased shotgun for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[1]), Businesses[business][bName]);
  89. SendClientMessageEx(playerid, -1, szMiscArray);
  90. Log("logs/business.log", szMiscArray);
  91. }
  92. case 2: // Deagle
  93. {
  94. new iWeaponMats = GetWeaponParam(WEAPON_DEAGLE, WeaponMats);
  95. new business = InBusiness(playerid);
  96. if(PlayerInfo[playerid][pCash] < GunPrices[2]) return SendClientMessageEx(playerid, COLOR_WHITE, "You do not have enough money!");
  97. if(Businesses[business][bInventory] < iWeaponMats) return SendClientMessageEx(playerid, COLOR_WHITE, "The business has run out of stock");
  98. Businesses[business][bInventory] -= iWeaponMats;
  99. Businesses[business][bTotalSales]++;
  100. Businesses[business][bLevelProgress]++;
  101. Businesses[business][bSafeBalance] += TaxSale(GunPrices[2]);
  102. SaveBusiness(business);
  103. GivePlayerCash(playerid, -GunPrices[2]);
  104. GivePlayerValidWeapon(playerid, WEAPON_DEAGLE);
  105. format(szMiscArray, sizeof(szMiscArray), "%s has purchased deagle for $%s at %s", GetPlayerNameEx(playerid), number_format(GunPrices[2]), Businesses[business][bName]);
  106. SendClientMessageEx(playerid, -1, szMiscArray);
  107. Log("logs/business.log", szMiscArray);
  108. }
  109. }
  110. }
  111. }
  112. return 0;
  113. }