OtaconEvil

[FS] Sistema de Bombas By OTACON [ES]

Sep 10th, 2014
643
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     * ## LEASE ATENTAMENTE PARA NO CONVERTIRSE EN LAMMER!!.: :D ##
  3.     *
  4.     * Estè Simple FILTERSCRIPT esta hecho especialmente para www.forum.sa-mp.com
  5.     * NO Publicar estè FILTERSCRIPT en Otros foros de SA-MP y hacerse pasar por el creador del CODE.
  6.     *
  7.     * Codigo Creado Por OTACON
  8.     *
  9.     * CREDITOS:
  10.     *     OTACON: Realizacion y Idea de creacion del code.
  11.     *     TÙ: Modificacion libremente respetando lo mencionado ;).
  12.     *
  13.     *    NOTA: Menos Creditos para los que me los critican.. JO'PUTAS! :D xD ;)
  14.     *
  15.     *                Prohibido TOTALMENTE el Robo de Créditos o la
  16.     *                  Publicación de este FILTERSCRIPT sin Mi Permiso.
  17. */
  18. /*
  19.     * ## READ CAREFULLY TO AVOID BECOMING LAMMER!.: :D ##
  20.     *
  21.     * This simple FILTERSCRIPT is made especially for www.forum.sa-mp.com
  22.     * DO NOT Post the FILTERSCRIPT in Other SAMP forums and impersonating the creator of the CODE.
  23.     *
  24.     * Code Created By OTACON
  25.     *
  26.     * CREDITS:
  27.     *     OTACON: Idea Making and code creation.
  28.     *     YOUR: Modification freely respecting the above ;).
  29.     *
  30.     *    NOTE: Less Credits for those who criticize me.. JO'PUTAS! :D xD ;)
  31.     *
  32.     *                        FULLY spaces Theft Credit or
  33.     *                 Publication of this FILTERSCRIPT without my permission.
  34. */
  35.  
  36. #include <a_samp>
  37. #include <zcmd>
  38. #include <player_progressbar>
  39. #define pressed(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  40. #define released(%0) (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  41.  
  42. #define COLOR_BAR_1 0xD9D9D9FF //Blanco
  43. #define COLOR_BAR_2 0xB71700FF //Rojo
  44. #define MAX_BOMBA (5)
  45. #define ID_BOMBA (1654)
  46. #define TIMER_BOOM (30)
  47. #define COSTO_BOMBA (1500)
  48. enum BombInfo {
  49.     bool:BombasActivas,
  50.     CantidadBombas,
  51.     Float:PosBombaX,
  52.     Float:PosBombaY,
  53.     Float:PosBombaZ,
  54.     Float:PosBombaA,
  55.     MatarColocando,
  56.     MatarExplotando,
  57.     ContandoBoom,
  58.     ObjetoBomba, };
  59. new Bombas[MAX_PLAYERS][BombInfo];
  60. new PlayerBar:BarBombas[MAX_PLAYERS][2];
  61. new PlayerText:TextBombas[MAX_PLAYERS][3];
  62.  
  63. public OnPlayerConnect(playerid) {
  64.     new data[128];
  65.     TextBombas[playerid][0]=CreatePlayerTextDraw(playerid,413.000000, 104.000000, "_");
  66.     PlayerTextDrawBackgroundColor(playerid,TextBombas[playerid][0], 255);
  67.     PlayerTextDrawFont(playerid,TextBombas[playerid][0], 1);
  68.     PlayerTextDrawLetterSize(playerid,TextBombas[playerid][0], 0.270000, 1.300000);
  69.     PlayerTextDrawColor(playerid,TextBombas[playerid][0], -1);
  70.     PlayerTextDrawSetOutline(playerid,TextBombas[playerid][0], 1);
  71.     PlayerTextDrawSetProportional(playerid,TextBombas[playerid][0], 1);
  72.     PlayerTextDrawSetSelectable(playerid,TextBombas[playerid][0], 0);
  73.  
  74.     TextBombas[playerid][1]=CreatePlayerTextDraw(playerid,322.000000, 50.000000, "_");
  75.     PlayerTextDrawAlignment(playerid,TextBombas[playerid][1], 2);
  76.     PlayerTextDrawBackgroundColor(playerid,TextBombas[playerid][1], 255);
  77.     PlayerTextDrawFont(playerid,TextBombas[playerid][1], 2);
  78.     PlayerTextDrawLetterSize(playerid,TextBombas[playerid][1], 0.670000, 3.300000);
  79.     PlayerTextDrawColor(playerid,TextBombas[playerid][1], -1);
  80.     PlayerTextDrawSetOutline(playerid,TextBombas[playerid][1], 1);
  81.     PlayerTextDrawSetProportional(playerid,TextBombas[playerid][1], 1);
  82.     PlayerTextDrawUseBox(playerid,TextBombas[playerid][1], 1);
  83.     PlayerTextDrawBoxColor(playerid,TextBombas[playerid][1], 0x0000155);
  84.     PlayerTextDrawTextSize(playerid,TextBombas[playerid][1], 80.000000, 98.000000);
  85.     PlayerTextDrawSetSelectable(playerid,TextBombas[playerid][1], 0);
  86.  
  87.     TextBombas[playerid][2]=CreatePlayerTextDraw(playerid,512.000000, 136.000000, "_");
  88.     PlayerTextDrawAlignment(playerid,TextBombas[playerid][2], 2);
  89.     PlayerTextDrawBackgroundColor(playerid,TextBombas[playerid][2], 255);
  90.     PlayerTextDrawFont(playerid,TextBombas[playerid][2], 2);
  91.     PlayerTextDrawLetterSize(playerid,TextBombas[playerid][2], 0.220000, 1.500000);
  92.     PlayerTextDrawColor(playerid,TextBombas[playerid][2], -1);
  93.     PlayerTextDrawSetOutline(playerid,TextBombas[playerid][2], 1);
  94.     PlayerTextDrawSetProportional(playerid,TextBombas[playerid][2], 1);
  95.     PlayerTextDrawSetSelectable(playerid,TextBombas[playerid][2], 0);
  96.     format(data,sizeof(data), "~w~Cantidad de Bombas: ~g~%02d/%02d", Bombas[playerid][CantidadBombas], MAX_BOMBA);
  97.     PlayerTextDrawSetString(playerid,TextBombas[playerid][2], data);
  98.        
  99.     BarBombas[playerid][0]=CreatePlayerProgressBar(playerid, 503.000000, 110.000000, 55.500000, 3.200000, COLOR_BAR_1, 100.0);
  100.     SetPlayerProgressBarMaxValue(playerid, BarBombas[playerid][0], 100.0);
  101.     SetPlayerProgressBarValue(playerid, BarBombas[playerid][0], 0);
  102.     BarBombas[playerid][1]=CreatePlayerProgressBar(playerid, 503.000000, 122.000000, 101.500000, 3.199999, COLOR_BAR_2, 100.0);
  103.     SetPlayerProgressBarMaxValue(playerid, BarBombas[playerid][1], Float:float(TIMER_BOOM));
  104.     SetPlayerProgressBarValue(playerid, BarBombas[playerid][1], Float:float(TIMER_BOOM));
  105.     Bombas[playerid][BombasActivas]=false;
  106.     Bombas[playerid][ContandoBoom]=0;
  107.     return true;
  108. }
  109. public OnPlayerDisconnect(playerid, reason) {
  110.     HidePlayerProgressBar(playerid, BarBombas[playerid][0]);
  111.     HidePlayerProgressBar(playerid, BarBombas[playerid][1]);
  112.     PlayerTextDrawHide(playerid, TextBombas[playerid][0]);
  113.     PlayerTextDrawHide(playerid, TextBombas[playerid][1]);
  114.     PlayerTextDrawHide(playerid, TextBombas[playerid][2]);
  115.     KillTimer(Bombas[playerid][MatarColocando]);
  116.     KillTimer(Bombas[playerid][MatarExplotando]);
  117.     Bombas[playerid][BombasActivas]=false;
  118.     Bombas[playerid][ContandoBoom]=0;
  119.     return true;
  120. }
  121. public OnPlayerDeath(playerid, killerid, reason) {
  122.     HidePlayerProgressBar(playerid, BarBombas[playerid][0]);
  123.     HidePlayerProgressBar(playerid, BarBombas[playerid][1]);
  124.     PlayerTextDrawHide(playerid, TextBombas[playerid][0]);
  125.     PlayerTextDrawHide(playerid, TextBombas[playerid][1]);
  126.     PlayerTextDrawHide(playerid, TextBombas[playerid][2]);
  127.     KillTimer(Bombas[playerid][MatarColocando]);
  128.     KillTimer(Bombas[playerid][MatarExplotando]);
  129.     Bombas[playerid][BombasActivas]=false;
  130.     Bombas[playerid][ContandoBoom]=0;
  131.     Bombas[playerid][CantidadBombas]=0;
  132.     DestroyObject(Bombas[playerid][ObjetoBomba]);
  133.     return true;
  134. }
  135. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  136.     if(pressed(KEY_HANDBRAKE)) {
  137.         switch(Bombas[playerid][BombasActivas]) {
  138.             case true: {
  139.                 if(Bombas[playerid][CantidadBombas]<=0) return SendClientMessage(playerid, -1,"  [ ! ] No tienes bombas para colocar!.");
  140.                 ShowPlayerProgressBar(playerid, BarBombas[playerid][0]);
  141.                 PlayerTextDrawShow(playerid, TextBombas[playerid][0]);
  142.                 PlayerTextDrawSetString(playerid,TextBombas[playerid][0], "~w~Colocando Bomba:");
  143.                 ApplyAnimation(playerid,"BOMBER","BOM_Plant_Crouch_In",4.1,0,1,1,1,1);
  144.                 Bombas[playerid][MatarColocando]=SetTimerEx("ColocandoBomba", 150, true, "d", playerid);
  145.                 GameTextForPlayer(playerid, "~n~~n~~n~~g~Colocando Bomba...", 4000, 3);
  146.                 GetPlayerPos(playerid, Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ]);
  147.                 GetPlayerFacingAngle(playerid,Bombas[playerid][PosBombaA]);
  148.                 DestroyObject(Bombas[playerid][ObjetoBomba]);
  149.                 Bombas[playerid][PosBombaX] = Bombas[playerid][PosBombaX] + (0.6 * floatsin(-Bombas[playerid][PosBombaA], degrees));
  150.                 Bombas[playerid][PosBombaY] = Bombas[playerid][PosBombaY] + (0.6 * floatcos(-Bombas[playerid][PosBombaA], degrees));
  151.                 Bombas[playerid][ObjetoBomba]=CreateObject(ID_BOMBA, Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ]-0.8, 0.0, 0.0, Bombas[playerid][PosBombaA]);
  152.             }
  153.         }
  154.     }
  155.     if(released(KEY_HANDBRAKE)) {
  156.         switch(Bombas[playerid][BombasActivas]) {
  157.             case true: {
  158.                 HidePlayerProgressBar(playerid, BarBombas[playerid][0]);
  159.                 PlayerTextDrawHide(playerid, TextBombas[playerid][0]);
  160.                 ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,0,0,0,0,0);
  161.                 KillTimer(Bombas[playerid][MatarExplotando]);
  162.                 KillTimer(Bombas[playerid][MatarColocando]);
  163.                 Bombas[playerid][ContandoBoom]=0;
  164.                 DestroyObject(Bombas[playerid][ObjetoBomba]);
  165.             }
  166.         }
  167.     } return true;
  168. }
  169. forward ColocandoBomba(playerid);
  170. public ColocandoBomba(playerid) {
  171.     new data[100];
  172.     Bombas[playerid][ContandoBoom]++;
  173.     SetPlayerProgressBarValue(playerid, BarBombas[playerid][0], Bombas[playerid][ContandoBoom]);
  174.     UpdatePlayerProgressBar(playerid, BarBombas[playerid][0]);
  175.     if(Bombas[playerid][ContandoBoom]>=100) {
  176.         GameTextForPlayer(playerid, "~n~~n~~n~~g~Bomba Colocada!", 4000, 3);
  177.         Bombas[playerid][ContandoBoom]=0;
  178.         Bombas[playerid][ContandoBoom]=TIMER_BOOM;
  179.         Bombas[playerid][CantidadBombas]--;
  180.         format(data,sizeof(data), "~w~Cantidad de Bombas: ~g~%02d/%02d", Bombas[playerid][CantidadBombas], MAX_BOMBA);
  181.         PlayerTextDrawSetString(playerid,TextBombas[playerid][2], data);
  182.         HidePlayerProgressBar(playerid, BarBombas[playerid][0]);
  183.         ShowPlayerProgressBar(playerid, BarBombas[playerid][1]);
  184.         PlayerTextDrawShow(playerid, TextBombas[playerid][1]);
  185.         PlayerTextDrawSetString(playerid,TextBombas[playerid][0], "~w~~n~Tiempo Explosion:");
  186.         ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,0,0,0,0,0);
  187.         KillTimer(Bombas[playerid][MatarColocando]);
  188.         Bombas[playerid][MatarExplotando]=SetTimerEx("ExplotandoBomba", 1*1000, true, "d", playerid);
  189.         Bombas[playerid][BombasActivas]=false;
  190.     } return true;
  191. }
  192. forward ExplotandoBomba(playerid);
  193. public ExplotandoBomba(playerid) {
  194.     new data[20];
  195.     Bombas[playerid][ContandoBoom]--;
  196.     SetPlayerProgressBarValue(playerid, BarBombas[playerid][1], Bombas[playerid][ContandoBoom]);
  197.     UpdatePlayerProgressBar(playerid, BarBombas[playerid][1]);
  198.     format(data,sizeof(data), "~w~00:%02d", Bombas[playerid][ContandoBoom]);
  199.     PlayerTextDrawSetString(playerid,TextBombas[playerid][1], data);
  200.     PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  201.     if(Bombas[playerid][ContandoBoom]<=0) {
  202.         KillTimer(Bombas[playerid][MatarExplotando]);
  203.         KillTimer(Bombas[playerid][MatarColocando]);
  204.         Bombas[playerid][ContandoBoom]=0;
  205.         HidePlayerProgressBar(playerid, BarBombas[playerid][1]);
  206.         PlayerTextDrawHide(playerid, TextBombas[playerid][0]);
  207.         PlayerTextDrawHide(playerid, TextBombas[playerid][1]);
  208.         DestroyObject(Bombas[playerid][ObjetoBomba]);
  209.         GameTextForPlayer(playerid, "~n~~n~~n~~w~BOOM!!.", 4000, 3);
  210.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 1, 30.0);
  211.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 2, 30.0);
  212.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 3, 30.0);
  213.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 4, 30.0);
  214.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 5, 30.0);
  215.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 6, 30.0);
  216.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 7, 30.0);
  217.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 8, 30.0);
  218.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 9, 30.0);
  219.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 10, 30.0);
  220.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 11, 30.0);
  221.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 12, 30.0);
  222.         CreateExplosion(Bombas[playerid][PosBombaX], Bombas[playerid][PosBombaY], Bombas[playerid][PosBombaZ], 13, 30.0);
  223.         Bombas[playerid][BombasActivas]=true;
  224.     } return true;
  225. }
  226. COMMAND:bombas(playerid, params[]) {
  227.     switch(Bombas[playerid][BombasActivas]) {
  228.         case false: {
  229.             Bombas[playerid][BombasActivas]=true;
  230.             PlayerTextDrawShow(playerid, TextBombas[playerid][2]);
  231.             SendClientMessage(playerid, -1,"  [ ! ] Haz activado el sistema de bombas!.");
  232.         }
  233.         case true: {
  234.             HidePlayerProgressBar(playerid, BarBombas[playerid][0]);
  235.             HidePlayerProgressBar(playerid, BarBombas[playerid][1]);
  236.             PlayerTextDrawHide(playerid, TextBombas[playerid][0]);
  237.             PlayerTextDrawHide(playerid, TextBombas[playerid][1]);
  238.             PlayerTextDrawHide(playerid, TextBombas[playerid][2]);
  239.             KillTimer(Bombas[playerid][MatarColocando]);
  240.             KillTimer(Bombas[playerid][MatarExplotando]);
  241.             Bombas[playerid][BombasActivas]=false;
  242.             Bombas[playerid][ContandoBoom]=0;
  243.             DestroyObject(Bombas[playerid][ObjetoBomba]);
  244.             PlayerTextDrawHide(playerid, TextBombas[playerid][2]);
  245.             SendClientMessage(playerid, -1,"  [ ! ] Haz desactivado el sistema de bombas!.");
  246.         }
  247.     } return true;
  248. }
  249. COMMAND:municion(playerid, params[]) {
  250.     if(Bombas[playerid][CantidadBombas]!=0) return SendClientMessage(playerid, -1,"  [ ! ] Aun tienes bombas para colocar!.");
  251.     if(GetPlayerMoney(playerid)<=0 || GetPlayerMoney(playerid)<COSTO_BOMBA) return SendClientMessage(playerid, -1,"  [ ! ] No tienes suficiente dinero para comprar bombas!.");
  252.     new data[100];
  253.     Bombas[playerid][CantidadBombas]=MAX_BOMBA;
  254.     format(data,sizeof(data), "  [ ! ] Haz comprado un pack de %d bombas, por $%d - ($:%d x Bombas:%d)!.",MAX_BOMBA,COSTO_BOMBA*MAX_BOMBA,COSTO_BOMBA,MAX_BOMBA);
  255.     SendClientMessage(playerid, -1,data);
  256.     GivePlayerMoney(playerid,(0-COSTO_BOMBA*MAX_BOMBA));
  257.     format(data,sizeof(data), "~w~Cantidad de Bombas: ~g~%02d/%02d", Bombas[playerid][CantidadBombas], MAX_BOMBA);
  258.     PlayerTextDrawSetString(playerid,TextBombas[playerid][2], data);
  259.     return true;
  260. }
RAW Paste Data