getdate help -
DetoNater - 24.12.2015
Actually I have the plan of giving doublescore in weekends, so guess I need an idea with getdate for finding weekends, hope you guys can help!!
Thanks,
OFF: Wishing you merry christmas!!
Re: getdate help -
sheeraz - 25.12.2015
new Year,Month,Day;
getdate(Year,Month,Day);
and to give something
if(Day == whateverday) // This Checks IF The Day , From Your Pc
{
give something Using Your Codes // like giveplayer money whatever
return 1; // return 1 is not really necessary ..

}
Re: getdate help -
DetoNater - 25.12.2015
Quote:
Originally Posted by sheeraz
new Year,Month,Day;
getdate(Year,Month,Day);
and to give something
if(Day == whateverday) // This Checks IF The Day , From Your Pc
{
give something Using Your Codes // like giveplayer money whatever
return 1; // return 1 is not really necessary .. 
}
|
Yup i know about the getdate thing, but should I give everyweekend date?? for date params?? any other optimized way of processing it??
Re: getdate help -
Vince - 25.12.2015
Insanely difficult to achieve. Consider parsing it through another language. If you already use MySQL you can get it using
DAYOFWEEK() or
WEEKDAY(). Otherwise you can send a HTTP request to a PHP page that outputs the result of
date().
Re: getdate help -
Tamy - 25.12.2015
This can be possible if you fill an array every month or so (manually) with the Sat/Sun days using calender like this, 'MonthDays' array has all the Sat/Sun days in the month of January, 16.
Код:
new MonthDays[10] = {"2", "3", "9", "10", "16", "17", "23", "24", "30", "31");
stock IsWeekend()
{
new dd, mm, yy;
getdate(yy, mm, dd);
for(new i=0; i<10; i++)
{
if(MonthDays[i] == dd)
{
return true;
}
}
return false;
}
Re: getdate help -
ball - 25.12.2015
There is function for this, I have absolutely no idea how it works
Код:
GetWeekDay(day=0, month=0, year=0)
{
if(!day) getdate(year, month, day);
new j, e;
if(month <= 2)
{
month += 12;
--year;
}
j = year % 100;
e = year / 100;
switch((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)
{
case 0: return 6; //Saturday
case 1: return 7; //Sunday
case 2: return 1; //Monday
case 3: return 2; //Tuesday
case 4: return 3; //Wednesday
case 5: return 4; //Thursday
case 6: return 5; //Friday
}
return -1;
}
Re: getdate help -
DetoNater - 25.12.2015
i have an idea
pawn Код:
dsweekendcheck()
{
dsweekendtime++;
if(dsweekendtime >= 518400 && dsweekendtime <= 604800) // 518400 is 6th day and 604800 is 7th day which incl Saturday and Sunday, here monday is starting of week, which is day 1
{
dsweekend = 1;
}
else dsweekend = 0;
if(dsweekendtime == 604800)
{
dsweekendtime = 0;
}
}
i will start the gamemode on monday sharp 12:00am, the dsweekendtime will get advancing, but a doubt there's a restart of gamemode everyday, so the dsweekendtime will reset right? can i save the advancing time in mysql and fetch back when it starts back??
P.S: I use the dsweekend++ in task globaltimer[1000]()
Re: getdate help -
CrazyChoco - 25.12.2015
Why not use a timer which is executed every day and then disablef by a new timer? It's pure math
Re: getdate help -
DetoNater - 25.12.2015
Quote:
Originally Posted by CrazyChoco
Why not use a timer which is executed every day and then disablef by a new timer? It's pure math
|
Explain please!
Re: getdate help -
Vince - 25.12.2015
Quote:
Originally Posted by DetoNater
i will start the gamemode on monday sharp 12:00am, the dsweekendtime will get advancing, but a doubt there's a restart of gamemode everyday, so the dsweekendtime will reset right? can i save the advancing time in mysql and fetch back when it starts back??
P.S: I use the dsweekend++ in task globaltimer[1000]()
|
Timers are not at all accurate, especially over longer periods. They're roughly 20% off. Plus they're CPU intensive. You mention saving in MySQL so what's wrong with using the already inbuilt functions that it offers (see my previous post)?
PHP код:
SELECT WEEKDAY(CURDATE());
Could hardly be easier.