Advertisement
legodude

legodude

Jan 4th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #define CALENDAR_X 470.0
  6. #define CALENDAR_Y 360.0
  7. #define TDS 42
  8. // 1 2 3 4 5 6 7 8 9 10 11 12
  9. new daysamonth[12] = {31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
  10. new startdayformonth[12] = {6 , 2 , 2 , 5 , 7 , 3 , 5 , 1 , 4 , 6 , 2 , 4 };
  11. new year,month,day,hour,minute,second;
  12. new Text:xtxd[TDS];
  13. new Text:background;
  14. new Text:Date;
  15. new showing[MAX_PLAYERS];
  16. new Text:days;
  17. public OnFilterScriptInit()
  18. {
  19. new str[3];
  20. new bstr[30];
  21. format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
  22. background = TextDrawCreate(460.0,340.0,"_");
  23. Date = TextDrawCreate(460.0,340.0,bstr);
  24. TextDrawLetterSize(Date, 0.3 ,1);
  25.  
  26. TextDrawUseBox(background, 1);
  27. TextDrawTextSize(background,615.0,200.0);
  28. TextDrawBoxColor(background,0x000000AA);
  29. TextDrawLetterSize(background, 2.0 ,9.5);
  30.  
  31. days = TextDrawCreate(460.0,350.0,"Mon Tue Wed Thu Fri Sat Sun");
  32. TextDrawLetterSize(days, 0.29 ,1);
  33. TextDrawColor(days,0x333333AA);
  34. new count=0;
  35. new vcount=0;
  36. getdate(year,month,day);
  37. gettime(hour,minute,second);
  38. printf("INIT: %i/%i/%i %i:%i.%i",year,month,day,hour,minute,second);
  39. for(new i=0;i<TDS;i++)
  40. {
  41. if(count==7)
  42. {
  43. count=0;
  44. vcount++;
  45. }
  46. xtxd[i]=TextDrawCreate(CALENDAR_X+count*20.0,CALENDAR_Y+vcount*10.0,"_");
  47. TextDrawColor(xtxd[i],0xFFFFFFFF);
  48. TextDrawColor(xtxd[day+startdayformonth[month-1]-2] ,0xFF0000FF);
  49. TextDrawUseBox(xtxd[i], 0);
  50. TextDrawLetterSize(xtxd[i],0.3,1.0);
  51. TextDrawTextSize(xtxd[i],20.0,10.0);
  52. TextDrawFont(xtxd[i], 2);
  53. TextDrawSetShadow(xtxd[i],0);
  54. TextDrawSetOutline(xtxd[i],1);
  55. count++;
  56. }
  57. for(new i=0;i<=daysamonth[month-1]-1;i++)
  58. {
  59. format(str,sizeof(str),"%i",i+1);
  60. TextDrawSetString(xtxd[i+startdayformonth[month-1]-1],str);
  61. TextDrawColor(xtxd[i],0xFF0000FF);
  62. }
  63. SetTimer("Update",30000,true);
  64. Update();
  65. for(new i;i<MAX_PLAYERS;i++)
  66. {
  67. ShowCalendar(i);
  68. }
  69. return 1;
  70. }
  71.  
  72. public OnFilterScriptExit()
  73. {
  74. TextDrawHideForAll(Date);
  75. TextDrawDestroy(Date);
  76. TextDrawHideForAll(background);
  77. TextDrawDestroy(background);
  78. TextDrawHideForAll(days);
  79. TextDrawDestroy(days);
  80. getdate(year,month,day);
  81. gettime(hour,minute,second);
  82. printf("EXIT: %i/%i/%i %i:%i.%i",year,month,day,hour,minute,second);
  83. for(new i=0;i<TDS;i++)
  84. {
  85. TextDrawHideForAll(xtxd[i]);
  86. TextDrawDestroy(xtxd[i]);
  87. }
  88. return 1;
  89. }
  90.  
  91. forward Update();
  92.  
  93. public Update()
  94. {
  95. new str[3];
  96. new oldyear,oldmonth,oldday,oldhour,oldminute;
  97. getdate(year,month,day);
  98. gettime(hour,minute,second);
  99. if(oldhour!=hour||oldminute!=minute)
  100. {
  101. new bstr[30];
  102. format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
  103. TextDrawSetString(Date,bstr);
  104. }
  105. if(oldyear!=year||oldmonth!=month||oldday!=day)
  106. {
  107. for(new i;i<TDS;i++)
  108. {
  109. TextDrawSetString(xtxd[i],"_");
  110. }
  111. if(oldmonth!=month)
  112. {
  113. valstr(str,minute);
  114. new bstr[30];
  115. if(strlen(str)==2)
  116. {
  117. format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
  118. }
  119. else if(strlen(str)==1)
  120. {
  121. format(bstr,sizeof(bstr),"%s %i - %i:0%i",MonthName(month),year,hour,minute);
  122. }
  123. TextDrawSetString(Date,bstr);
  124. }
  125. for(new i=0;i<=daysamonth[month-1]-1;i++)
  126. {
  127. format(str,sizeof(str),"%i",i+1);
  128. TextDrawSetString(xtxd[i+startdayformonth[month-1]-1],str);
  129. TextDrawColor(xtxd[i],0xFF0000FF);
  130. }
  131. for(new i=0;i<TDS;i++)
  132. {
  133. TextDrawColor(xtxd[i],0xFFFFFFFF);
  134. TextDrawColor(xtxd[day+startdayformonth[month-1]-2] ,0xFF0000FF);
  135. for(new j=0;j<MAX_PLAYERS;j++)
  136. {
  137. if(showing[j]==1)
  138. {
  139. TextDrawHideForPlayer(j,xtxd[i]);
  140. TextDrawHideForPlayer(j,Date);
  141. TextDrawShowForPlayer(j,xtxd[i]);
  142. TextDrawShowForPlayer(j,Date);
  143. }
  144. }
  145. }
  146. }
  147.  
  148. return 1;
  149. }
  150.  
  151. public OnPlayerSpawn(playerid)
  152. {
  153. ShowCalendar(playerid);
  154. return 1;
  155. }
  156.  
  157. public OnPlayerDeath(playerid,killerid,reason)
  158. {
  159. HideCalendar(playerid);
  160. return 1;
  161. }
  162.  
  163. MonthName(monthid)
  164. {
  165. new mn[10];
  166. switch(monthid)
  167. {
  168. case 1:format(mn,sizeof(mn),"January");
  169. case 2:format(mn,sizeof(mn),"February");
  170. case 3:format(mn,sizeof(mn),"March");
  171. case 4:format(mn,sizeof(mn),"April");
  172. case 5:format(mn,sizeof(mn),"May");
  173. case 6:format(mn,sizeof(mn),"June");
  174. case 7:format(mn,sizeof(mn),"July");
  175. case 8:format(mn,sizeof(mn),"August");
  176. case 9:format(mn,sizeof(mn),"September");
  177. case 10:format(mn,sizeof(mn),"October");
  178. case 11:format(mn,sizeof(mn),"November");
  179. case 12:format(mn,sizeof(mn),"December");
  180. }
  181. return mn;
  182. }
  183.  
  184. stock ShowCalendar(playerid)
  185. {
  186. for(new i=0;i<TDS;i++)
  187. {
  188. TextDrawShowForPlayer(playerid,xtxd[i]);
  189. }
  190. TextDrawShowForPlayer(playerid,background);
  191. TextDrawShowForPlayer(playerid,Date);
  192. TextDrawShowForPlayer(playerid,days);
  193. showing[playerid]=1;
  194. return 1;
  195. }
  196. stock HideCalendar(playerid)
  197. {
  198. for(new i=0;i<TDS;i++)
  199. {
  200. TextDrawHideForPlayer(playerid,xtxd[i]);
  201. }
  202. TextDrawHideForPlayer(playerid,background);
  203. TextDrawHideForPlayer(playerid,Date);
  204. TextDrawHideForPlayer(playerid,days);
  205. showing[playerid]=0;
  206. return 1;
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement