Page 2 of 2

Re: Character online time

Posted: Sun Mar 27, 2011 12:26 pm
by jorgeromero
Anyone got a solution for this?

Re: Character online time

Posted: Mon Feb 06, 2012 8:27 am
by fakoykas
It's rather simple...

Code: Select all

### Eclipse Workspace Patch 1.0#P L2J_ServerIndex: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java===================================================================--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 5165)+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)@@ -7828,7 +7828,7 @@            long totalOnlineTime = _onlineTime;                        if (_onlineBeginTime > 0)-               totalOnlineTime += (System.currentTimeMillis()-_onlineBeginTime)/1000;+               totalOnlineTime += (System.currentTimeMillis()-getOfflineStartTime()-_onlineBeginTime)/1000;                        statement.setLong(35, totalOnlineTime);            statement.setInt(36, getPunishLevel().value()); 

Re: Character online time

Posted: Thu Sep 20, 2012 2:26 pm
by lucan
Szponiasty wrote:

Code: Select all

     private long getLastSeen(String CharName)    {   //lastaccess        long chObjectId = getObjectIdByName(CharName);        long result = -1;        if (chObjectId < 1)            return result;         L2PcInstance _playerInstance = L2World.getInstance().findPlayer((int)chObjectId);         if (_playerInstance != null && (_playerInstance.isOnline() == 1))            return 0;         Connection con = null;        try        {   // CharName             con = L2DatabaseFactory.getInstance().getConnection();            PreparedStatement statement = con.prepareStatement("SELECT lastaccess FROM characters WHERE charId=?");            statement.setLong(1, chObjectId);            ResultSet rset = statement.executeQuery();            if (rset.next())            {                result = rset.getLong(1);                               }            //_log.warning("Repair Attempt: Output Result for searching characters on account:"+result);            rset.close();            statement.close();        }        catch (SQLException e)        {            e.printStackTrace();            return result;        }        finally        {            try            {                if (con != null)                    con.close();            }            catch (SQLException e)            {                // I really don't care...            }        }        return result;    } 
Have fun.

PS. You can access that also in L2PcInstance with no need for SQL queries.

Code: Select all

 L2pcInstance.javalong _onlineTimelong _onlineBeginTime 
Make getters for that variables, as they're private as I recall (or make them public If you want to).
Sorry for necroposting but i need this to .py script.
I need know the online time of a character, someone can help me?