Guest User

sa-mp CatFish Sync clock

a guest
Apr 20th, 2011
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.35 KB | None | 0 0
  1. //Synchronised Player Clock By CatFish
  2. //Feel free to do anything to it
  3.  
  4.  
  5. #include <a_samp>
  6.  
  7. #define     TimeTimer       1       //In Seconds        -       Time of which minutes will pass
  8. #define     StartHour       00      //24 hour time      -       14 for 2pm eg.
  9.  
  10.  
  11. static
  12.     whour,
  13.     wminute;
  14.  
  15.  
  16. new Text:Timet;
  17.  
  18.  
  19. forward Time();
  20.  
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24.     Time();
  25.     TextDrawShowForPlayer(playerid, Text:Timet);
  26. }
  27.  
  28.  
  29. public OnGameModeInit()
  30. {
  31.     SetWorldTime(StartHour);
  32.     whour = StartHour;
  33.     wminute = 00;
  34.     Time();
  35.     SetTimer("Time", TimeTimer*1000, true);
  36.  
  37.  
  38.     new timem[6];
  39.     format(timem, 128, "%02d:%02d",whour,wminute);
  40.     Timet = TextDrawCreate(551, 35, timem);
  41.     TextDrawFont(Timet , 3);
  42.     TextDrawLetterSize(Timet , 0.60, 2.0); //0.58    1.9
  43.     TextDrawColor(Timet , 0xFFFFFFFF);
  44.     TextDrawSetOutline(Timet , 1);
  45.     TextDrawSetProportional(Timet , 1);
  46.     TextDrawSetShadow(Timet , 1);
  47. }
  48.  
  49.  
  50. public Time()
  51. {
  52.     if(wminute == 59)
  53.     {
  54.         if(whour == 23) whour = 00, wminute = 00;
  55.         else whour++, wminute = 00;
  56.     }
  57.     else wminute++;
  58.    
  59.     for(new p = 0; p < MAX_PLAYERS; p++)
  60.     {
  61.         if(IsPlayerConnected(p) && GetPlayerState(p) != PLAYER_STATE_NONE)
  62.         {
  63.             SetPlayerTime(p, whour, wminute);
  64.  
  65.             new timem[6];
  66.             format(timem,128,"%02d:%02d",whour,wminute);
  67.             TextDrawSetString(Text:Timet, timem);
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment