Advertisement
EnzoMetlc

[FilterScript] Calendary [zTime.inc]

Dec 14th, 2016
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.57 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ZCMD>
  3.  
  4.  
  5.  
  6. static Text:BOX[2];
  7. static Text:IMG[2];
  8. static Text:Date[2];
  9. static Text:Days;
  10. static Text:NumberDate[7];
  11. static Text:MiniCalendary[2];
  12.  
  13. static SyncTimer;
  14.  
  15. static const DayName[][] = {"Moday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  16. static const MonthName[][] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. print("\n*************************************");
  21. print("* Calendary System - By Swedky 2014 *");
  22. print("*************************************\n");
  23.  
  24.  
  25. /* Calendary boxs */
  26. BOX[0] = TextDrawCreate(230.000000, 129.000000, "_");
  27. TextDrawBackgroundColor(BOX[0], 255);
  28. TextDrawFont(BOX[0], 1);
  29. TextDrawLetterSize(BOX[0], 1.301000, 17.100000);
  30. TextDrawColor(BOX[0], -1);
  31. TextDrawSetOutline(BOX[0], 0);
  32. TextDrawSetProportional(BOX[0], 1);
  33. TextDrawSetShadow(BOX[0], 1);
  34. TextDrawUseBox(BOX[0], 1);
  35. TextDrawBoxColor(BOX[0], 100);
  36. TextDrawTextSize(BOX[0], 31.000000, 0.000000);
  37.  
  38. BOX[1] = TextDrawCreate(230.000000, 174.000000, "_");
  39. TextDrawBackgroundColor(BOX[1], 255);
  40. TextDrawFont(BOX[1], 1);
  41. TextDrawLetterSize(BOX[1], 0.500000, -0.900000);
  42. TextDrawColor(BOX[1], -1);
  43. TextDrawSetOutline(BOX[1], 0);
  44. TextDrawSetProportional(BOX[1], 1);
  45. TextDrawSetShadow(BOX[1], 1);
  46. TextDrawUseBox(BOX[1], 1);
  47. TextDrawBoxColor(BOX[1], -10092374);
  48. TextDrawTextSize(BOX[1], 31.000000, 0.000000);
  49.  
  50. IMG[0] = TextDrawCreate(25.000000, 121.000000, "-");
  51. TextDrawBackgroundColor(IMG[0], 255);
  52. TextDrawFont(IMG[0], 1);
  53. TextDrawLetterSize(IMG[0], 14.890000, 1.000000);
  54. TextDrawColor(IMG[0], -1);
  55. TextDrawSetOutline(IMG[0], 1);
  56. TextDrawSetProportional(IMG[0], 1);
  57.  
  58. IMG[1] = TextDrawCreate(39.000000, 116.000000, "c c c c c c c c c c c c c c c");
  59. TextDrawBackgroundColor(IMG[1], 255);
  60. TextDrawFont(IMG[1], 1);
  61. TextDrawLetterSize(IMG[1], 0.401000, 1.800000);
  62. TextDrawColor(IMG[1], -1);
  63. TextDrawSetOutline(IMG[1], 1);
  64. TextDrawSetProportional(IMG[1], 1);
  65.  
  66.  
  67. /* Date and hour */
  68. Date[0] = TextDrawCreate(133.000000, 129.000000, "_");
  69. TextDrawAlignment(Date[0], 2);
  70. TextDrawBackgroundColor(Date[0], 255);
  71. TextDrawFont(Date[0], 2);
  72. TextDrawLetterSize(Date[0], 0.930000, 2.700000);
  73. TextDrawColor(Date[0], -1);
  74. TextDrawSetOutline(Date[0], 1);
  75. TextDrawSetProportional(Date[0], 1);
  76.  
  77. Date[1] = TextDrawCreate(133.000000, 152.000000, "_");
  78. TextDrawAlignment(Date[1], 2);
  79. TextDrawBackgroundColor(Date[1], 255);
  80. TextDrawFont(Date[1], 1);
  81. TextDrawLetterSize(Date[1], 0.390000, 1.400000);
  82. TextDrawColor(Date[1], -1);
  83. TextDrawSetOutline(Date[1], 1);
  84. TextDrawSetProportional(Date[1], 1);
  85.  
  86.  
  87. /* Days */
  88. Days = TextDrawCreate(131.000000, 171.000000, "M T W T F ~r~~h~S S");
  89. TextDrawAlignment(Days, 2);
  90. TextDrawBackgroundColor(Days, 255);
  91. TextDrawFont(Days, 2);
  92. TextDrawLetterSize(Days, 0.469999, 1.799998);
  93. TextDrawColor(Days, -1);
  94. TextDrawSetOutline(Days, 1);
  95. TextDrawSetProportional(Days, 0);
  96.  
  97.  
  98. /* Day number of the week */
  99. NumberDate[0] = TextDrawCreate(50.000000, 195.000000, "_");
  100. TextDrawAlignment(NumberDate[0], 2);
  101. TextDrawBackgroundColor(NumberDate[0], 255);
  102. TextDrawFont(NumberDate[0], 1);
  103. TextDrawLetterSize(NumberDate[0], 0.309998, 1.600000);
  104. TextDrawColor(NumberDate[0], -1);
  105. TextDrawSetOutline(NumberDate[0], 1);
  106. TextDrawSetProportional(NumberDate[0], 1);
  107.  
  108. NumberDate[1] = TextDrawCreate(78.000000, 195.000000, "_");
  109. TextDrawAlignment(NumberDate[1], 2);
  110. TextDrawBackgroundColor(NumberDate[1], 255);
  111. TextDrawFont(NumberDate[1], 1);
  112. TextDrawLetterSize(NumberDate[1], 0.309998, 1.600000);
  113. TextDrawColor(NumberDate[1], -1);
  114. TextDrawSetOutline(NumberDate[1], 1);
  115. TextDrawSetProportional(NumberDate[1], 1);
  116.  
  117. NumberDate[2] = TextDrawCreate(105.000000, 195.000000, "_");
  118. TextDrawAlignment(NumberDate[2], 2);
  119. TextDrawBackgroundColor(NumberDate[2], 255);
  120. TextDrawFont(NumberDate[2], 1);
  121. TextDrawLetterSize(NumberDate[2], 0.309998, 1.600000);
  122. TextDrawColor(NumberDate[2], -1);
  123. TextDrawSetOutline(NumberDate[2], 1);
  124. TextDrawSetProportional(NumberDate[2], 1);
  125.  
  126. NumberDate[3] = TextDrawCreate(130.000000, 195.000000, "_");
  127. TextDrawAlignment(NumberDate[3], 2);
  128. TextDrawBackgroundColor(NumberDate[3], 255);
  129. TextDrawFont(NumberDate[3], 1);
  130. TextDrawLetterSize(NumberDate[3], 0.309998, 1.600000);
  131. TextDrawColor(NumberDate[3], -1);
  132. TextDrawSetOutline(NumberDate[3], 1);
  133. TextDrawSetProportional(NumberDate[3], 1);
  134.  
  135. NumberDate[4] = TextDrawCreate(157.000000, 195.000000, "_");
  136. TextDrawAlignment(NumberDate[4], 2);
  137. TextDrawBackgroundColor(NumberDate[4], 255);
  138. TextDrawFont(NumberDate[4], 1);
  139. TextDrawLetterSize(NumberDate[4], 0.309998, 1.600000);
  140. TextDrawColor(NumberDate[4], -1);
  141. TextDrawSetOutline(NumberDate[4], 1);
  142. TextDrawSetProportional(NumberDate[4], 1);
  143.  
  144. NumberDate[5] = TextDrawCreate(183.000000, 195.000000, "_");
  145. TextDrawAlignment(NumberDate[5], 2);
  146. TextDrawBackgroundColor(NumberDate[5], 255);
  147. TextDrawFont(NumberDate[5], 1);
  148. TextDrawLetterSize(NumberDate[5], 0.309998, 1.600000);
  149. TextDrawColor(NumberDate[5], -1);
  150. TextDrawSetOutline(NumberDate[5], 1);
  151. TextDrawSetProportional(NumberDate[5], 1);
  152.  
  153. NumberDate[6] = TextDrawCreate(209.000000, 195.000000, "_");
  154. TextDrawAlignment(NumberDate[6], 2);
  155. TextDrawBackgroundColor(NumberDate[6], 255);
  156. TextDrawFont(NumberDate[6], 1);
  157. TextDrawLetterSize(NumberDate[6], 0.309998, 1.600000);
  158. TextDrawColor(NumberDate[6], -1);
  159. TextDrawSetOutline(NumberDate[6], 1);
  160. TextDrawSetProportional(NumberDate[6], 1);
  161.  
  162.  
  163. /* Mini-calendary */
  164. MiniCalendary[0] = TextDrawCreate(163.000000, 132.000000, "_");
  165. TextDrawBackgroundColor(MiniCalendary[0], 255);
  166. TextDrawFont(MiniCalendary[0], 1);
  167. TextDrawLetterSize(MiniCalendary[0], -0.300000, 3.400000);
  168. TextDrawColor(MiniCalendary[0], -1);
  169. TextDrawSetOutline(MiniCalendary[0], 0);
  170. TextDrawSetProportional(MiniCalendary[0], 1);
  171. TextDrawSetShadow(MiniCalendary[0], 1);
  172. TextDrawUseBox(MiniCalendary[0], 1);
  173. TextDrawBoxColor(MiniCalendary[0], 25700);
  174. TextDrawTextSize(MiniCalendary[0], 32.000000, 0.000000);
  175.  
  176. MiniCalendary[1] = TextDrawCreate(98.000000, 130.000000, "_");
  177. TextDrawAlignment(MiniCalendary[1], 2);
  178. TextDrawBackgroundColor(MiniCalendary[1], 255);
  179. TextDrawFont(MiniCalendary[1], 2);
  180. TextDrawLetterSize(MiniCalendary[1], 0.280000, 1.800000);
  181. TextDrawColor(MiniCalendary[1], -1);
  182. TextDrawSetOutline(MiniCalendary[1], 1);
  183. TextDrawSetProportional(MiniCalendary[1], 1);
  184.  
  185.  
  186. new sec, year, month, day, str[25];
  187. gettime(sec, sec, sec);
  188. SyncTimer = SetTimer("UpdateCalendary", (60 - sec) * 1000, true);
  189.  
  190. getdate(year, month, day);
  191. format(str, sizeof(str), "%s, %i de %s", DayName[GetDayOfWeek(day, month, year) - 1], day, MonthName[month - 1]);
  192. TextDrawSetString(Date[1], str);
  193. UpdateDate();
  194. return 1;
  195. }
  196.  
  197.  
  198. CMD:calendary(playerid)
  199. {
  200. TextDrawHideForPlayer(playerid, MiniCalendary[0]);
  201. TextDrawHideForPlayer(playerid, MiniCalendary[1]);
  202.  
  203. TextDrawShowForPlayer(playerid, BOX[0]);
  204. TextDrawShowForPlayer(playerid, BOX[1]);
  205. TextDrawShowForPlayer(playerid, IMG[0]);
  206. TextDrawShowForPlayer(playerid, IMG[1]);
  207. TextDrawShowForPlayer(playerid, Date[0]);
  208. TextDrawShowForPlayer(playerid, Date[1]);
  209. TextDrawShowForPlayer(playerid, Days);
  210.  
  211. for(new i = 0; i < 7; i++) TextDrawShowForPlayer(playerid, NumberDate[i]);
  212. return 1;
  213. }
  214.  
  215.  
  216. CMD:mini(playerid)
  217. {
  218. TextDrawHideForPlayer(playerid, BOX[0]);
  219. TextDrawHideForPlayer(playerid, BOX[1]);
  220. TextDrawHideForPlayer(playerid, IMG[0]);
  221. TextDrawHideForPlayer(playerid, IMG[1]);
  222. TextDrawHideForPlayer(playerid, Date[0]);
  223. TextDrawHideForPlayer(playerid, Date[1]);
  224. TextDrawHideForPlayer(playerid, Days);
  225.  
  226. for(new i = 0; i < 7; i++) TextDrawHideForPlayer(playerid, NumberDate[i]);
  227.  
  228. TextDrawShowForPlayer(playerid, MiniCalendary[0]);
  229. TextDrawShowForPlayer(playerid, MiniCalendary[1]);
  230. return 1;
  231. }
  232.  
  233.  
  234.  
  235.  
  236. /* Funciones */
  237. stock UpdateDate()
  238. {
  239. new st, month, year, day, max_days[2], str[128], temp[3][10];
  240.  
  241. getdate(year, month, day);
  242. st = GetDayOfWeek(1, month, year) - 1; // Primer día del mes.
  243. max_days[0] = ((month - 1) != 0) ? (GetMaxDaysOfMonth(year, month - 1)) : (GetMaxDaysOfMonth(year, 12));
  244. max_days[1] = GetMaxDaysOfMonth(year, month);
  245.  
  246. new i, week1, week2, week5, week6;
  247. for(i = 1; i <= 7; i++)
  248. {
  249. week1 = (i <= st) ? (max_days[0] - st + i) : (i - st);
  250. week2 = (week1 <= 7) ? (week1 + 7) : ((week1 + 7) - max_days[0]);
  251. week5 = ((week2 + 21) <= max_days[1]) ? (week2 + 21) : ((week2 + 21) - max_days[1]);
  252. week6 = ((week5 + 7) <= max_days[1]) ? (week5 + 7) : ((week5 + 7) - max_days[1]);
  253.  
  254. if(week1 >= 25) format(temp[0], 10, "~b~~h~%i", week1);
  255. else format(temp[0], 3, "%i", week1);
  256.  
  257. if(week5 <= 15) format(temp[1], 10, "~b~~h~%i", week5);
  258. else format(temp[1], 3, "%i", week5);
  259.  
  260. if(week6 <= 15) format(temp[2], 10, "~b~~h~%i", week6);
  261. else format(temp[2], 3, "%i", week6);
  262.  
  263. format(str, sizeof(str), "%s~w~~n~%i~n~%i~n~%i~n~%s~n~%s", temp[0], week2, week2 + 7, week2 + 14, temp[1], temp[2]);
  264. TextDrawSetString(NumberDate[i - 1], str);
  265. }
  266. return 1;
  267. }
  268.  
  269.  
  270. stock GetMaxDaysOfMonth(year, month)
  271. {
  272. if(month == 2) return ((year % 4) == 0) ? (29) : (28);
  273.  
  274. new const MaxDayOfMonth[12] = {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  275. return MaxDayOfMonth[month - 1];
  276. }
  277.  
  278.  
  279.  
  280. /* GetDayOfWeek (zTime.inc - by _Zume, edited by me) */
  281. stock GetDayOfWeek(day, month, year)
  282. {
  283. new d_[4];
  284.  
  285. d_[0] = (14 - month) / 12;
  286. d_[2] = year - d_[0];
  287. d_[1] = month + (12 * d_[0]) - 2;
  288. d_[3] = (day + d_[2] + (d_[2] / 4) - (d_[2] / 100) + (d_[2] / 400) + (31 * d_[1]) / 12) % 7;
  289. if(d_[3] == 0) d_[3] = 7;
  290. return d_[3];
  291. }
  292.  
  293.  
  294.  
  295.  
  296. //-------
  297. forward UpdateCalendary();
  298. public UpdateCalendary()
  299. {
  300. new hour, minute, second, string[35];
  301. new year, month, day;
  302.  
  303. getdate(year, month, day);
  304. gettime(hour, minute, second);
  305. format(string, 8, "%i:%02i", hour, minute);
  306. TextDrawSetString(Date[0], string);
  307.  
  308. /* Update mini-calendary */
  309. new dayname[4];
  310. format(dayname, 4, "%s", DayName[GetDayOfWeek(day, month, year) - 1]);
  311. format(string, sizeof(string), "~r~%i:%i~n~~w~%02i/%02i/%i - %s", hour, minute, day, month, year, dayname);
  312. TextDrawSetString(MiniCalendary[1], string);
  313.  
  314.  
  315. if(second != 0) // Sinc timer
  316. {
  317. KillTimer(SyncTimer);
  318. SyncTimer = SetTimer("UpdateCalendary", (60 - second) * 1000, true);
  319. }
  320. if(hour == 0) // Update date
  321. {
  322. new str[25];
  323. format(str, sizeof(str), "%s, %i de %s", DayName[GetDayOfWeek(day, month, year) - 1], day, MonthName[month - 1]);
  324. TextDrawSetString(Date[1], str);
  325. }
  326. if(day == 0) UpdateDate(); // Update calendary
  327. return 1;
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement