Guest User

[FS] Time & Date

a guest
Feb 18th, 2011
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. *                                                                              *
  3. *                           [FS] Orginal TIME & DATE                           *
  4. *                                                                              *
  5. *                          © 2011, Script by 4#Future                          *
  6. *                                                                              *
  7. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  8.  
  9. // ------------
  10. // - Includes -
  11. // ------------
  12.  
  13. #include <a_samp>
  14.  
  15.  
  16. // -----------
  17. // - Defines -
  18. // -----------
  19.  
  20. #define TIME_COLOR 0xFFFFFFFF           // die Farbe ist beliebig wählbar (weiß)
  21. #define DATE_COLOR 0xBFBFBFFF           // die Farbe ist beliebig wählbar (grau)
  22.  
  23. new Text:ShowZeit, Text:ShowDatum;
  24. new stunde, minute;
  25. new tag, monat, jahr;
  26.  
  27. forward UpdateZeit();
  28. forward UpdateDatum();
  29.  
  30.  
  31. // --------------
  32. // - Funktionen -
  33. // --------------
  34.  
  35. public OnFilterScriptInit()
  36. {
  37.     print(" ");
  38.     print("[FILTERSCRIPT] Time & Date, by 4#Future");
  39.     print(" ");
  40.     return 1;
  41. }
  42.  
  43. public OnGameModeInit()
  44. {
  45.     // -- Textdraws --
  46.    
  47.     ShowZeit = TextDrawCreate(547.0, 13.0,"00:00");         // Zeit
  48.     TextDrawLetterSize(ShowZeit, 0.62, 1.8);
  49.     TextDrawFont(ShowZeit, 3);
  50.     TextDrawColor(ShowDatum, TIME_COLOR);
  51.     TextDrawSetOutline(ShowZeit, 1);
  52.     TextDrawShowForAll(ShowZeit);
  53.     UpdateZeit();
  54.     SetTimer("UpdateZeit", 1000 * 60, 1);
  55.  
  56.     ShowDatum = TextDrawCreate(547.0, 31.0,"00.00.0000");   // Datum
  57.     TextDrawLetterSize(ShowDatum, 0.33, 1.2);
  58.     TextDrawFont(ShowDatum, 3);
  59.     TextDrawColor(ShowDatum, DATE_COLOR);
  60.     TextDrawSetOutline(ShowDatum, 1);
  61.     TextDrawShowForAll(ShowDatum);
  62.     UpdateDatum();
  63.     SetTimer("UpdateDatum", 1000 * 60 * 60, 1);
  64.  
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerSpawn(playerid)
  69. {
  70.     TextDrawShowForPlayer(playerid, ShowZeit);
  71.     TextDrawShowForPlayer(playerid, ShowDatum);
  72.  
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerDeath(playerid, killerid, reason)
  77. {
  78.     TextDrawHideForPlayer(playerid, ShowZeit);
  79.     TextDrawHideForPlayer(playerid, ShowDatum);
  80.    
  81.     return 1;
  82. }
  83.  
  84. //------------------------------------------------------------------------------
  85.  
  86. public UpdateZeit()
  87. {
  88.     new timestr[50];
  89.     gettime(stunde, minute);
  90.     format(timestr, 32, "%02d:%02d", stunde, minute);
  91.     TextDrawSetString(ShowZeit, timestr);
  92.  
  93.     new x = 0;
  94.     while(x != MAX_PLAYERS)
  95.     {
  96.         if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) { SetPlayerTime(x, stunde, minute); }
  97.         x++;
  98.     }
  99. }
  100.  
  101. public UpdateDatum()
  102. {
  103.     new datestr[50];
  104.     getdate(jahr, monat, tag);
  105.     format(datestr, 32, "%02d.%02d.%d", tag, monat, jahr);
  106.     TextDrawSetString(ShowDatum, datestr);
  107. }
Advertisement
Add Comment
Please, Sign In to add comment