daily pastebin goal
28%
SHARE
TWEET

xPlosions by inv3rse (v1.0)

a guest Jul 4th, 2014 331 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3.        -------------------                    >= xPlosions =<                     -------------------
  4.        ===================                     (Version: 1.0)                     ===================
  5.        -------------------        => Scripted by "inv3rse" a.k.a "Inverse".       -------------------
  6.                          
  7.                                                                                                            */
  8.  
  9.                                                                                            
  10.                                                                                            
  11. #define FILTERSCRIPT
  12.  
  13. #include <a_samp>
  14. #include <zcmd>
  15. #include <YSI\y_ini>
  16.  
  17.  
  18. #define SMALL_BOMB_PRICE 0
  19. #define NORMAL_BOMB_PRICE 0
  20. #define HEAVY_BOMB_PRICE 0
  21. #define xPlosivesPath "xPlosives/%s.ini"
  22.  
  23. #define DIALOG_BUYBOMB 98742
  24. #define DIALOG_PLANTBOMB 98743
  25. #define DIALOG_MSGBOMB 98744
  26.  
  27. #define SMALL_BOMB 1
  28. #define NORMAL_BOMB 2
  29. #define HEAVY_BOMB 3
  30.  
  31. #define ShopX 0.0
  32. #define ShopY 0.0
  33. #define ShopZ 0.0
  34.  
  35. new NOofSmallBombs[MAX_PLAYERS];
  36. new NOofNormalBombs[MAX_PLAYERS];
  37. new NOofHeavyBombs[MAX_PLAYERS];
  38. new PlayerHasPlantedBomb[MAX_PLAYERS];
  39. new BombID[MAX_PLAYERS];
  40.  
  41. new Float:BombX[MAX_PLAYERS];
  42. new Float:BombY[MAX_PLAYERS];
  43. new Float:BombZ[MAX_PLAYERS];
  44. new BombTYPE[MAX_PLAYERS];
  45.  
  46.  
  47. // ------------------------ Custom Functions ------------------------------------------ //
  48.  
  49.  
  50. PlantBombForPlayer(playerid, BOMBTYPE)
  51. {
  52.     new Float:X, Float:Y, Float:Z, ObjID;
  53.     switch(BOMBTYPE)
  54.     {
  55.         case SMALL_BOMB: ObjID = 3798;
  56.         case NORMAL_BOMB: ObjID = 964;
  57.         case HEAVY_BOMB: ObjID = 2040;
  58.     }
  59.     GetPlayerPos(playerid, X, Y, Z);
  60.     BombX[playerid] = X + 2;
  61.     BombY[playerid] = Y + 2;
  62.     BombZ[playerid] = Z;
  63.     BombTYPE[playerid] = BOMBTYPE;
  64.     BombID[playerid] = CreateObject(ObjID, BombX[playerid], BombY[playerid], BombZ[playerid], 0.0, 0.0, 0.0, 400.0);
  65.     PlayerHasPlantedBomb[playerid] = true;
  66.     return true;
  67. }
  68.  
  69. forward loadbombs_user(playerid, name[], value[]);
  70. public loadbombs_user(playerid, name[], value[])
  71. {
  72.     INI_Int("NOofSmallBombs", NOofSmallBombs[playerid]);
  73.     INI_Int("NOofNormalBombs", NOofNormalBombs[playerid]);
  74.     INI_Int("NOofHeavyBombs", NOofHeavyBombs[playerid]);
  75.     return 1;
  76. }
  77.  
  78. LoadBombs(playerid)
  79. {
  80.         new name[MAX_PLAYER_NAME + 1], fname[36];
  81.     GetPlayerName(playerid, name, sizeof(name));
  82.     format(fname, sizeof(fname), xPlosivesPath, name);
  83.  
  84.     switch(fexist(fname))
  85.     {
  86.         case true:
  87.         {
  88.                 INI_ParseFile(fname, "loadbombs_%s", .bExtra = true, .extra = playerid);
  89.         }
  90.  
  91.         case false:
  92.         {
  93.             new INI:file = INI_Open(fname);
  94.             INI_WriteInt(file, "NOofSmallBombs", 0);
  95.                         INI_WriteInt(file, "NOofNormalBombs", 0);
  96.                 INI_WriteInt(file, "NOofHeavyBombs", 0);
  97.                 INI_Close(file);
  98.         }
  99.     }
  100.     return true;
  101. }
  102.  
  103. SaveBombs(playerid)
  104. {
  105.     new name[MAX_PLAYER_NAME + 1], fname[36], INI:file;
  106.     GetPlayerName(playerid, name, sizeof(name));
  107.     format(fname, sizeof(fname), xPlosivesPath, name);
  108.     file = INI_Open(fname);
  109.     INI_WriteInt(file, "NOofSmallBombs", NOofSmallBombs[playerid]);
  110.     INI_WriteInt(file, "NOofNormalBombs", NOofNormalBombs[playerid]);
  111.     INI_WriteInt(file, "NOofHeavyBombs", NOofHeavyBombs[playerid]);
  112.     INI_Close(file);
  113.     return true;
  114. }
  115.  
  116. // --------------------------- Callbacks ---------------------------------------- //
  117.  
  118.  
  119. public OnFilterScriptInit()
  120. {
  121.     print("\n--------------------------------------");
  122.     print("    |xPlosives by inv3rse loaded!|     ");
  123.     print("--------------------------------------\n");
  124.     return 1;
  125. }
  126.  
  127. public OnPlayerConnect(playerid)
  128. {
  129.     LoadBombs(playerid);
  130.     return true;
  131. }
  132.  
  133. public OnPlayerDisconnect(playerid, reason)
  134. {
  135.     SaveBombs(playerid);
  136.     PlayerHasPlantedBomb[playerid] = false;
  137.     return true;
  138. }
  139.  
  140. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  141. {
  142.     switch(dialogid)
  143.     {
  144.         case DIALOG_PLANTBOMB:
  145.         {
  146.             if(PlayerHasPlantedBomb[playerid]) return ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bombs Inventory", "\n{FFFFFF}You have already planted a bomb.\nUse {FFA500}/detonate {FFFFFF}to detonate it first.\n", "", "Cancel");
  147.  
  148.             switch(listitem)
  149.             {
  150.                 case 0:
  151.                 {
  152.                     if(NOofSmallBombs[playerid] > 0)
  153.                     {
  154.                         NOofSmallBombs[playerid] -= 1;
  155.                         PlantBombForPlayer(playerid, SMALL_BOMB);
  156.                     }
  157.  
  158.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bombs Inventory", "\n{FFFFFF}You have no {FFFF00}Small Bombs.\n{FFFFFF}Select {FFA500}Buy to buy one.\n", "{FFA500}Buy!", "Cancel");
  159.                 }
  160.  
  161.                 case 1:
  162.                 {
  163.                     if(NOofNormalBombs[playerid] > 0)
  164.                     {
  165.                         NOofNormalBombs[playerid] -= 1;
  166.                         PlantBombForPlayer(playerid, NORMAL_BOMB);
  167.                     }
  168.  
  169.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bombs Inventory", "\n{FFFFFF}You have no {008000}Normal Bombs.\n{FFFFFF}Select {FFA500}Buy to buy one.\n", "{FFA500}Buy!", "Cancel");
  170.                 }
  171.  
  172.                 case 2:
  173.                 {
  174.                     if(NOofHeavyBombs[playerid] > 0)
  175.                     {
  176.                         NOofHeavyBombs[playerid] -= 1;
  177.                         PlantBombForPlayer(playerid, HEAVY_BOMB);
  178.                     }
  179.  
  180.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bombs Inventory", "\n{FFFFFF}You have no {42C0FB}Heavy Bombs.\n{FFFFFF}Select {FFA500}Buy to buy one.\n", "{FFA500}Buy!", "Cancel");
  181.                 }
  182.             }
  183.                 return true;
  184.         }
  185.  
  186.         case DIALOG_BUYBOMB:
  187.         {
  188.             switch(listitem)
  189.             {
  190.                 case 0:
  191.                 {
  192.                     if(GetPlayerMoney(playerid) >= SMALL_BOMB_PRICE)
  193.                     {
  194.                         GivePlayerMoney(playerid, - (SMALL_BOMB_PRICE));
  195.                         NOofSmallBombs[playerid] += 1;
  196.                         PlayerPlaySound(playerid, 4203, 0, 0, 0);
  197.                         ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You have successfully purchased a {FFFF00}Small Bomb.\n\n{FFA500}COMMANDS\n\n\n{FF0000}/plantbomb - {FFFFFF}To plant the bomb.\n{FF0000}/detonate - {FFFFFF}To explode the bomb.\n", "{FFA500}Back!", "Cancel");
  198.                     }
  199.  
  200.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You don't have enough money to purchase a {FFFF00}Small Bomb.\n", "{FFA500}Back!", "Cancel");
  201.                 }
  202.  
  203.                 case 1:
  204.                 {
  205.                     if(GetPlayerMoney(playerid) >= NORMAL_BOMB_PRICE)
  206.                     {
  207.                         GivePlayerMoney(playerid, - (NORMAL_BOMB_PRICE));
  208.                         NOofNormalBombs[playerid] += 1;
  209.                         PlayerPlaySound(playerid, 4203, 0, 0, 0);
  210.                         ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You have successfully purchased a {008000}Normal Bomb.\n\n{FFA500}COMMANDS\n\n\n{FF0000}/plantbomb - {FFFFFF}To plant the bomb.\n{FF0000}/detonate - {FFFFFF}To explode the bomb.\n", "{FFA500}Back!", "Cancel");
  211.                     }
  212.  
  213.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You don't have enough money to purchase a {008000}Normal Bomb.\n", "{FFA500}Back!", "Cancel");
  214.                 }
  215.  
  216.                 case 2:
  217.                 {
  218.                     if(GetPlayerMoney(playerid) >= HEAVY_BOMB_PRICE)
  219.                     {
  220.                         GivePlayerMoney(playerid, - (HEAVY_BOMB_PRICE));
  221.                         NOofHeavyBombs[playerid] += 1;
  222.                         PlayerPlaySound(playerid, 4203, 0, 0, 0);
  223.                         ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You have successfully purchased a {42C0FB}Heavy Bomb.\n\n{FFA500}COMMANDS\n\n\n{FF0000}/plantbomb - {FFFFFF}To plant the bomb.\n{FF0000}/detonate - {FFFFFF}To explode the bomb.\n", "{FFA500}Back!", "Cancel");
  224.                     }
  225.  
  226.                     else ShowPlayerDialog(playerid, DIALOG_MSGBOMB, DIALOG_STYLE_MSGBOX, "{FFA500}Bomb Shop", "\n{FFFFFF}You don't have enough money to purchase a {42C0FB}Heavy Bomb.\n", "{FFA500}Back!", "Cancel");
  227.                 }
  228.             }
  229.             return true;
  230.         }
  231.  
  232.         case DIALOG_MSGBOMB:
  233.         {
  234.             if(response)
  235.             {
  236.                 new str[200];
  237.                         format(str, sizeof(str), "{FFFF00}Small Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})\n{008000}Normal Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})\n{42C0FB}Heavy Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})", SMALL_BOMB_PRICE, NORMAL_BOMB_PRICE, HEAVY_BOMB_PRICE);
  238.                                 ShowPlayerDialog(playerid, DIALOG_BUYBOMB, DIALOG_STYLE_LIST, "{FFA500}Bomb Shop", str, "{FFA500}Buy!", "{FFFFFF}Cancel");
  239.                         PlayerPlaySound(playerid, 4203, 0, 0, 0);
  240.             }
  241.             return true;
  242.         }
  243.     }
  244.     return false;
  245. }
  246.  
  247.  
  248. // ------------------------- Commands -------------------------------------------- //
  249.  
  250.  
  251. CMD:plantbomb(playerid, params[])
  252. {
  253.     new str[200];
  254.     format(str, sizeof(str), "{FFFF00}Small Bomb {FFFFFF}(Quantity: {008080}%i{FFFFFF})\n{008000}Normal Bomb {FFFFFF}(Quantity: {008080}%i{FFFFFF})\n{42C0FB}Heavy Bomb {FFFFFF}(Quantity: {008080}%i{FFFFFF})", NOofSmallBombs[playerid], NOofNormalBombs[playerid], NOofHeavyBombs[playerid]);
  255.     ShowPlayerDialog(playerid, DIALOG_PLANTBOMB, DIALOG_STYLE_LIST, "{FFA500}Bombs Inventory", str, "{FFA500}Plant!", "{FFFFFF}Cancel");
  256.     PlayerPlaySound(playerid, 4203, 0, 0, 0);
  257.     return true;
  258. }
  259.  
  260. CMD:detonate(playerid, params[])
  261. {
  262.     if(!PlayerHasPlantedBomb[playerid]) return SendClientMessage(playerid, -1, "{FFA500}ERROR: {FFFFFF}You haven't planted any bomb!");
  263.     switch(BombTYPE[playerid])
  264.     {
  265.         case SMALL_BOMB: CreateExplosion(BombX[playerid], BombY[playerid], BombZ[playerid], 11, 10.0);
  266.         case NORMAL_BOMB: CreateExplosion(BombX[playerid], BombY[playerid], BombZ[playerid], 9, 20.0);
  267.         case HEAVY_BOMB: CreateExplosion(BombX[playerid], BombY[playerid], BombZ[playerid], 2, 30.0);
  268.     }
  269.     DestroyObject(BombID[playerid]);
  270.     GameTextForPlayer(playerid, "~r~~h~Bomb detonated!", 3000, 3);
  271.     PlayerPlaySound(playerid, 4203, 0, 0, 0);
  272.     PlayerHasPlantedBomb[playerid] = false;
  273.     return true;
  274. }
  275.  
  276. CMD:buybomb(playerid, params[])
  277. {
  278.     if(!IsPlayerInRangeOfPoint(playerid, 3.0, ShopX, ShopY, ShopZ)) return SendClientMessage(playerid, -1, "{FFA500}ERROR: {FFFFFF}You are not near a bomb shop!");
  279.     new str[200];
  280.     format(str, sizeof(str), "{FFFF00}Small Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})\n{008000}Normal Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})\n{42C0FB}Heavy Bomb {FFFFFF}(Price: {008000}$%i{FFFFFF})", SMALL_BOMB_PRICE, NORMAL_BOMB_PRICE, HEAVY_BOMB_PRICE);
  281.     ShowPlayerDialog(playerid, DIALOG_BUYBOMB, DIALOG_STYLE_LIST, "{FFA500}Bomb Shop", str, "{FFA500}Buy!", "{FFFFFF}Cancel");
  282.     PlayerPlaySound(playerid, 4203, 0, 0, 0);
  283.     return true;
  284. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top