Advertisement
legodude

legodude

Jan 3rd, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 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. if(oldmonth!=month)
  108. {
  109. new bstr[30];
  110. format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
  111. TextDrawSetString(Date,bstr);
  112. }
  113. for(new i=0;i<=daysamonth[month-1]-1;i++)
  114. {
  115. format(str,sizeof(str),"%i",i+1);
  116. TextDrawSetString(xtxd[i+startdayformonth[month-1]-1],str);
  117. TextDrawColor(xtxd[i],0xFF0000FF);
  118. }
  119. for(new i=0;i<TDS;i++)
  120. {
  121. TextDrawColor(xtxd[i],0xFFFFFFFF);
  122. TextDrawColor(xtxd[day+startdayformonth[month-1]-2] ,0xFF0000FF);
  123. for(new j=0;j<MAX_PLAYERS;j++)
  124. {
  125. if(showing[j]==1)
  126. {
  127. TextDrawHideForPlayer(j,xtxd[i]);
  128. TextDrawHideForPlayer(j,Date);
  129. TextDrawShowForPlayer(j,xtxd[i]);
  130. TextDrawShowForPlayer(j,Date);
  131. }
  132. }
  133. }
  134. }
  135.  
  136. return 1;
  137. }
  138.  
  139. public OnPlayerSpawn(playerid)
  140. {
  141. ShowCalendar(playerid);
  142. return 1;
  143. }
  144.  
  145. public OnPlayerDeath(playerid,killerid,reason)
  146. {
  147. HideCalendar(playerid);
  148. return 1;
  149. }
  150.  
  151. MonthName(monthid)
  152. {
  153. new mn[10];
  154. switch(monthid)
  155. {
  156. case 1:format(mn,sizeof(mn),"January");
  157. case 2:format(mn,sizeof(mn),"February");
  158. case 3:format(mn,sizeof(mn),"March");
  159. case 4:format(mn,sizeof(mn),"April");
  160. case 5:format(mn,sizeof(mn),"May");
  161. case 6:format(mn,sizeof(mn),"June");
  162. case 7:format(mn,sizeof(mn),"July");
  163. case 8:format(mn,sizeof(mn),"August");
  164. case 9:format(mn,sizeof(mn),"September");
  165. case 10:format(mn,sizeof(mn),"October");
  166. case 11:format(mn,sizeof(mn),"November");
  167. case 12:format(mn,sizeof(mn),"December");
  168. }
  169. return mn;
  170. }
  171.  
  172. stock ShowCalendar(playerid)
  173. {
  174. for(new i=0;i<TDS;i++)
  175. {
  176. TextDrawShowForPlayer(playerid,xtxd[i]);
  177. }
  178. TextDrawShowForPlayer(playerid,background);
  179. TextDrawShowForPlayer(playerid,Date);
  180. TextDrawShowForPlayer(playerid,days);
  181. showing[playerid]=1;
  182. return 1;
  183. }
  184. stock HideCalendar(playerid)
  185. {
  186. for(new i=0;i<TDS;i++)
  187. {
  188. TextDrawHideForPlayer(playerid,xtxd[i]);
  189. }
  190. TextDrawHideForPlayer(playerid,background);
  191. TextDrawHideForPlayer(playerid,Date);
  192. TextDrawHideForPlayer(playerid,days);
  193. showing[playerid]=0;
  194. return 1;
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement