Guest User

So gehts

a guest
Nov 17th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. /*
  2. *
  3. *
  4. adm_Bomb 2.0 (Author: Admantis)
  5. *
  6. * Features
  7. - Easy to configure system.
  8. - Can set the bomb shop coordenates
  9. - Can set the bomb cost
  10. - After a time the bomb will explode (can set too)
  11. - Can set realistic features (beep, object on ground)
  12.  
  13. * Commands
  14. - /buybomb
  15. - /givebomb
  16. - /plantbomb
  17.  
  18. * Disclaimer
  19. - Credits are not needed, just don't claim it as yours
  20. - You may not re-release this or sell it
  21.  
  22. * Notes
  23. - Please report any bugs to Admantis via SA:MP forums PM
  24. - I'm not responsible of how this could harm your server
  25. - You need the command processor 'zcmd' to use this
  26. - Slow computers may lag at the bomb explosion
  27. *
  28. *
  29. *
  30. *
  31. */
  32.  
  33. #include a_samp
  34. #include zcmd
  35. #include sscanf2
  36.  
  37. #define ShopX 0.000 // Change me, I'm the X place of bomb shop!
  38. #define ShopY 0.000 // Change me, I'm the Y place of bomb shop!
  39. #define ShopZ 0.000 // Change me, I'm the Z place of bomb shop!
  40. #define ShopV 0 // Change me, I'm the virtual world of bomb shop!
  41. #define Cost 25000 // Change me, I'm the cost of the bomb!
  42. #define BombTimer 30 // Change me, I'm in how many seconds will the bomb blow up!
  43. #define Realism 1 // Change me, I'm the one who toggles realism options! (0=false/1=true)
  44. #define Explosions 5 // Change me, I'm how many explosions will happen when bombs blow!
  45.  
  46. /*
  47. TBA: More realism and features options.
  48. Realism includes;
  49. * Beep sound when you are close to the bomb.
  50. * Bomb object.
  51. It's up to you to use it!
  52. */
  53.  
  54. new iPlanter;
  55. new Timer;
  56. new Float:fBombX;
  57. new Float:fBombY;
  58. new Float:fBombZ;
  59.  
  60. forward Explode();
  61. forward Beep();
  62. forward ResetPlant(playerid);
  63.  
  64.  
  65. public OnPlayerConnect(playerid)
  66. {
  67. SetPVarInt(playerid, "Bomb", 0);
  68. SetPVarInt(playerid, "Plant", 0);
  69. return 1;
  70. }
  71.  
  72. public OnPlayerDisconnect(playerid, reason)
  73. {
  74. SetPVarInt(playerid, "Bomb", 0);
  75. SetPVarInt(playerid, "Plant", 0);
  76. if (iPlanter == playerid) iPlanter = 0;
  77. return 1;
  78. }
  79.  
  80. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  81. {
  82. if (dialogid == 1)
  83. {
  84. if (response)
  85. {
  86. SetPVarInt(playerid, "Bomb", 1);
  87. GivePlayerMoney(playerid, -Cost);
  88. ShowPlayerDialog(playerid, 7236, 0, "{CC0000}Success", "{FFFFFF}You have bought a bomb", "Close", "");
  89. return 1;
  90. }
  91. }
  92. return 1;
  93. }
  94.  
  95. public ResetPlant(playerid)
  96. {
  97. return SetPVarInt(playerid, "Plant", 0);
  98. }
  99.  
  100. public Beep()
  101. {
  102. for(new I = 0; I < MAX_PLAYERS; I++)
  103. {
  104. if (IsPlayerInRangeOfPoint(I, 15.0, fBombX, fBombY, fBombZ))
  105. {
  106. PlayerPlaySound(I, 1056, 0.0, 0.0, 0.0);
  107. }
  108. }
  109. return 1;
  110. }
  111.  
  112. public Explode()
  113. {
  114. new Bombs;
  115. do
  116. {
  117. Bombs += 1;
  118. CreateExplosion(fBombX, fBombY, fBombZ, 2, 20);
  119. }
  120. while (Bombs != Explosions);
  121. SendClientMessage(iPlanter, -1, "{FFFFFF}Your bomb has {CC0000}exploded sucessfully");
  122. #if Realism == 1
  123. {
  124. KillTimer(Timer);
  125. }
  126. #endif
  127. return 1;
  128. }
  129.  
  130. stock IsAtBombShop(playerid)
  131. {
  132. if (IsPlayerInRangeOfPoint(playerid, 3, ShopX, ShopY, ShopZ)
  133. && (GetPlayerVirtualWorld(playerid) == ShopV)) return 1;
  134. return 0;
  135. }
  136.  
  137. stock CanAffordBomb(playerid)
  138. {
  139. if (GetPlayerMoney(playerid) > Cost) return 1;
  140. return 0;
  141. }
  142.  
  143. stock RecentlyPlanted(playerid)
  144. {
  145. if (GetPVarInt(playerid, "Plant") == 1) return 1;
  146. return 0;
  147. }
  148.  
  149. CMD:buybomb(playerid, params[])
  150. {
  151. new szString[124];
  152. format(szString, 124, "{FFFFFF}Are you sure you want to buy a bomb for {00CC00}%d$?", Cost);
  153. if (!IsAtBombShop(playerid))
  154. {
  155. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not at the {CC0000}bomb shop");
  156. return 1;
  157. }
  158. if (!CanAffordBomb(playerid))
  159. {
  160. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You can't afford this {CC0000}bomb");
  161. return 1;
  162. }
  163. if (GetPVarInt(playerid, "Bomb") == 1)
  164. {
  165. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You already have a {CC0000}bomb");
  166. return 1;
  167. }
  168. return ShowPlayerDialog(playerid, 6326, 0, "{CC0000}Confirmation", szString, "Yes", "No");
  169. }
  170.  
  171. CMD:givebomb(playerid, params[])
  172. {
  173. new szString[124], szDestName[24], szpName[24], iDest, Float:fDestX, Float:fDestY, Float:fDestZ;
  174. if (sscanf(params, "u", iDest))
  175. {
  176. SendClientMessage(playerid, -1, "{CC0000}Usage:{FFFFFF} /givebomb [playerid/PartOfName]");
  177. return 1;
  178. }
  179. GetPlayerPos(iDest, fDestX, fDestY, fDestZ);
  180. if (!IsPlayerInRangeOfPoint(playerid, 3, fDestX, fDestY, fDestZ))
  181. {
  182. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not {CC0000}near the player!");
  183. return 1;
  184. }
  185. if (GetPVarInt(iDest, "Bomb") == 1)
  186. {
  187. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player already has {CC0000}a bomb!");
  188. return 1;
  189. }
  190. if (iDest == INVALID_PLAYER_ID)
  191. {
  192. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player is {CC0000}not online!");
  193. return 1;
  194. }
  195. GetPlayerName(iDest, szDestName, 24);
  196. GetPlayerName(playerid, szpName, 24);
  197. format(szString, 124, "{FFFFFF}You've given a bomb to {CC0000}%s(%d)", szDestName, iDest);
  198. SendClientMessage(playerid, -1, szString);
  199. format(szString, 124, "{FFFFFF}You've recived a bomb from {CC0000}%s(%d)", szpName, playerid);
  200. SendClientMessage(iDest, -1, szString);
  201. SetPVarInt(playerid, "Bomb", 0);
  202. SetPVarInt(iDest, "Bomb", 1);
  203. return 1;
  204. }
  205.  
  206. CMD:plantbomb(playerid, params[])
  207. {
  208. if (GetPVarInt(playerid, "Bomb") == 0)
  209. {
  210. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You do not have a {CC0000}bomb!");
  211. return 1;
  212. }
  213. if (GetPVarInt(playerid, "Plant") == 1)
  214. {
  215. SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You need to wait before {CC0000}planting again!");
  216. return 1;
  217. }
  218. new Float:fpX, Float:fpY, Float:fpZ, szString[124];
  219. GetPlayerPos(playerid, fpX, fpY, fpZ);
  220. fBombX = fpX;
  221. fBombY = fpY;
  222. fBombZ = fpZ-1.5;
  223. SetTimer("Explode", BombTimer * 1000, 0);
  224. SetTimerEx("ResetPlant", 20 * 60 * 1000, false, "i", playerid);
  225. SetPVarInt(playerid, "Bomb", 0);
  226. SetPVarInt(playerid, "Plant", 1);
  227. ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); // Place Bomb
  228. iPlanter = playerid;
  229. format(szString, 124, "{FFFFFF}You have planted a bomb in your location and it will explode in {CC0000}%d seconds", BombTimer);
  230. SendClientMessage(playerid, -1, szString);
  231. #if Realism == 1
  232. {
  233. CreateObject(1252, fpX, fpY, fpZ-1.4, 0, 0, 0); // 'fpZ-1.4' may be inaccurate. Be aware.
  234. Timer = SetTimer("Beep", 4000, 1);
  235. }
  236. #endif
  237. return 1;
  238. }
Advertisement
Add Comment
Please, Sign In to add comment