Guest User

Times.inc

a guest
Apr 13th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.54 KB | None | 0 0
  1. //Times by UltraScripter / / //////////////////////////////////////////
  2. //Times by UltraScripter / / //////////////////////////////////////////
  3.  
  4. #if defined _Times_included
  5. #endinput
  6. #define _Times_included
  7. #endif
  8.  
  9. new RaiseTimeTimer;
  10. new PRaiseTimeTimer[MAX_PLAYERS];
  11. new SRTFA;
  12. new PSRTFA[MAX_PLAYERS];
  13. new bool:RTTU;
  14. new bool:PRTTU[MAX_PLAYERS];
  15.  
  16. #define TIMES_GAME_TIME 0
  17. #define TIMES_REAL_TIME 1
  18. #define TIMES_WEEKS 0
  19. #define TIMES_DAYS 1
  20.  
  21. /*
  22. native SetDays(days);
  23. native SetHours(hours);
  24. native SetMinutes(minutes);
  25. native SetSeconds(seconds);
  26. native GetDays();
  27. native GetHours();
  28. native GetMinutes();
  29. native GetSeconds();
  30. native StartTime(type, week_type);
  31. native EndTime();
  32. native ResetTime();
  33. native SetPlayerDays(playerid, pdays)
  34. native SetPlayerHours(playerid, phours)
  35. native SetPlayerMinutes(playerid, pminutes)
  36. native SetPlayerSeconds(playerid, pseconds)
  37. native GetPlayerDays(playerid);
  38. native GetPlayerHours(playerid);
  39. native GetPlayerMinutes(playerid);
  40. native GetPlayerSeconds(playerid);
  41. native StartPlayerTime(playerid, ptype, pweek_type);
  42. native EndPlayerTime(playerid)
  43. native ResetPlayerTime(playerid);
  44. native SetRealTime();
  45. native SetPlayerRealTime(playerid);
  46. */
  47.  
  48. enum Times_HMS
  49. {
  50. Days,
  51. Hours,
  52. Minutes,
  53. Seconds
  54. }
  55. new Times_SMH[Times_HMS];
  56.  
  57. enum Times_PHMS
  58. {
  59. PDays,
  60. PHours,
  61. PMinutes,
  62. PSeconds
  63. }
  64. new Times_PSMH[MAX_PLAYERS][Times_PHMS];
  65.  
  66. stock SetDays(days)
  67. {
  68. return Times_SMH[Days] = days;
  69. }
  70.  
  71. stock SetHours(hours)
  72. {
  73. return Times_SMH[Hours] = hours;
  74. }
  75.  
  76. stock SetMinutes(minutes)
  77. {
  78. return Times_SMH[Minutes] = minutes;
  79. }
  80.  
  81. stock SetSeconds(seconds)
  82. {
  83. return Times_SMH[Seconds] = seconds;
  84. }
  85.  
  86. stock GetDays()
  87. {
  88. return Times_SMH[Days];
  89. }
  90.  
  91. stock GetHours()
  92. {
  93. return Times_SMH[Hours];
  94. }
  95.  
  96. stock GetMinutes()
  97. {
  98. return Times_SMH[Minutes];
  99. }
  100.  
  101. stock GetSeconds()
  102. {
  103. return Times_SMH[Seconds];
  104. }
  105.  
  106. stock StartTime(type, week)
  107. {
  108. if(RTTU == true) return 0;
  109. if(RTTU == false)
  110. {
  111. if(week == TIMES_WEEKS)
  112. {
  113. if(type == TIMES_GAME_TIME)
  114. {
  115. RTTU = true;
  116. RaiseTimeTimer = SetTimer("RaiseTimeS", 100, true);
  117. }
  118. if(type == TIMES_REAL_TIME)
  119. {
  120. RTTU = true;
  121. RaiseTimeTimer = SetTimer("RaiseTimeS", 1000, true);
  122. }
  123. }
  124. if(week == TIMES_DAYS)
  125. {
  126. if(type == TIMES_GAME_TIME)
  127. {
  128. RTTU = true;
  129. RaiseTimeTimer = SetTimer("RaiseTime", 100, true);
  130. }
  131. if(type == TIMES_REAL_TIME)
  132. {
  133. RTTU = true;
  134. RaiseTimeTimer = SetTimer("RaiseTime", 1000, true);
  135. }
  136. }
  137. }
  138. return 1;
  139. }
  140.  
  141. stock EndTime()
  142. {
  143. RTTU = false;
  144. KillTimer(SRTFA);
  145. KillTimer(RaiseTimeTimer);
  146. return 1;
  147. }
  148.  
  149. forward RaiseTime();
  150.  
  151. public RaiseTime()
  152. {
  153. Times_SMH[Seconds] ++;
  154. if(Times_SMH[Seconds] == 60)
  155. {
  156. Times_SMH[Seconds] = 0;
  157. Times_SMH[Minutes] ++;
  158. }
  159. if(Times_SMH[Minutes] == 60)
  160. {
  161. Times_SMH[Minutes] = 0;
  162. Times_SMH[Hours] ++;
  163. }
  164. if(Times_SMH[Hours] == 24)
  165. {
  166. Times_SMH[Hours] = 0;
  167. Times_SMH[Days] ++;
  168. }
  169. return 1;
  170. }
  171.  
  172. stock SetRealTime()
  173. {
  174. SRTFA = SetTimer("SetRealTimeForAll", 1000, true);
  175. return 1;
  176. }
  177.  
  178. stock SetPlayerRealTime(playerid)
  179. {
  180. PSRTFA[playerid] = SetTimerEx("PSetRealTimeForAll", 1000, true, "i", playerid);
  181. return 1;
  182. }
  183.  
  184. forward SetRealTimeForAll();
  185.  
  186. public SetRealTimeForAll()
  187. {
  188. for(new i = 0; i < GetMaxPlayers(); i ++)
  189. {
  190. SetPlayerTime(i, Times_SMH[Hours], Times_SMH[Minutes]);
  191. }
  192. return 1;
  193. }
  194.  
  195. forward PSetRealTimeForAll(playerid);
  196.  
  197. public PSetRealTimeForAll(playerid)
  198. {
  199. SetPlayerTime(playerid, Times_PSMH[playerid][PHours], Times_PSMH[playerid][PMinutes]);
  200. return 1;
  201. }
  202.  
  203. forward RaiseTimeS();
  204.  
  205. public RaiseTimeS()
  206. {
  207. Times_SMH[Seconds] ++;
  208. if(Times_SMH[Seconds] == 60)
  209. {
  210. Times_SMH[Seconds] = 0;
  211. Times_SMH[Minutes] ++;
  212. }
  213. if(Times_SMH[Minutes] == 60)
  214. {
  215. Times_SMH[Minutes] = 0;
  216. Times_SMH[Hours] ++;
  217. }
  218. if(Times_SMH[Hours] == 24)
  219. {
  220. Times_SMH[Hours] = 0;
  221. Times_SMH[Days] ++;
  222. }
  223. if(Times_SMH[Days] == 8)
  224. {
  225. Times_SMH[Days] = 1;
  226. }
  227. return 1;
  228. }
  229.  
  230. stock ResetTime()
  231. {
  232. Times_SMH[Days] = 0;
  233. Times_SMH[Hours] = 0;
  234. Times_SMH[Minutes] = 0;
  235. Times_SMH[Seconds] = 0;
  236. return 1;
  237. }
  238.  
  239. stock SetPlayerDays(playerid, pdays)
  240. {
  241. return Times_PSMH[playerid][PDays] = pdays;
  242. }
  243.  
  244. stock SetPlayerHours(playerid, phours)
  245. {
  246. return Times_PSMH[playerid][PHours] = phours;
  247. }
  248.  
  249. stock SetPlayerMinutes(playerid, pminutes)
  250. {
  251. return Times_PSMH[playerid][PMinutes] = pminutes;
  252. }
  253.  
  254. stock SetPlayerSeconds(playerid, pseconds)
  255. {
  256. return Times_PSMH[playerid][PSeconds] = pseconds;
  257. }
  258.  
  259. stock GetPlayerDays(playerid)
  260. {
  261. return Times_PSMH[playerid][PDays];
  262. }
  263.  
  264. stock GetPlayerHours(playerid)
  265. {
  266. return Times_PSMH[playerid][PHours];
  267. }
  268.  
  269. stock GetPlayerMinutes(playerid)
  270. {
  271. return Times_PSMH[playerid][PMinutes];
  272. }
  273.  
  274. stock GetPlayerSeconds(playerid)
  275. {
  276. return Times_PSMH[playerid][PSeconds];
  277. }
  278.  
  279. stock StartPlayerTime(playerid, ptype, pweek)
  280. {
  281. if(PRTTU[playerid] == true) return 0;
  282. if(PRTTU[playerid] == false)
  283. {
  284. if(pweek == TIMES_WEEKS)
  285. {
  286. if(ptype == TIMES_GAME_TIME)
  287. {
  288. PRTTU[playerid] = true;
  289. PRaiseTimeTimer[playerid] = SetTimerEx("PRaiseTimeS", 100, true, "i", playerid);
  290. }
  291. if(ptype == TIMES_REAL_TIME)
  292. {
  293. PRTTU[playerid] = true;
  294. PRaiseTimeTimer[playerid] = SetTimerEx("PRaiseTimeS", 1000, true, "i", playerid);
  295. }
  296. }
  297. if(pweek == TIMES_DAYS)
  298. {
  299. if(ptype == TIMES_GAME_TIME)
  300. {
  301. PRTTU[playerid] = true;
  302. PRaiseTimeTimer[playerid] = SetTimerEx("PRaiseTime", 100, true, "i", playerid);
  303. }
  304. if(ptype == TIMES_REAL_TIME)
  305. {
  306. PRTTU[playerid] = true;
  307. PRaiseTimeTimer[playerid] = SetTimerEx("PRaiseTime", 1000, true, "i", playerid);
  308. }
  309. }
  310. }
  311. return 1;
  312. }
  313.  
  314. stock EndPlayerTime(playerid)
  315. {
  316. PRTTU[playerid] = false;
  317. KillTimer(PSRTFA[playerid]);
  318. KillTimer(PRaiseTimeTimer[playerid]);
  319. return 1;
  320. }
  321.  
  322. forward PRaiseTime(playerid);
  323.  
  324. public PRaiseTime(playerid)
  325. {
  326. Times_PSMH[playerid][PSeconds] ++;
  327. if(Times_PSMH[playerid][PSeconds] == 60)
  328. {
  329. Times_PSMH[playerid][PSeconds] = 0;
  330. Times_PSMH[playerid][PMinutes] ++;
  331. }
  332. if(Times_PSMH[playerid][PMinutes] == 60)
  333. {
  334. Times_PSMH[playerid][PMinutes] = 0;
  335. Times_PSMH[playerid][PHours] ++;
  336. }
  337. if(Times_PSMH[playerid][PHours] == 24)
  338. {
  339. Times_PSMH[playerid][PHours] = 0;
  340. Times_PSMH[playerid][PDays] ++;
  341. }
  342. return 1;
  343. }
  344.  
  345. forward PRaiseTimeS(playerid);
  346.  
  347. public PRaiseTimeS(playerid)
  348. {
  349. Times_PSMH[playerid][PSeconds] ++;
  350. if(Times_PSMH[playerid][PSeconds] == 60)
  351. {
  352. Times_PSMH[playerid][PSeconds] = 0;
  353. Times_PSMH[playerid][PMinutes] ++;
  354. }
  355. if(Times_PSMH[playerid][PMinutes] == 60)
  356. {
  357. Times_PSMH[playerid][PMinutes] = 0;
  358. Times_PSMH[playerid][PHours] ++;
  359. }
  360. if(Times_PSMH[playerid][PHours] == 24)
  361. {
  362. Times_PSMH[playerid][PHours] = 0;
  363. Times_PSMH[playerid][PDays] ++;
  364. }
  365. if(Times_PSMH[playerid][PDays] == 8)
  366. {
  367. Times_PSMH[playerid][PDays] = 1;
  368. }
  369. return 1;
  370. }
  371.  
  372. stock ResetPlayerTime(playerid)
  373. {
  374. Times_PSMH[playerid][PDays] = 0;
  375. Times_PSMH[playerid][PHours] = 0;
  376. Times_PSMH[playerid][PMinutes] = 0;
  377. Times_PSMH[playerid][PSeconds] = 0;
  378. return 1;
  379. }
  380.  
  381. //Times by UltraScripter / / //////////////////////////////////////////
  382. //Times by UltraScripter / / //////////////////////////////////////////
Add Comment
Please, Sign In to add comment