Guest User

Untitled

a guest
Apr 6th, 2011
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.93 KB | None | 0 0
  1. /* Bomb System for SA:MP 0.3c
  2. // Made by Admantis
  3. // You may not re-release or sell this under any circumstance.
  4. */
  5.  
  6. #include    <a_samp>
  7. #include    <zcmd>
  8. #include    <sscanf2>
  9.  
  10. #define     ShopX       0.000
  11. #define     ShopY       0.000
  12. #define     ShopZ       0.000
  13. #define     ShopV       0
  14. #define     Cost        25000
  15. #define     BombTimer   1
  16.  
  17. new iPlanter;
  18. new Float:fBombX;
  19. new Float:fBombY;
  20. new Float:fBombZ;
  21.  
  22. forward Explode();
  23. forward ResetPlant(playerid);
  24.  
  25.  
  26. public OnPlayerConnect(playerid)
  27. {
  28.     SetPVarInt(playerid, "Bomb", 0);
  29.     SetPVarInt(playerid, "Plant", 0);
  30.     return 1;
  31. }
  32.  
  33. public OnPlayerDisconnect(playerid, reason)
  34. {
  35.     SetPVarInt(playerid, "Bomb", 0);
  36.     SetPVarInt(playerid, "Plant", 0);
  37.     if (iPlanter == playerid) iPlanter = 0;
  38.     return 1;
  39. }
  40.  
  41. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  42. {
  43.     if (dialogid == 1)
  44.     {
  45.         if (response)
  46.         {
  47.             SetPVarInt(playerid, "Bomb", 1);
  48.             GivePlayerMoney(playerid, -Cost);
  49.             ShowPlayerDialog(playerid, 0, 0, "{CC0000}Success", "{FFFFFF}You have bought a bomb", "Close", "");
  50.             return 1;
  51.         }
  52.     }
  53.     return 1;
  54. }
  55.  
  56. public ResetPlant(playerid)
  57. {
  58.     return SetPVarInt(playerid, "Plant", 0);
  59. }
  60.  
  61. public Explode()
  62. {
  63.     CreateExplosion(fBombX, fBombY, fBombZ, 9, 30.0);
  64.     CreateExplosion(fBombX, fBombY, fBombZ, 0, 30.0);
  65.     CreateExplosion(fBombX-1, fBombY-1, fBombZ-1, 0, 30.0);
  66.     CreateExplosion(fBombX+1, fBombY+1, fBombZ+1, 0, 30.0);
  67.     CreateExplosion(fBombX, fBombY, fBombZ, 13, 30.0);
  68.     SendClientMessage(iPlanter, -1, "{FFFFFF}Your bomb has {CC0000}exploded sucessfully");
  69.     return 1;
  70. }
  71.    
  72. stock IsAtBombShop(playerid)
  73. {
  74.     if (IsPlayerInRangeOfPoint(playerid, 3, ShopX, ShopY, ShopZ)
  75.     && (GetPlayerVirtualWorld(playerid) == ShopV)) return 1;
  76.     return 0;
  77. }
  78.  
  79. stock CanAffordBomb(playerid)
  80. {
  81.     if (GetPlayerMoney(playerid) > Cost) return 1;
  82.     return 0;
  83. }
  84.  
  85. stock RecentlyPlanted(playerid)
  86. {
  87.     if (GetPVarInt(playerid, "Plant") == 1) return 1;
  88.     return 0;
  89. }
  90.  
  91. CMD:buybomb(playerid, params[])
  92. {
  93.     new szString[128];
  94.     format(szString, 128, "{FFFFFF}Are you sure you want to buy a bomb for {00CC00}%d$?", Cost);
  95.     if (!IsAtBombShop(playerid))
  96.     {
  97.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not at the {CC0000}bomb shop");
  98.         return 1;
  99.     }
  100.     if (!CanAffordBomb(playerid))
  101.     {
  102.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You can't afford this {CC0000}bomb");
  103.         return 1;
  104.     }
  105.     if (GetPVarInt(playerid, "Bomb") == 1)
  106.     {
  107.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You already have a {CC0000}bomb");
  108.         return 1;
  109.     }
  110.     return ShowPlayerDialog(playerid, 1, 0, "{CC0000}Confirmation", szString, "Yes", "No");
  111. }
  112.  
  113. CMD:givebomb(playerid, params[])
  114. {
  115.     new szString[128], szDestName[28], szpName[28], iDest, Float:fDestX, Float:fDestY, Float:fDestZ;
  116.     if (sscanf(params, "u", iDest))
  117.     {
  118.         SendClientMessage(playerid, -1, "{CC0000}Usage:{FFFFFF} /givebomb [playerid/PartOfName]");
  119.         return 1;
  120.     }
  121.     GetPlayerPos(iDest, fDestX, fDestY, fDestZ);
  122.     if (!IsPlayerInRangeOfPoint(playerid, 3, fDestX, fDestY, fDestZ))
  123.     {
  124.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not {CC0000}near the player!");
  125.         return 1;
  126.     }
  127.     if (GetPVarInt(iDest, "Bomb") == 1)
  128.     {
  129.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player already has {CC0000}a bomb!");
  130.         return 1;
  131.     }
  132.     if (iDest == INVALID_PLAYER_ID)
  133.     {
  134.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player is {CC0000}not online!");
  135.         return 1;
  136.     }
  137.     GetPlayerName(iDest, szDestName, 28);
  138.     GetPlayerName(playerid, szpName, 28);
  139.     format(szString, 128, "{FFFFFF}You've given a bomb to {CC0000}%s(%d)", szDestName, iDest);
  140.     SendClientMessage(playerid, -1, szString);
  141.     format(szString, 128, "{FFFFFF}You've recived a bomb from {CC0000}%s(%d)", szpName, playerid);
  142.     SendClientMessage(iDest, -1, szString);
  143.     SetPVarInt(playerid, "Bomb", 0);
  144.     SetPVarInt(iDest, "Bomb", 1);
  145.     return 1;
  146. }
  147.  
  148. CMD:plantbomb(playerid, params[])
  149. {
  150.     if (GetPVarInt(playerid, "Bomb") == 0)
  151.     {
  152.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You do not have a {CC0000}bomb!");
  153.         return 1;
  154.     }
  155.     if (GetPVarInt(playerid, "Plant") == 1)
  156.     {
  157.         SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You need to wait before {CC0000}planting again!");
  158.         return 1;
  159.     }
  160.     new Float:fpX, Float:fpY, Float:fpZ, szString[128];
  161.     GetPlayerPos(playerid, fpX, fpY, fpZ);
  162.     fBombX = fpX;
  163.     fBombY = fpY;
  164.     fBombZ = fpZ-1.5;
  165.     SetTimer("Explode", BombTimer * 60 * 1000, 0);
  166.     SetTimerEx("ResetPlant", 30 * 60 *1000, false, "i", playerid);
  167.     SetPVarInt(playerid, "Bomb", 0);
  168.     SetPVarInt(playerid, "Plant", 1);
  169.     ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); // Place Bomb
  170.     iPlanter = playerid;
  171.     format(szString, 128, "{FFFFFF}You have planted a bomb in your location and it will explode in {CC0000}%d minutes", BombTimer);
  172.     SendClientMessage(playerid, -1, szString);
  173.     return 1;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment