Oblivion_UFF

This

Mar 12th, 2020
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6.  
  7. enum E_AMMUNATION_MDATA
  8. {
  9. WEAPON_MODELID,
  10. WEAPON_NAME[35],
  11. WEAPON_PRICE,
  12. WEAPON_AMMO,
  13. WEAPON_ID
  14. };
  15.  
  16. enum E_AMMUNATION_PDATA
  17. {
  18. PWEAPON_MODELID,
  19. PWEAPON_NAME[35],
  20. PWEAPON_PRICE,
  21. PWEAPON_AMMO,
  22. PWEAPON_ID
  23. };
  24.  
  25. new const AmmuMelee[][E_AMMUNATION_MDATA] =
  26. {
  27. //Model ID - Name - Price - Ammo - Weapon ID
  28. {331, "Brass Knuckles", 200, 1, WEAPON_BRASSKNUCKLE},
  29. {333, "Golf Club", 100, 1, WEAPON_GOLFCLUB},
  30. {335, "Knife", 250, 1, WEAPON_KNIFE}
  31. };
  32.  
  33. new const AmmuPistol[][E_AMMUNATION_PDATA] =
  34. {
  35. //Model ID - Name - Price - Ammo - Weapon ID
  36.  
  37. {46, "9mm Pistol", 500, 1, WEAPON_COLT45},
  38. {347, "Silenced Pistol", 500, 1, WEAPON_SILENCED},
  39. {348, "Desert Eagle", 500, 1, WEAPON_DEAGLE}
  40. };
  41.  
  42. enum
  43. {
  44. CATEGORY_MELEE,
  45. CATEGORY_PISTOLS
  46. }
  47. new AmmuCategory[MAX_PLAYERS];
  48.  
  49. public OnPlayerConnect(playerid)
  50. {
  51. AmmuCategory[playerid] = -1;
  52. return 1;
  53. }
  54.  
  55. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  56. {
  57. switch(dialogid)
  58. {
  59. case 1: //DIALOG_AMMUNATION
  60. {
  61. if(!response)
  62. {
  63. AmmuCategory[playerid] = -1;
  64. return 1;
  65. }
  66.  
  67. switch(listitem)
  68. {
  69. case 0: ShowAmmuMenu(playerid, CATEGORY_MELEE);
  70. case 1: ShowAmmuMenu(playerid, CATEGORY_PISTOLS);
  71. }
  72. }
  73. case 2: //DIALOG_AMMUNATION_BUY
  74. {
  75. if(!response)
  76. {
  77. AmmuCategory[playerid] = -1;
  78. return ShowDialogToPlayer(playerid, DIALOG_AMMUNATION);
  79. }
  80.  
  81. new wepCat = AmmuCategory[playerid];
  82. switch(wepCat)
  83. {
  84. case CATEGORY_MELEE:
  85. {
  86. for(new i = 0; i < sizeof(AmmuMelee); i++)
  87. {
  88. if(i == listitem)
  89. {
  90. if(GetPlayerCash(playerid) < AmmuMelee[i][WEAPON_PRICE])
  91. {
  92. SendErrorMessage(playerid, "You don't have enough money.");
  93. return ShowAmmuMenu(playerid, wepCat);
  94. }
  95.  
  96. RemovePlayerCash(playerid, AmmuMelee[i][WEAPON_PRICE]);
  97. TransactionLog(-1, playerid, AmmuMelee[i][WEAPON_PRICE], "Ammunation Gun Purchase", 1);
  98.  
  99. GivePlayerWeaponEx(playerid, AmmuMelee[i][WEAPON_ID], AmmuMelee[i][WEAPON_AMMO]);
  100.  
  101. SCMEX(playerid, -1, "* "ORANGE"Bought "WHITE"%s "ORANGE"with "WHITE"%d "ORANGE"ammo for "GREEN"%s"ORANGE".",
  102. ReturnWeaponName(AmmuMelee[listitem][WEAPON_ID]), AmmuMelee[listitem][WEAPON_AMMO], formatInt(AmmuMelee[listitem][WEAPON_PRICE]));
  103. break;
  104. }
  105. }
  106. }
  107. case CATEGORY_PISTOLS:
  108. {
  109. for(new i = 0; i < sizeof(AmmuPistol); i++)
  110. {
  111. if(i == listitem)
  112. {
  113. if(GetPlayerCash(playerid) < AmmuPistol[i][PWEAPON_PRICE])
  114. {
  115. SendErrorMessage(playerid, "You don't have enough money.");
  116. return ShowAmmuMenu(playerid, wepCat);
  117. }
  118.  
  119. RemovePlayerCash(playerid, AmmuPistol[i][PWEAPON_PRICE]);
  120. TransactionLog(-1, playerid, AmmuPistol[i][PWEAPON_PRICE], "Ammunation Gun Purchase", 1);
  121.  
  122. GivePlayerWeaponEx(playerid, AmmuPistol[i][WEAPON_ID], AmmuPistol[i][PWEAPON_AMMO]);
  123.  
  124. SCMEX(playerid, -1, "* "ORANGE"Bought "WHITE"%s "ORANGE"with "WHITE"%d "ORANGE"ammo for "GREEN"%s"ORANGE".",
  125. ReturnWeaponName(AmmuPistol[listitem][PWEAPON_ID]), AmmuPistol[listitem][PWEAPON_AMMO], formatInt(AmmuPistol[listitem][PWEAPON_PRICE]));
  126. break;
  127. }
  128. }
  129. }
  130. }
  131. ShowAmmuMenu(playerid, wepCat);
  132. }
  133. }
  134. return 1;
  135. }
  136.  
  137.  
  138. stock ShowAmmuMenu(playerid, category)
  139. {
  140. new subString[200];
  141.  
  142. AmmuCategory[playerid] = category;
  143.  
  144. switch(category)
  145. {
  146. case CATEGORY_MELEE:
  147. {
  148. new string[sizeof(AmmuMelee) * sizeof(subString)];
  149.  
  150. if(string[0] == EOS)
  151. {
  152. for(new i; i < sizeof(AmmuMelee); i++)
  153. {
  154. format(subString, sizeof(subString), "%i(0.0, 0.0, -50.0, 1.5)\t%s~n~~g~~h~$%i\n", AmmuMelee[i][WEAPON_MODELID], AmmuMelee[i][WEAPON_NAME], AmmuMelee[i][WEAPON_PRICE]);
  155. strcat(string, subString);
  156. }
  157. }
  158. ShowPlayerDialog(playerid, /*DIALOG_AMMUNATION_BUY*/ 2, /*DIALOG_STYLE_PREVIEW_MODEL*/ 2, "Ammunation", string, "Purchase", "Cancel");
  159. }
  160. case CATEGORY_PISTOLS:
  161. {
  162.  
  163. new string[sizeof(AmmuPistol) * sizeof(subString)];
  164.  
  165. if(string[0] == EOS)
  166. {
  167. for(new i; i < sizeof(AmmuPistol); i++)
  168. {
  169. format(subString, sizeof(subString), "%i(0.0, 0.0, -50.0, 1.5)\t%s~n~~g~~h~$%i\n", AmmuPistol[i][PWEAPON_MODELID], AmmuPistol[i][PWEAPON_NAME], AmmuPistol[i][PWEAPON_PRICE]);
  170. strcat(string, subString);
  171. }
  172. }
  173. ShowPlayerDialog(playerid, /*DIALOG_AMMUNATION_BUY*/ 2, /*DIALOG_STYLE_PREVIEW_MODEL*/ 2, "Ammunation", string, "Purchase", "Cancel");
  174. }
  175. }
  176. return 1;
  177. }
Advertisement
Add Comment
Please, Sign In to add comment