Advertisement
Private200

Real Time Sync - SAMP

Mar 26th, 2013
3,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.83 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. // Here will be the the configurations for the time. There will be the textdraw, hour, minutes and the string.
  4.  
  5. new Text:TimerTextdraw;
  6. new hours, minutes;
  7. new realtime[32];
  8.  
  9. // We're going to create the textdraw over here, so it will appear in game, and we're going to make the timer too.
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.     TimerTextdraw = TextDrawCreate(557.000000, 20.000000, "00:00");
  14.     TextDrawBackgroundColor(TimerTextdraw, 255);
  15.     TextDrawFont(TimerTextdraw, 1);
  16.     TextDrawLetterSize(TimerTextdraw, 0.549999, 3.199999);
  17.     TextDrawColor(TimerTextdraw, -1);
  18.     TextDrawSetOutline(TimerTextdraw, 1);
  19.     TextDrawSetProportional(TimerTextdraw, 0);
  20.     TextDrawUseBox(TimerTextdraw, 1);
  21.     TextDrawBoxColor(TimerTextdraw, 595);
  22.     TextDrawTextSize(TimerTextdraw, 618.000000, 4.000000);
  23.  
  24.     TimeUpdater();
  25.     SetTimer("UpdateTime", 1000 * 60, 1);
  26.  
  27.     return 1;
  28. }
  29.  
  30. // This is the end of the configurations.
  31.  
  32. // This is the public that that will be created to update the clock shown in the screen.
  33.  
  34. forward TimeUpdater();
  35.  
  36. public TimeUpdater()
  37. {
  38.     gettime(hours, minutes);
  39.     format(realtime, 32, "%02d:%02d", hours, minutes);
  40.     TextDrawSetString(TimerTextdraw, realtime);
  41.    
  42.     SetWorldTime(hours);
  43.    
  44.     new x=0;
  45.     while(x!=MAX_PLAYERS) {
  46.         if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) {
  47.             SetPlayerTime(x, hours, minutes);
  48.          }
  49.         x++;
  50.     }
  51. }
  52.  
  53.  
  54. public OnPlayerSpawn(playerid)
  55. {
  56.     TextDrawShowForPlayer(playerid, TimerTextdraw);
  57.  
  58.     gettime(hours, minutes);
  59.     SetPlayerTime(playerid, hours, minutes);
  60.     return 1;
  61. }
  62.  
  63. public OnPlayerDeath(playerid)
  64. {
  65.     TextDrawHideForPlayer(playerid, TimerTextdraw);
  66.     return 1;
  67. }
  68. public OnPlayerConnect(playerid)
  69. {
  70.     gettime(hours, minutes);
  71.     SetPlayerTime(playerid, hours, minutes);
  72.     return 1;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement