Wrong day shown
#1

My problem is that it is displaying the wrong day. for eg. today is thursday but in the game it is displaying as monday.
And just cant figure it out. Anyone?

This is the code:
Код:
public settime(){
	new hour,minute,second;
	new string[256];
	gettime(hour,minute,second);
	if (minute <= 9){format(string,25,"%d:0%d",hour,minute);}
	else {format(string,25,"%d:%d",hour,minute);}
	TextDrawSetString(Clock,string);
	SetWorldTime(hour);
	new day, month, year;
	new weekday;
	getdate(day, month, year);
	weekday = GetWeekdayNum(day, month, year);
	if(weekday == 1){TextDrawSetString(WeekDayg,"Monday");}
	if(weekday == 2){TextDrawSetString(WeekDayg,"Tuesday");}
	if(weekday == 3){TextDrawSetString(WeekDayg,"Wednesday");}
	if(weekday == 4){TextDrawSetString(WeekDayg,"Thursday");}
	if(weekday == 5){TextDrawSetString(WeekDayg,"Friday");}
	if(weekday == 6){TextDrawSetString(WeekDayg,"Saturday");}
	if(weekday == 7){TextDrawSetString(WeekDayg,"Sunday");}
	return 1;
}

public GetWeekdayNum(d,m,y)
{
	m-=2;
	if(m<=0)
		{
		y--;
		m+=12;
		}
	new cen = y/100;
	y=getrem(y,100);
	new w = d + ((13*m-1)/5) + y + (y/4) + (cen/4) - 2*cen;
	w=getrem(w,7);
	if (w==0) w=7;
	return w-1;
}
Reply
#2

Is your server time equal on the real life time?
Reply
#3

pawn Код:
stock weekday(month, day, year)
{
    if (month <= 2)
    {
        month += 12;
        --year;
    }
    new
        j = year % 100,
        e = year / 100;
       
    return (day + (month + 1) * 26 / 10 + j + j / 4 + e / 4 - 2 * e) % 7;
}
pawn Код:
stock weekdayname(weekday)
{
    new
        szDayname[10];
       
    switch (weekday)
    {
        case 0: szDayname = "Saturday";
        case 1: szDayname = "Sunday";
        case 2: szDayname = "Monday";
        case 3: szDayname = "Tuesday";
        case 4: szDayname = "Wednesday";
        case 5: szDayname = "Thursday";
        case 6: szDayname = "Friday";
        default: szDayname = "N/A";
    }
    return szDayname;
}
pawn Код:
new day, month, year;
getdate(year, month, day);
TextDrawSetString(WeekDayg, weekdayname(weekday(Month, Day, Year)));
Reply
#4

@-Shifty- yes it is real time. Its just the days are incorrect
Reply
#5

Still need help please
Reply
#6

Is your server hosted on a VPS/Dedi? If so, the date might be set wrong on there.
Reply
#7

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Is your server hosted on a VPS/Dedi? If so, the date might be set wrong on there.
Nevertheless, he's used the getdate function incorrectly.

pawn Код:
getdate(day, month, year);
It should be:
pawn Код:
getdate(year, month, day);
@Blademaster680: Did you even try what I posted?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)