Advertisement
legodude

legodude

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