getdate help
#1

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!!
Reply
#2

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 ..
}
Reply
#3

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??
Reply
#4

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().
Reply
#5

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;
}
Reply
#6

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; 
}
Reply
#7

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]()
Reply
#8

Why not use a timer which is executed every day and then disablef by a new timer? It's pure math
Reply
#9

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!
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)