Advertisement
Meta__

[IT] NewYearCounter v0.2a

Dec 27th, 2011
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.11 KB | None | 0 0
  1. /*####################################################################*\
  2. ##                                                                  ##
  3. ##  CNA (Contatore Nuovo Anno :D) v.0.2a [Tradotto da giovanni256]  ##
  4. ##                 Un lavoro per ItalianHack.org                    ##
  5. ##      Originale: NYC (New Year Counter :D) v.0.2a by Meta         ##
  6. ##                                                                  ##
  7. \*####################################################################*/
  8.  
  9. #include <a_samp>
  10.  
  11. #pragma tabsize 0
  12.  
  13. //#define Italiano // Mostrare il dispaly con le opzioni in Italiano?
  14.  
  15. new cTime;
  16. new Text:NYCounter;
  17. new Text:HappyNewYearText;
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.         NYCounter = TextDrawCreate(357.000000, 399.000000, "_");
  22.         TextDrawAlignment(NYCounter, 2);
  23.         TextDrawBackgroundColor(NYCounter, 255);
  24.         TextDrawFont(NYCounter, 2);
  25.         TextDrawLetterSize(NYCounter, 0.40000, 2);
  26.         TextDrawColor(NYCounter, -16776961);
  27.         TextDrawSetOutline(NYCounter, 1);
  28.         TextDrawSetProportional(NYCounter, 1);
  29.  
  30.         new message[40], year, month, day;
  31.         getdate(year, month, day);
  32.         if(month != 1) { year--; }
  33.         #if defined Italiano
  34.                 format(message, sizeof(message), "~>~ FELICE NUOVO ANNO ~<~~n~~y~%d!", year);
  35.         #else
  36.                 format(message, sizeof(message), "~>~ HAPPY NEW YEAR ~<~~n~~y~%d!", year);
  37.         #endif
  38.         HappyNewYearText = TextDrawCreate(340.000000, 350.000000, message);
  39.         TextDrawAlignment(HappyNewYearText, 2);
  40.         TextDrawBackgroundColor(HappyNewYearText, 255);
  41.         TextDrawFont(HappyNewYearText, 1);
  42.         TextDrawLetterSize(HappyNewYearText, 1.000000, 4.000000);
  43.         TextDrawColor(HappyNewYearText, 16777215);
  44.         TextDrawSetOutline(HappyNewYearText, 1);
  45.         TextDrawSetProportional(HappyNewYearText, 1);
  46.  
  47.     CounterTimer();
  48.         cTime = SetTimer("CounterTimer", 400, 1);
  49.         return 1;
  50. }
  51.  
  52. public OnFilterScriptExit()
  53. {
  54.         TextDrawDestroy(NYCounter);
  55.         TextDrawDestroy(HappyNewYearText);
  56.         KillTimer(cTime);
  57. }
  58.  
  59. public OnPlayerConnect(playerid)
  60. {
  61.     new year, month, day, hour, minute, second;
  62.         getdate(year, month, day);
  63.         gettime(hour, minute, second);
  64.         if(day == 1 && month == 1 && (second > 0 || hour > 0))
  65.         {
  66.             TextDrawShowForPlayer(playerid, HappyNewYearText);
  67.         }
  68. }
  69.  
  70. forward CounterTimer();
  71. public CounterTimer()
  72. {
  73.         new string[150];
  74.         new year, month, day, hour, minute, second;
  75.         getdate(year, month, day);
  76.         gettime(hour, minute, second);
  77.         if(month == 1 && day == 1)
  78.         {
  79.             TextDrawHideForAll(NYCounter);
  80.             TextDrawShowForAll(HappyNewYearText);
  81.             KillTimer(cTime);
  82.         }
  83.         else
  84.         {
  85.                 gettime(hour, minute, second);
  86.  
  87.                 new day2;
  88.                 switch(month)
  89.                 {
  90.                     case 1, 3, 5, 7, 8, 10, 12: day2 = 31;
  91.                     case 2: { if(year%4 == 0) { day2 = 29; } else { day2 = 28; } }
  92.                     case 4, 6, 9, 11: day2 = 30;
  93.                 }
  94.                 month = 12 - month;
  95.                 day = day2 - day;
  96.                 hour = 24 - hour;               if(hour == 24) { hour = 0; }            if(minute != 0) { hour--; }
  97.                 minute = 60 - minute;   if(minute == 60) { minute = 0; }        if(second != 0) { minute--; }
  98.                 second = 60 - second;   if(second == 60) { second = 0; }
  99.  
  100.                 #if defined Italiano
  101.                 format(string, sizeof(string), "~y~2012: ~g~%02d ~w~Me, ~g~%02d ~w~G, ~g~%02d ~w~H, ~g~%02d ~w~M, ~g~%02d ~w~S", month, day, hour, minute, second);
  102.                 #else
  103.                 format(string, sizeof(string), "~y~2012: ~g~%02d ~w~Mo, ~g~%02d ~w~D, ~g~%02d ~w~H, ~g~%02d ~w~M, ~g~%02d ~w~S", month, day, hour, minute, second);
  104.                 #endif
  105.                 TextDrawHideForAll(NYCounter);
  106.                 TextDrawSetString(NYCounter, string);
  107.                 TextDrawShowForAll(NYCounter);
  108.         }
  109.         return 1;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement