2015 may bug it?
#1

Hello guys, few months ago I wrote a system that it does find me inactive players that they haven't join the server for more than 2 months. (It's not that accurate, but it does it's work)

So, I knew that when 2015 comes out, it should get bugged. So I made a simple check to be sure, but I'm not that sure if it's join to work.

pawn Код:
format(Query, sizeof(Query), "SELECT `LastLogin` FROM `Users` WHERE `Username` = '%s' LIMIT 0, 1", DB_Escape(hInfo[h][Owner]));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
    db_get_field_assoc(Result, "LastLogin", Date, 32);

    if(!sscanf(Date, "p</>ddd", sDay, sMonth, sYear))
    {
        if(sYear != Year)
        {
            //sMonth = The last month player joined. Month = the current month.
            //So if player joined in the 10 month and now it's 1, (10 - 1) = 9, so 2 months. The same with (11 - 2) = 9, (12 - 3) = 9.

            if((sMonth - Month) <= 9)
            {
                hInfo[h][IsOwnerInactive] = 1;

                LoadedInactiveHouses++;
            }
        }
        else if((Month - sMonth) >= 2)
        {
            hInfo[h][IsOwnerInactive] = 1;

            LoadedInactiveHouses++;
        }
    }
}
db_free_result(Result);
I Know that it could be written with a better way, but I don't really have that time to do it.

Any advice? It will work or it's going to return false results.
Reply
#2

It is like a mono time set...
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
This is why people use timestamps.
It's too late to use Timestamps. I'm currently saving it as "08/01/2015 - 10:28:14".
Reply
#4

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
It's too late to use Timestamps. I'm currently saving it as "08/01/2015 - 10:28:14".
a? perhaps it's time to change the system, because the current one is not so good
Reply
#5

I wish I had the time to do it. Anyway the problem is any advice if it's going to bug or something, not to improve my System.
Reply
#6

Why u don't have time to convert that ? Just run a simple query on mysql, edit function check time
Reply
#7

Because I serve in the army and my time home is limited.
Reply
#8

For the similar thing I made this https://sampforum.blast.hk/showthread.php?tid=553377
Have a look at it, its similar to timestamps but in days only so
So according to your script it will be something like this -
pawn Код:
new diffrence = DateToJulian(todayY, todayM, todayD)-DateToJulian(sYear, sMonth, sDay);
if(diffrence >= 60)//60 days
{
//inactive for two months
}
Reply
#9

look at this : http://dev.mysql.com/doc/refman/5.1/...unix-timestamp
pawn Код:
format(Query, sizeof(Query), "SELECT UNIX_TIMESTAMP(LastLogin) FROM `Users` WHERE `Username` = '%s' LIMIT 0, 1", DB_Escape(hInfo[h][Owner]));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
    db_get_field_assoc(Result, "LastLogin", Date, 32);

    if(gettime() - strval(Date) >= 5259486) // 60 days = 5259486 secconds
    {
        hInfo[h][IsOwnerInactive] = 1;
        LoadedInactiveHouses++;
    }
}
db_free_result(Result);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)