RealTime and Hour [+REP]
#5

People these days, too lazy to apply the fix..
pawn Код:
//Whereever you want it
new Hour, Minutes, Seconds; gettime(hour, minute, Seconds);
if(GetDayName() == 2 && Hour == 12 && !Minutes && !Seconds) pInfo[playerid][pAdminLevel] = 0;

stock GetDayName(d=0,m=0,y=0) {
    /*
    0=Invalid date
    1=Sunday
    2=Monday
    ...
    7=Saturday
    */

    if(d==0&&m==0&&y==0) { //set to today if no values passed
        getdate(y, m, d);
    }

    new month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
        i;

    if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
        month[1] = 29;

    if (y < 1900 || m < 1 || m > 12 || d < 1 || d > month[m - 1])
        return 0;

    for (i = 1900; i < y; i++) {
        if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0))
            d += 366;
        else
            d += 365;
    }

    for (i = 0; i < m - 1; i++) {
        d += month[i];
    }

    return d%7+1;
}
Reply


Messages In This Thread
RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:06
Re: RealTime and Hour [+REP] - by Kaperstone - 20.01.2015, 13:14
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:23
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:42
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:52
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:54
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:59
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 14:02
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 14:06
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 14:09

Forum Jump:


Users browsing this thread: 1 Guest(s)