Re: Character online time
Posted: Sun Mar 27, 2011 12:26 pm
Anyone got a solution for this?
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());
Sorry for necroposting but i need this to .py script.Szponiasty wrote:Have fun.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; }
PS. You can access that also in L2PcInstance with no need for SQL queries.Make getters for that variables, as they're private as I recall (or make them public If you want to).Code: Select all
L2pcInstance.javalong _onlineTimelong _onlineBeginTime