Advertisement
yNexus

Tempo Online em Textdraw

Mar 28th, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3.  
  4. #define FILTERSCRIPT
  5. #if defined FILTERSCRIPT
  6.  
  7. new PlayerText:TempoOnline[MAX_PLAYERS];
  8.  
  9. enum pInfo
  10. {
  11. pTemp,
  12. pLogged
  13. }
  14.  
  15. new PlayerInfo[MAX_PLAYERS][pInfo];
  16.  
  17. public OnFilterScriptInit()
  18. {
  19. SetTimer("AtualizarTempo", 1000, true);
  20. SetTimer("atualizartext", 1000, true);
  21. print("\n--------------------------------------");
  22. print(" Tempo Online By: yNexus");
  23. print("--------------------------------------\n");
  24. return 1;
  25. }
  26.  
  27. public OnPlayerConnect(playerid)
  28. {
  29. TodasText(playerid);
  30. return 1;
  31. }
  32.  
  33. public OnPlayerDisconnect(playerid, reason)
  34. {
  35. PlayerInfo[playerid][pTemp] = 0;
  36. PlayerInfo[playerid][pLogged] = 0;
  37. return 1;
  38. }
  39.  
  40. public OnPlayerSpawn(playerid)
  41. {
  42. PlayerInfo[playerid][pLogged] = 1;
  43. return 1;
  44. }
  45.  
  46. forward atualizartext(playerid);
  47. public atualizartext(playerid)
  48. {
  49. if(PlayerInfo[playerid][pLogged] == 1)
  50. {
  51. new nexus[128];
  52. format(nexus, sizeof(nexus), "Tempo Online: ~w~%s",Convert(PlayerInfo[playerid][pTemp]));
  53. PlayerTextDrawSetString(playerid, TempoOnline[playerid], nexus);
  54. PlayerTextDrawShow(playerid, TempoOnline[playerid]);
  55. }
  56. return 1;
  57. }
  58.  
  59. stock Convert(playerid)
  60. {
  61. new hours = 0, mins = 0, secs = 0, string[100];
  62. hours = floatround(playerid / 3600);
  63. mins = floatround((playerid / 60) - (hours * 60));
  64. secs = floatround(playerid - ((hours * 3600) + (mins * 60)));
  65. new days = 0;
  66.  
  67. if(hours >= 24)
  68. {
  69. days = floatround((hours/24), floatround_floor);
  70. hours = hours % 24;
  71. }
  72.  
  73. if(days > 0)
  74. {
  75. format(string, 0xD3F128FF, "%ddias, %dh %dm e %ds", days, hours, mins, secs);
  76. }
  77. else if(hours > 0)
  78. {
  79. format(string, 0xD3F128FF, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (mins < 10) ? ("0"):(""), mins, (secs < 10) ? ("0"):(""), secs);
  80. }
  81. else
  82. {
  83. format(string, 0xD3F128FF, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (mins < 10) ? ("0"):(""), mins, (secs < 10) ? ("0"):(""), secs);
  84. }
  85. return string;
  86. }
  87.  
  88. forward AtualizarTempo();
  89. public AtualizarTempo()
  90. {
  91. foreach(Player, i)
  92. {
  93. if(PlayerInfo[i][pLogged] == 1)
  94. {
  95. PlayerInfo[i][pTemp]++;
  96. }
  97. }
  98. return 1;
  99. }
  100.  
  101. stock TodasText(playerid)
  102. {
  103. TempoOnline[playerid] = CreatePlayerTextDraw(playerid,18.000000, 320.000000, "Tempo Online: 00:00:00");
  104. PlayerTextDrawBackgroundColor(playerid,TempoOnline[playerid], 255);
  105. PlayerTextDrawFont(playerid,TempoOnline[playerid], 1);
  106. PlayerTextDrawLetterSize(playerid,TempoOnline[playerid], 0.300000, 1.000000);
  107. PlayerTextDrawColor(playerid,TempoOnline[playerid], -1);
  108. PlayerTextDrawSetOutline(playerid,TempoOnline[playerid], 1);
  109. PlayerTextDrawSetProportional(playerid,TempoOnline[playerid], 1);
  110. }
  111.  
  112. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement