OtaconEvil

[FS] Contador Cuenta Regresiva By OTACON [EDIT: LuiisRubio]

Oct 3rd, 2013
271
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 <sscanf2>
  39. #define CALLBACK:%0(%1) forward%0(%1); public%0(%1)
  40.  
  41. #define B "{FFFFFF}" //white
  42. #define R "{BC0000}" //red
  43. #define G "{009100}" //green
  44.  
  45. #define TIMER_COUNTDOWN (1*1000)
  46. #define COLOR_N 0x00000055
  47. #define COLOR_B 0xFFFDFFFF
  48. #define COLOR_R 0xC00000FF
  49. #define COLOR_G 0x009800FF
  50. #define MAX_COUNTDOWN (10)
  51. static Text:CountdownTD[MAX_COUNTDOWN],
  52. DataCountdown[4],bool:ActiveCountdown,KillCountdown;
  53.  
  54. CALLBACK: OnFilterScriptInit()
  55. {
  56.     print("\n**************************************");
  57.     print("            Countdown Timer             ");
  58.     print("           Date: 29/09/2013             ");
  59.     print("            Author: OTACON              ");
  60.     print("   --* Downloaded with Success!!. *--   ");
  61.     print("***************************************\n");
  62.     SendRconCommand("hostname Countdown Timer");
  63.     SendRconCommand("gamemodetext By OTACON");
  64.    
  65.     CountdownTD[0] = TextDrawCreate(529.000000, 354.000000, "_");
  66.     TextDrawAlignment(CountdownTD[0], 2);
  67.     TextDrawBackgroundColor(CountdownTD[0], 255);
  68.     TextDrawFont(CountdownTD[0], 2);
  69.     TextDrawLetterSize(CountdownTD[0], 0.189999, 9.799999);
  70.     TextDrawColor(CountdownTD[0], -1);
  71.     TextDrawSetOutline(CountdownTD[0], 1);
  72.     TextDrawSetProportional(CountdownTD[0], 1);
  73.     TextDrawUseBox(CountdownTD[0], 1);
  74.     TextDrawBoxColor(CountdownTD[0], COLOR_N);
  75.     TextDrawTextSize(CountdownTD[0], -24.000000, 179.000000);
  76.  
  77.     CountdownTD[1] = TextDrawCreate(529.000000, 385.000000, "_");
  78.     TextDrawAlignment(CountdownTD[1], 2);
  79.     TextDrawBackgroundColor(CountdownTD[1], COLOR_G);
  80.     TextDrawFont(CountdownTD[1], 3);
  81.     TextDrawLetterSize(CountdownTD[1], 0.799999, 4.599999);
  82.     TextDrawColor(CountdownTD[1], COLOR_B);
  83.     TextDrawSetOutline(CountdownTD[1], 1);
  84.     TextDrawSetProportional(CountdownTD[1], 1);
  85.  
  86.     TextDrawLetterSize(CountdownTD[1], 0.799999, 4.599999);
  87.     CountdownTD[2] = TextDrawCreate(458.000000, 422.000000, "DAYS");
  88.     TextDrawLetterSize(CountdownTD[2], 0.250000, 1.900000);
  89.     TextDrawBackgroundColor(CountdownTD[2], COLOR_G);
  90.     CountdownTD[3] = TextDrawCreate(505.000000, 422.000000, "HOURS");
  91.     TextDrawLetterSize(CountdownTD[3], 0.220000, 1.900000);
  92.     TextDrawBackgroundColor(CountdownTD[3], COLOR_G);
  93.     CountdownTD[4] = TextDrawCreate(552.000000, 422.000000, "MINUTES");
  94.     TextDrawLetterSize(CountdownTD[4], 0.179999, 1.900000);
  95.     TextDrawBackgroundColor(CountdownTD[4], COLOR_G);
  96.     CountdownTD[5] = TextDrawCreate(598.000000, 422.000000, "SECONDS");
  97.     TextDrawLetterSize(CountdownTD[5], 0.159999, 1.900000);
  98.     TextDrawBackgroundColor(CountdownTD[5], COLOR_G);
  99.     CountdownTD[6] = TextDrawCreate(528.000000, 349.000000, "COUNTDOWN TIMER");
  100.     TextDrawLetterSize(CountdownTD[6], 0.259999, 2.499998);
  101.     TextDrawBackgroundColor(CountdownTD[6], COLOR_R);
  102.     CountdownTD[7] = TextDrawCreate(575.000000, 369.000000, "By OTACON");
  103.     TextDrawLetterSize(CountdownTD[7], 0.189999, 1.599999);
  104.     TextDrawBackgroundColor(CountdownTD[7], COLOR_G);
  105.     for(new index=2; index<MAX_COUNTDOWN; index++) {
  106.         TextDrawAlignment(CountdownTD[index], 2);
  107.         TextDrawFont(CountdownTD[index], 2);
  108.         TextDrawColor(CountdownTD[index], -1);
  109.         TextDrawSetOutline(CountdownTD[index], 1);
  110.         TextDrawSetProportional(CountdownTD[index], 1); }
  111.  
  112.     CountdownTD[8] = TextDrawCreate(530.000000, 331.000000, "PLACE YOUR MESSAGE HERE!...");
  113.     TextDrawAlignment(CountdownTD[8], 2);
  114.     TextDrawBackgroundColor(CountdownTD[8], 255);
  115.     TextDrawFont(CountdownTD[8], 1);
  116.     TextDrawLetterSize(CountdownTD[8], 0.260000, 1.600000);
  117.     TextDrawColor(CountdownTD[8], -1);
  118.     TextDrawSetOutline(CountdownTD[8], 1);
  119.     TextDrawSetProportional(CountdownTD[8], 1);
  120.     TextDrawUseBox(CountdownTD[8], 1);
  121.     TextDrawBoxColor(CountdownTD[8], COLOR_N);
  122.     TextDrawTextSize(CountdownTD[8], -17.000000, 180.000000);
  123.  
  124.     CountdownTD[9] = TextDrawCreate(438.000000, 316.000000, "MESSAGE:");
  125.     TextDrawBackgroundColor(CountdownTD[9], COLOR_G);
  126.     TextDrawFont(CountdownTD[9], 1);
  127.     TextDrawLetterSize(CountdownTD[9], 0.260000, 1.600000);
  128.     TextDrawColor(CountdownTD[9], COLOR_B);
  129.     TextDrawSetOutline(CountdownTD[9], 1);
  130.     TextDrawSetProportional(CountdownTD[9], 1);
  131.     return true;
  132. }
  133.  
  134. CALLBACK: OnFilterScriptExit() {
  135.     print("\n**************************************");
  136.     print("            Countdown Timer             ");
  137.     print("           Date: 29/09/2013             ");
  138.     print("            Author: OTACON              ");
  139.     print("     --* Loaded with Success!!. *--     ");
  140.     print("***************************************\n");
  141.     SendRconCommand("hostname Countdown Timer");
  142.     SendRconCommand("gamemodetext By OTACON");
  143.     for(new index=0; index<MAX_COUNTDOWN; index++) \
  144.         TextDrawHideForAll(CountdownTD[index]), \
  145.            TextDrawDestroy(CountdownTD[index]);
  146.     return true;
  147. }
  148.  
  149.  
  150. /*
  151. CALLBACK: OnPlayerDisconnect(playerid, reason) {
  152.     for(new index=0; index<MAX_COUNTDOWN; index++) \
  153.         TextDrawHideForAll(playerid,CountdownTD[index]), \
  154.            TextDrawDestroy(CountdownTD[index]);
  155.     return true;
  156. }
  157. */
  158.  
  159. CALLBACK: UpdateCountdown() {
  160.     new data[50];
  161.     if(!ActiveCountdown)
  162.     {
  163.         for(new index=0; index<MAX_COUNTDOWN; index++) TextDrawHideForAll(CountdownTD[index]);
  164.         for(new index=0; index<4; index++) DataCountdown[index]=0;
  165.         KillTimer(KillCountdown);
  166.     }
  167.     else
  168.     {
  169.         static CountdownTemp[2];
  170.         DataCountdown[3]--;
  171.         if(DataCountdown[3]>=60) DataCountdown[3]=0, DataCountdown[2]--, CountdownTemp[0]++;
  172.         if(CountdownTemp[0]>=60) CountdownTemp[0]=0, DataCountdown[1]--, CountdownTemp[1]++;
  173.         if(CountdownTemp[1]>=24) CountdownTemp[1]=0, DataCountdown[0]--;
  174.         if(DataCountdown[3]<=0 && DataCountdown[2] >= 1) DataCountdown[2]--, DataCountdown[3]=59; //Faltaba esto, pequeño error de Otacon.
  175.         if(DataCountdown[2]<=0) DataCountdown[2]=0;
  176.         if(DataCountdown[1]<=0) DataCountdown[1]=0;
  177.         if(DataCountdown[0]<=0) DataCountdown[0]=0;
  178.         format(data,sizeof(data),"%02d:%02d:%02d:%02d",DataCountdown[0],DataCountdown[1],DataCountdown[2],DataCountdown[3]);
  179.         TextDrawSetString(CountdownTD[1],data);
  180.         for(new index=0; index<MAX_COUNTDOWN; index++) \
  181.             TextDrawHideForAll(CountdownTD[index]),\
  182.             TextDrawShowForAll(CountdownTD[index]);
  183.         if(DataCountdown[0]<=0 && DataCountdown[1]<=0 && DataCountdown[2]<=0 && DataCountdown[3]<=0)
  184.         {
  185.             ActiveCountdown=false;
  186.             //CountdownFunction();
  187.             SendClientMessageToAll(-1, ""B"[!] "G"The countdown timer is over"B"!");
  188.             for(new index=0; index<2; index++) \
  189.                 CountdownTemp[index]=0;
  190.         }
  191.     }
  192. }
  193.  
  194. /*
  195. stock CountdownFunction() {
  196.     for(new msg=0; msg<100; msg++) \
  197.         SendClientMessageToAll(-1, "    "B"[ ! ] "G"The countdown timer is over"B"!."), \
  198.         SendClientMessageToAll(-1, "    "B"[ ! ] "R"COUNTDOWN TIMER - By OTACON"B"!.");
  199. }*/
  200.  
  201. COMMAND:countdown(playerid, params[]) {
  202.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1," "B"[ ! ] "G"You Not Authorized to Use this command"B"!.");
  203.     if(sscanf(params,"dddds[20]",params[0],params[1],params[2],params[3],params[4])) return SendClientMessage(playerid, -1, "   "B"[ ! ] "G"Type the command: "R"/countdown "G"[days] [hours] [minutes] [seconds] [message]");
  204.     if(strval(params[0])<0||strval(params[0])>30) return SendClientMessage(playerid, -1, "  "B"[ ! ] "G"not go below 0 or above 30 days"B"!.");
  205.     if(strval(params[1])<0||strval(params[1])>12) return SendClientMessage(playerid, -1, "  "B"[ ! ] "G"not go below 0 or above 12 hours"B"!.");
  206.     if(strval(params[2])<0||strval(params[2])>60) return SendClientMessage(playerid, -1, "  "B"[ ! ] "G"not go below 0 or above 60 minutes"B"!.");
  207.     if(strval(params[3])<0||strval(params[3])>60) return SendClientMessage(playerid, -1, "  "B"[ ! ] "G"not go below 0 or above 60 seconds"B"!.");
  208.     if(strlen(params[4])<0||strlen(params[4])>20) return SendClientMessage(playerid, -1, "  "B"[ ! ] "G"not go below 0 or above 20 characters"B"!.");
  209.     ActiveCountdown=false;
  210.     ActiveCountdown=true;
  211.     for(new index=0; index<4; index++) \
  212.         DataCountdown[index]=0;
  213.     DataCountdown[0]=params[0];
  214.     DataCountdown[1]=params[1];
  215.     DataCountdown[2]=params[2];
  216.     DataCountdown[3]=params[3];
  217.     TextDrawSetString(CountdownTD[8],params[4]);
  218.     for(new index=0; index<MAX_COUNTDOWN; index++) \
  219.         TextDrawHideForAll(CountdownTD[index]),\
  220.         TextDrawShowForAll(CountdownTD[index]);
  221.     KillTimer(KillCountdown);
  222.     KillCountdown=SetTimer("UpdateCountdown",TIMER_COUNTDOWN,true);
  223.     SendClientMessage(playerid, -1, "   "B"[ ! ] "G"COUNTDOWN TIMER - ACTIVATED"B"!.");
  224.     return true;
  225. }
  226.  
  227. /*
  228.     * ## LEASE ATENTAMENTE PARA NO CONVERTIRSE EN LAMMER!!.: :D ##
  229.     *
  230.     * Estè Simple FILTERSCRIPT esta hecho especialmente para www.forum.sa-mp.com
  231.     * NO Publicar estè FILTERSCRIPT en Otros foros de SA-MP y hacerse pasar por el creador del CODE.
  232.     *
  233.     * Codigo Creado Por OTACON
  234.     *
  235.     * CREDITOS:
  236.     *     OTACON: Realizacion y Idea de creacion del code.
  237.     *     TÙ: Modificacion libremente respetando lo mencionado ;).
  238.     *
  239.     *    NOTA: Menos Creditos para los que me los critican.. JO'PUTAS! :D xD ;)
  240.     *
  241.     *            Prohibido TOTALMENTE el Robo de Créditos o la
  242.     *              Publicación de este FILTERSCRIPT sin Mi Permiso.
  243. */
  244. /*
  245.     * ## READ CAREFULLY TO AVOID BECOMING LAMMER!.: :D ##
  246.     *
  247.     * This simple FILTERSCRIPT is made especially for www.forum.sa-mp.com
  248.     * DO NOT Post the FILTERSCRIPT in Other SAMP forums and impersonating the creator of the CODE.
  249.     *
  250.     * Code Created By OTACON
  251.     *
  252.     * CREDITS:
  253.     *     OTACON: Idea Making and code creation.
  254.     *     YOUR: Modification freely respecting the above ;).
  255.     *
  256.     *    NOTE: Less Credits for those who criticize me.. JO'PUTAS! :D xD ;)
  257.     *
  258.     *                    FULLY spaces Theft Credit or
  259.     *             Publication of this FILTERSCRIPT without my permission.
  260. */
RAW Paste Data