Advertisement
Guest User

Untitled

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