Advertisement
yNexus

Tempo Online em Dialog

Mar 28th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include <a_samp>
  2. #include <foreach>
  3.  
  4. #define FILTERSCRIPT
  5. #if defined FILTERSCRIPT
  6.  
  7. enum pInfo
  8. {
  9. pTemp,
  10. pLogged
  11. }
  12.  
  13. new PlayerInfo[MAX_PLAYERS][pInfo];
  14.  
  15. public OnFilterScriptInit()
  16. {
  17. SetTimer("AtualizarTempo", 1000, true);
  18. print("\n--------------------------------------");
  19. print(" Tempo Online By: yNexus");
  20. print("--------------------------------------\n");
  21. return 1;
  22. }
  23.  
  24. public OnPlayerCommandText(playerid, cmdtext[])
  25. {
  26. if (strcmp("/meutempo", cmdtext, true, 10) == 0)
  27. {
  28. new nexus[100];
  29. format(nexus,sizeof(nexus), "Seu Tempo Online é: %s", Convert(PlayerInfo[playerid][pTemp]));
  30. ShowPlayerDialog(playerid,2424,DIALOG_STYLE_MSGBOX,"Tempo online:",nexus,"Fechar","");
  31. return 1;
  32. }
  33. return 0;
  34. }
  35.  
  36. public OnPlayerDisconnect(playerid, reason)
  37. {
  38. PlayerInfo[playerid][pTemp] = 0;
  39. PlayerInfo[playerid][pLogged] = 0;
  40. return 1;
  41. }
  42.  
  43. public OnPlayerSpawn(playerid)
  44. {
  45. PlayerInfo[playerid][pLogged] = 1;
  46. return 1;
  47. }
  48.  
  49. stock Convert(playerid)
  50. {
  51. new hours = 0, mins = 0, secs = 0, string[100];
  52. hours = floatround(playerid / 3600);
  53. mins = floatround((playerid / 60) - (hours * 60));
  54. secs = floatround(playerid - ((hours * 3600) + (mins * 60)));
  55. new days = 0;
  56.  
  57. if(hours >= 24)
  58. {
  59. days = floatround((hours/24), floatround_floor);
  60. hours = hours % 24;
  61. }
  62.  
  63. if(days > 0)
  64. {
  65. format(string, 0xD3F128FF, "%ddias, %dh %dm e %ds", days, hours, mins, secs);
  66. }
  67. else if(hours > 0)
  68. {
  69. format(string, 0xD3F128FF, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (mins < 10) ? ("0"):(""), mins, (secs < 10) ? ("0"):(""), secs);
  70. }
  71. else
  72. {
  73. format(string, 0xD3F128FF, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (mins < 10) ? ("0"):(""), mins, (secs < 10) ? ("0"):(""), secs);
  74. }
  75. return string;
  76. }
  77.  
  78. forward AtualizarTempo();
  79. public AtualizarTempo()
  80. {
  81. foreach(Player, i)
  82. {
  83. if(PlayerInfo[i][pLogged] == 1)
  84. {
  85. PlayerInfo[i][pTemp]++;
  86. }
  87. }
  88. return 1;
  89. }
  90.  
  91. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement