last active

Started by Coolkid, Apr 20, 2016, 09:05 PM

Previous topic - Next topic

Coolkid

the function gives the last active in wring month all other things r fine but it delivers month one back for example the data of today would be 20/3/2016 15:55:28 one moth back

[spoiler="command"]function LastActive(player)
{
local now = date();
local q = QuerySQL(db, "SELECT Name,LADate FROM LastActive WHERE Name='"+player.Name+"'");
if (GetSQLColumnData(q,0) == null)
{
QuerySQL(db, "INSERT INTO LastActive (Name, LADate) VALUES ('"+player.Name+"', '"+ now.day + "/" + now.month + "/" + now.year + " " + now.hour + ":" + now.min + ":" + now.sec +"')");
}
if (GetSQLColumnData(q,0) == player.Name)
{
QuerySQL(db, "UPDATE LastActive SET LADate='"+ now.day + "/" + now.month + "/" + now.year + " " + now.hour + ":" + now.min + ":" + now.sec + "' WHERE Name='" + player.Name + "'");
}
FreeSQLQuery( q );
}
[/spoiler]

MacTavish

use this
function LastActive(player)
{
local now = date(), CorrectMonth;
CorrectMonth = now.month+1;
local q = QuerySQL(db, "SELECT Name,LADate FROM LastActive WHERE Name='"+player.Name+"'");
if (GetSQLColumnData(q,0) == null)
{
QuerySQL(db, "INSERT INTO LastActive (Name, LADate) VALUES ('"+player.Name+"', '"+ now.day + "/" + CorrectMonth + "/" + now.year + " " + now.hour + ":" + now.min + ":" + now.sec +"')");
}
if (GetSQLColumnData(q,0) == player.Name)
{
QuerySQL(db, "UPDATE LastActive SET LADate='"+ now.day + "/" + CorrectMonth + "/" + now.year + " " + now.hour + ":" + now.min + ":" + now.sec + "' WHERE Name='" + player.Name + "'");
}
FreeSQLQuery( q );
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

You guys are making me laugh lol
function LastActive( player )
{
local q = QuerySQL( db, "SELECT Name FROM LastActive WHERE Name='"+player.Name+"'"); /*Don't forget the escape the string*/
local d = GetSQLColumnData( q, 0 );
if( d != null ) QuerySQL( db , "UPDATE LastActive SET LADate='" + time() + "' WHERE Name='"+player.Name+"'");
else QuerySQL( db, format( "INSERT INTO LastActive(Name,LADate) VALUES('%s','%s')",player.Name,time() ) );
}
Copy the gettimeformat function from Kusangi's uptime script and use it something like:
GetTimeFormat( LastActiveTime() );Some mistakes might be there because I'm on phone :D
oh no