Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #define CALENDAR_X 470.0
- #define CALENDAR_Y 360.0
- #define TDS 42
- // 1 2 3 4 5 6 7 8 9 10 11 12
- new daysamonth[12] = {31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
- new startdayformonth[12] = {6 , 2 , 2 , 5 , 7 , 3 , 5 , 1 , 4 , 6 , 2 , 4 };
- new year,month,day,hour,minute,second;
- new Text:xtxd[TDS];
- new Text:background;
- new Text:Date;
- new showing[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- new str[3];
- new bstr[30];
- format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
- background = TextDrawCreate(460.0,350.0,"_");
- Date = TextDrawCreate(460.0,350.0,bstr);
- TextDrawLetterSize(Date, 0.3 ,1);
- TextDrawUseBox(background, 1);
- TextDrawTextSize(background,615.0,170.0);
- TextDrawBoxColor(background,0x000000AA);
- TextDrawLetterSize(background, 2.0 ,8.5);
- new count=0;
- new vcount=0;
- getdate(year,month,day);
- gettime(hour,minute,second);
- printf("INIT: %i/%i/%i %i:%i.%i",year,month,day,hour,minute,second);
- for(new i=0;i<TDS;i++)
- {
- if(count==7)
- {
- count=0;
- vcount++;
- }
- xtxd[i]=TextDrawCreate(CALENDAR_X+count*20.0,CALENDAR_Y+vcount*10.0,"_");
- TextDrawColor(xtxd[i],0xFFFFFFFF);
- TextDrawColor(xtxd[day+startdayformonth[month-1]-2] ,0xFF0000FF);
- TextDrawUseBox(xtxd[i], 0);
- TextDrawLetterSize(xtxd[i],0.3,1.0);
- TextDrawTextSize(xtxd[i],20.0,10.0);
- TextDrawFont(xtxd[i], 2);
- TextDrawSetShadow(xtxd[i],0);
- TextDrawSetOutline(xtxd[i],1);
- count++;
- }
- for(new i=0;i<=daysamonth[month-1]-1;i++)
- {
- format(str,sizeof(str),"%i",i+1);
- TextDrawSetString(xtxd[i+startdayformonth[month-1]-1],str);
- TextDrawColor(xtxd[i],0xFF0000FF);
- }
- SetTimer("Update",30000,true);
- Update();
- return 1;
- }
- public OnFilterScriptExit()
- {
- TextDrawHideForAll(Date);
- TextDrawDestroy(Date);
- TextDrawHideForAll(background);
- TextDrawDestroy(background);
- getdate(year,month,day);
- gettime(hour,minute,second);
- printf("EXIT: %i/%i/%i %i:%i.%i",year,month,day,hour,minute,second);
- for(new i=0;i<TDS;i++)
- {
- TextDrawHideForAll(xtxd[i]);
- TextDrawDestroy(xtxd[i]);
- }
- return 1;
- }
- forward Update();
- public Update()
- {
- new str[3];
- new oldyear,oldmonth,oldday,oldhour,oldminute;
- getdate(year,month,day);
- gettime(hour,minute,second);
- if(oldhour!=hour||oldminute!=minute)
- {
- new bstr[30];
- format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
- TextDrawSetString(Date,bstr);
- }
- if(oldyear!=year||oldmonth!=month||oldday!=day)
- {
- if(oldmonth!=month)
- {
- new bstr[30];
- format(bstr,sizeof(bstr),"%s %i - %i:%i",MonthName(month),year,hour,minute);
- TextDrawSetString(Date,bstr);
- }
- for(new i=0;i<=daysamonth[month-1]-1;i++)
- {
- format(str,sizeof(str),"%i",i+1);
- TextDrawSetString(xtxd[i+startdayformonth[month-1]-1],str);
- TextDrawColor(xtxd[i],0xFF0000FF);
- }
- for(new i=0;i<TDS;i++)
- {
- TextDrawColor(xtxd[i],0xFFFFFFFF);
- TextDrawColor(xtxd[day+startdayformonth[month-1]-2] ,0xFF0000FF);
- for(new j=0;j<MAX_PLAYERS;j++)
- {
- if(showing[j]==1)
- {
- TextDrawHideForPlayer(j,xtxd[i]);
- TextDrawHideForPlayer(j,Date);
- TextDrawShowForPlayer(j,xtxd[i]);
- TextDrawShowForPlayer(j,Date);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- ShowCalendar(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid,killerid,reason)
- {
- HideCalendar(playerid);
- return 1;
- }
- MonthName(monthid)
- {
- new mn[10];
- switch(monthid)
- {
- case 1:format(mn,sizeof(mn),"January");
- case 2:format(mn,sizeof(mn),"February");
- case 3:format(mn,sizeof(mn),"March");
- case 4:format(mn,sizeof(mn),"April");
- case 5:format(mn,sizeof(mn),"May");
- case 6:format(mn,sizeof(mn),"June");
- case 7:format(mn,sizeof(mn),"July");
- case 8:format(mn,sizeof(mn),"August");
- case 9:format(mn,sizeof(mn),"September");
- case 10:format(mn,sizeof(mn),"October");
- case 11:format(mn,sizeof(mn),"November");
- case 12:format(mn,sizeof(mn),"December");
- }
- return mn;
- }
- stock ShowCalendar(playerid)
- {
- for(new i=0;i<TDS;i++)
- {
- TextDrawShowForPlayer(playerid,xtxd[i]);
- }
- TextDrawShowForPlayer(playerid,background);
- TextDrawShowForPlayer(playerid,Date);
- showing[playerid]=1;
- return 1;
- }
- stock HideCalendar(playerid)
- {
- for(new i=0;i<TDS;i++)
- {
- TextDrawHideForPlayer(playerid,xtxd[i]);
- }
- TextDrawHideForPlayer(playerid,background);
- TextDrawHideForPlayer(playerid,Date);
- showing[playerid]=0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement