Advertisement
zwoorelook

[FS]Clock, synchronized with the server system

Oct 7th, 2014
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.11 KB | None | 0 0
  1. //===========================================================================================
  2. //  Creditos
  3. //  Retirado do playhappy, editado por zwoorelook
  4. //===========================================================================================
  5.  
  6. //===========================================================================================
  7. //  *TEXTDRAW
  8. //===========================================================================================
  9. new Text:Reloginho1;
  10. new Text:Reloginho2;
  11. new Text:Reloginho3;
  12.  
  13. //===========================================================================================
  14. forward Fixhour(hora);
  15. forward Reloginho();
  16.  
  17. new shifthour;
  18. new hour;
  19. new minute;
  20. new second;
  21. new ghour = 0;
  22. new timeshift = 0;
  23.  
  24. stock SetHora()
  25. {
  26.     gettime(hour, minute, second);
  27.     if(hour == 0 && minute >= 0 && minute <= 59) { SetWorldTime(0); }
  28.     if(hour == 1 && minute >= 0 && minute <= 59) { SetWorldTime(1); }
  29.     if(hour == 2 && minute >= 0 && minute <= 59) { SetWorldTime(2); }
  30.     if(hour == 3 && minute >= 0 && minute <= 59) { SetWorldTime(3); }
  31.     if(hour == 4 && minute >= 0 && minute <= 59) { SetWorldTime(4); }
  32.     if(hour == 5 && minute >= 0 && minute <= 39) { SetWorldTime(5); }
  33.     if(hour == 5 && minute >= 40 && minute <= 49) { SetWorldTime(23); }
  34.     if(hour == 5 && minute >= 50 && minute <= 59) { SetWorldTime(22); }
  35.     if(hour == 6 && minute >= 0 && minute <= 9) { SetWorldTime(21); }
  36.     if(hour == 6 && minute >= 30 && minute <= 59) { SetWorldTime(7); }
  37.     if(hour == 7 && minute >= 0 && minute <= 59) { SetWorldTime(7); }
  38.     if(hour == 8 && minute >= 0 && minute <= 59) { SetWorldTime(8); }
  39.     if(hour == 9 && minute >= 0 && minute <= 59) { SetWorldTime(9); }
  40.     if(hour == 10 && minute >= 0 && minute <= 59) { SetWorldTime(10); }
  41.     if(hour == 11 && minute >= 0 && minute <= 59) { SetWorldTime(11); }
  42.     if(hour == 12 && minute >= 0 && minute <= 59) { SetWorldTime(12); }
  43.     if(hour == 13 && minute >= 0 && minute <= 59) { SetWorldTime(13); }
  44.     if(hour == 14 && minute >= 0 && minute <= 59) { SetWorldTime(14); }
  45.     if(hour == 15 && minute >= 0 && minute <= 59) { SetWorldTime(15); }
  46.     if(hour == 16 && minute >= 0 && minute <= 59) { SetWorldTime(16); }
  47.     if(hour == 17 && minute >= 0 && minute <= 59) { SetWorldTime(17); }
  48.     if(hour == 17 && minute >= 35 && minute <= 39) { SetWorldTime(20); }
  49.     if(hour == 17 && minute >= 40 && minute <= 49) { SetWorldTime(21); }
  50.     if(hour == 17 && minute >= 55 && minute <= 59) { SetWorldTime(23); }
  51.     if(hour == 18 && minute >= 0 && minute <= 29) { SetWorldTime(5); }
  52.     if(hour == 19 && minute >= 0 && minute <= 59) { SetWorldTime(4); }
  53.     if(hour == 20 && minute >= 0 && minute <= 59) { SetWorldTime(3); }
  54.     if(hour == 21 && minute >= 0 && minute <= 59) { SetWorldTime(2); }
  55.     if(hour == 22 && minute >= 0 && minute <= 59) { SetWorldTime(1); }
  56.     if(hour == 23 && minute >= 0 && minute <= 59) { SetWorldTime(0); }
  57. }
  58.  
  59. forward reloginho();
  60. forward SyncTime();
  61.  
  62. public OnGameModeInit()
  63. {  
  64.     SetTimer("reloginho",1000,true);
  65.     Reloginho1 = TextDrawCreate(553.00000,401.00000, "-");
  66.     TextDrawFont(Reloginho1, 2);
  67.     TextDrawColor(Reloginho1, 0xE5E5E5FF);
  68.     TextDrawLetterSize(Reloginho1, 0.200000, 0.790000);
  69.     TextDrawSetOutline(Reloginho1, 1);
  70.     TextDrawSetProportional(Reloginho1, 1);
  71.     TextDrawAlignment(Reloginho1, 2);
  72.     TextDrawBackgroundColor(Reloginho1, 0x00000055);
  73.     TextDrawSetShadow(Reloginho1, 1);
  74.  
  75.     Reloginho2 = TextDrawCreate(477.000000,377.000000, "-");
  76.     //TextDrawBackgroundColor(Reloginho2, -65281);
  77.     TextDrawBackgroundColor(Reloginho2, COLOR_LIGHTRED);
  78.     TextDrawFont(Reloginho2, 1);
  79.     TextDrawLetterSize(Reloginho2, 11.300043, 0.510000);
  80.     TextDrawColor(Reloginho2, COLOR_GREEN);
  81.     TextDrawSetOutline(Reloginho2, 0);
  82.     TextDrawSetProportional(Reloginho2, 1);
  83.     TextDrawSetShadow(Reloginho2, 1);
  84.  
  85.     Reloginho3 = TextDrawCreate(477.000000,409.000000, "-");
  86.     TextDrawBackgroundColor(Reloginho3, COLOR_LIGHTRED);
  87.     TextDrawFont(Reloginho3, 1);
  88.     TextDrawLetterSize(Reloginho3, 11.300043, 0.510000);
  89.     TextDrawColor(Reloginho3, COLOR_GREEN);
  90.     TextDrawSetOutline(Reloginho3, 0);
  91.     TextDrawSetProportional(Reloginho3, 1);
  92.     TextDrawSetShadow(Reloginho3, 1);
  93.  
  94.     forum = TextDrawCreate(510.000000,382.000000, "~r~~h~Genesee~g~~h~~h~Play");
  95.     TextDrawBackgroundColor(forum, 0x00000060);
  96.     TextDrawFont(forum,1);
  97.     TextDrawLetterSize(forum,0.500000, 1.700000);
  98.     TextDrawColor(forum, -1);
  99.     TextDrawSetOutline(forum,1);
  100.     TextDrawSetProportional(forum,1);
  101.  
  102.     forum2 = TextDrawCreate(493.000000,415.000000, "www.GeneseeGamers.com");
  103.     TextDrawBackgroundColor(forum2, 0x000030);
  104.     TextDrawFont(forum2, 1);
  105.     TextDrawLetterSize(forum2, 0.290000, 0.700000);
  106.     TextDrawColor(forum2, COLOR_GREEN);
  107.     TextDrawSetOutline(forum2, 1);
  108.     TextDrawSetProportional(forum2, 1);
  109.     TextDrawSetShadow(forum2, 1);
  110.     return 1;
  111. }
  112.  
  113. public OnGameModeExit()
  114. {
  115.     TextDrawDestroy(Reloginho1);
  116.     TextDrawDestroy(Reloginho2);
  117.     TextDrawHideForAll(Reloginho1);
  118.     TextDrawHideForAll(Reloginho2);
  119.  
  120.     return 1;
  121. }
  122.  
  123. public OnPlayerConnect(playerid)
  124. {
  125.     TextDrawShowForPlayer(playerid, Reloginho1);
  126.     TextDrawShowForPlayer(playerid, Reloginho2);
  127.     TextDrawShowForPlayer(playerid, Reloginho3);
  128.  
  129.     TextDrawShowForPlayer(playerid, forum);
  130.     TextDrawShowForPlayer(playerid, forum2);
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerSpawn(playerid)
  135. {
  136.     TextDrawShowForPlayer(playerid, Reloginho1);
  137.     TextDrawShowForPlayer(playerid, Reloginho2);
  138.  
  139.     TextDrawShowForPlayer(playerid, forum2);
  140.     return 1;
  141. }
  142.  
  143. public SyncTime()
  144. {
  145.     new tmphour;
  146.     new tmpminute;
  147.     new tmpsecond;
  148.     gettime(tmphour, tmpminute, tmpsecond);
  149.     Fixhour(tmphour);
  150.     tmphour = shifthour;
  151.     if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
  152.     {
  153.         ghour = tmphour;
  154.         SetHora();
  155.     }
  156. }
  157.  
  158. public reloginho()
  159. {
  160.     SyncTime();
  161.     new str[128];
  162.     new
  163.         ano,
  164.         mes,
  165.         dia,
  166.         horas,
  167.         minutos,
  168.         segundos;
  169.     getdate(ano, mes, dia);
  170.     gettime(horas, minutos, segundos);
  171.     format(str, sizeof(str), "~w~~h~~h~%d/%d/%d - %d:%d:%d", dia, mes, ano, horas, minutos, segundos);
  172.     TextDrawSetString(Reloginho1, str);
  173.     return true;
  174. }
  175.  
  176. public Fixhour(hora)
  177. {
  178.     hora = timeshift+hora;
  179.     if (hora < 0)
  180.     {
  181.         hora = hora+24;
  182.     }
  183.     else if (hora > 23)
  184.     {
  185.         hora = hora-24;
  186.     }
  187.     shifthour = hora;
  188.     return true;
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement