PDA

View Full Version : 2015 may bug it?


]Rafaellos[
08/01/2015, 06:35 AM
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.

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.

Spookieman
08/01/2015, 07:46 AM
It is like a mono time set...

]Rafaellos[
08/01/2015, 07:50 AM
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".

Jessyy
08/01/2015, 08:13 AM
Rafaellos[;3320105']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 :|

]Rafaellos[
08/01/2015, 09:13 AM
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.

rickisme
08/01/2015, 09:31 AM
Why u don't have time to convert that ? Just run a simple query on mysql, edit function check time

]Rafaellos[
08/01/2015, 09:47 AM
Because I serve in the army and my time home is limited.

BroZeus
08/01/2015, 09:56 AM
For the similar thing I made this http://forum.sa-mp.com/showthread.php?t=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 -

new diffrence = DateToJulian(todayY, todayM, todayD)-DateToJulian(sYear, sMonth, sDay);
if(diffrence >= 60)//60 days
{
//inactive for two months
}

rickisme
08/01/2015, 10:04 AM
look at this : http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_unix-timestamp

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);