Guest User

US_Timers.inc

a guest
Aug 26th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. //US_Timers inc made by UltraScripter ///////////////////////////// ///// //////////////////////////////////////////////////////////////
  2. //US_Timers inc made by UltraScripter ///////////////////////////// ///// //////////////////////////////////////////////////////////////
  3.  
  4. /*
  5. native US_SetTimer(playerid, type);
  6. native US_ResetTimer(playerid);
  7. native US_SetCountDown(playerid, type);
  8. native US_SetTimerAdd(playerid, type, days, hours, minutes, seconds);
  9. native US_GetSecs(playerid);
  10. native US_GetMins(playerid);
  11. native US_GetHours(playerid);
  12. native US_GetDays(playerid);
  13. native US_SetTimerTime(playerid, days, hours, minutes, seconds);
  14. */
  15.  
  16. #if defined _US_Timers_included
  17. #endinput
  18. #define US_timers_included
  19. #endif
  20.  
  21. new USTIMERSSEC[MAX_PLAYERS]; //1000
  22. new USTIMERSMIN[MAX_PLAYERS]; //60000
  23. new USTIMERSHOUR[MAX_PLAYERS]; //3600000
  24. new USTIMERSDAY[MAX_PLAYERS]; //86400000
  25.  
  26. #define SEC 0
  27. #define MIN 1
  28. #define HOUR 2
  29. #define DAY 3
  30.  
  31. stock US_SetTimer(playerid, type)
  32. {
  33. if(type == SEC)
  34. {
  35. SetTimerEx("USTIMERSECPUB", 1000, true, "i", playerid);
  36. }
  37. if(type == MIN)
  38. {
  39. SetTimerEx("USTIMERMINPUB", 60000, true, "i", playerid);
  40. }
  41. if(type == HOUR)
  42. {
  43. SetTimerEx("USTIMERHOURPUB", 3600000, true, "i", playerid);
  44. }
  45. if(type == DAY)
  46. {
  47. SetTimerEx("USTIMERDAYPUB", 8400000, true, "i", playerid);
  48. }
  49. return 1;
  50. }
  51.  
  52. stock US_ResetTimer(playerid)
  53. {
  54. USTIMERSSEC[playerid] = 0;
  55. USTIMERSMIN[playerid] = 0;
  56. USTIMERSHOUR[playerid] = 0;
  57. USTIMERSDAY[playerid] = 0;
  58. return 1;
  59. }
  60.  
  61. stock US_SetCountDown(playerid, type)
  62. {
  63. if(type == SEC)
  64. {
  65. SetTimerEx("SUBUSTIMERSECPUB", 1000, true, "i", playerid);
  66. }
  67. if(type == MIN)
  68. {
  69. SetTimerEx("SUBUSTIMERMINPUB", 60000, true, "i", playerid);
  70. }
  71. if(type == HOUR)
  72. {
  73. SetTimerEx("SUBUSTIMERHOURPUB", 3600000, true, "i", playerid);
  74. }
  75. if(type == DAY)
  76. {
  77. SetTimerEx("SUBUSTIMERDAYPUB", 8400000, true, "i", playerid);
  78. }
  79. return 1;
  80. }
  81.  
  82. stock US_SetTimerAdd(playerid, days, hours, minutes, seconds)
  83. {
  84. USTIMERSSEC[playerid] += seconds;
  85. USTIMERSMIN[playerid] += minutes;
  86. USTIMERSHOUR[playerid] += hours;
  87. USTIMERSDAY[playerid] += days;
  88. return 1;
  89. }
  90.  
  91. stock US_SetTimerTime(playerid, days, hours, minutes, seconds)
  92. {
  93. USTIMERSSEC[playerid] = seconds;
  94. USTIMERSMIN[playerid] = minutes;
  95. USTIMERSHOUR[playerid] = hours;
  96. USTIMERSDAY[playerid] = days;
  97. return 1;
  98. }
  99.  
  100. forward USTIMERSECPUB(playerid);
  101.  
  102. public USTIMERSECPUB(playerid)
  103. {
  104. USTIMERSSEC[playerid] += 1;
  105. if(USTIMERSSEC[playerid] == 60) return USTIMERSSEC[playerid] = 0;
  106. return 1;
  107. }
  108.  
  109. forward USTIMERMINPUB(playerid);
  110.  
  111. public USTIMERMINPUB(playerid)
  112. {
  113. USTIMERSMIN[playerid] += 1;
  114. if(USTIMERSMIN[playerid] == 60) return USTIMERSMIN[playerid] = 0;
  115. return 1;
  116. }
  117.  
  118. forward USTIMERHOURPUB(playerid);
  119.  
  120. public USTIMERHOURPUB(playerid)
  121. {
  122. USTIMERSHOUR[playerid] += 1;
  123. if(USTIMERSHOUR[playerid] == 60) return USTIMERSHOUR[playerid] = 0;
  124. return 1;
  125. }
  126.  
  127. forward USTIMERDAYPUB(playerid);
  128.  
  129. public USTIMERDAYPUB(playerid)
  130. {
  131. USTIMERSDAY[playerid] += 1;
  132. return 1;
  133. }
  134.  
  135. forward SUBUSTIMERSECPUB(playerid);
  136.  
  137. public SUBUSTIMERSECPUB(playerid)
  138. {
  139. USTIMERSSEC[playerid] -= 1;
  140. if(USTIMERSSEC[playerid] == 0) return USTIMERSSEC[playerid] = 59;
  141. if(USTIMERSSEC[playerid] == 60) return USTIMERSSEC[playerid] = 0;
  142. return 1;
  143. }
  144.  
  145. forward SUBUSTIMERMINPUB(playerid);
  146.  
  147. public SUBUSTIMERMINPUB(playerid)
  148. {
  149. USTIMERSMIN[playerid] -= 1;
  150. if(USTIMERSMIN[playerid] == 0) return USTIMERSMIN[playerid] = 59;
  151. if(USTIMERSMIN[playerid] == 60) return USTIMERSMIN[playerid] = 0;
  152. return 1;
  153. }
  154.  
  155. forward SUBUSTIMERHOURPUB(playerid);
  156.  
  157. public SUBUSTIMERHOURPUB(playerid)
  158. {
  159. USTIMERSHOUR[playerid] -= 1;
  160. if(USTIMERSHOUR[playerid] == 0) return USTIMERSHOUR[playerid] = 59;
  161. if(USTIMERSHOUR[playerid] == 60) return USTIMERSHOUR[playerid] = 0;
  162. return 1;
  163. }
  164.  
  165. forward SUBUSTIMERDAYPUB(playerid);
  166.  
  167. public SUBUSTIMERDAYPUB(playerid)
  168. {
  169. USTIMERSDAY[playerid] -= 1;
  170. return 1;
  171. }
  172.  
  173. stock US_GetSecs(playerid)
  174. {
  175. return USTIMERSSEC[playerid];
  176. }
  177.  
  178. stock US_GetMins(playerid)
  179. {
  180. return USTIMERSMIN[playerid];
  181. }
  182.  
  183. stock US_GetHours(playerid)
  184. {
  185. return USTIMERSHOUR[playerid];
  186. }
  187.  
  188. stock US_GetDays(playerid)
  189. {
  190. return USTIMERSDAY[playerid];
  191. }
  192.  
  193. //US_Timers inc made by UltraScripter ///////////////////////////// ///// //////////////////////////////////////////////////////////////
  194. //US_Timers inc made by UltraScripter ///////////////////////////// ///// //////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment