madarismenos Posted November 1, 2016 Posted November 1, 2016 (edited) Hello Member to mxc i create one easy code for check last login from account!Soory for bad Engilsh dont test this and i dont know if work retail :) :) Updated ### Eclipse Workspace Patch 1.0 #P aCis_gameserver Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 5) +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy) @@ -15,8 +15,10 @@ package net.sf.l2j.gameserver.model.actor.instance; import java.sql.Connection; +import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -10705,4 +10707,32 @@ break; } } + + public long cklastlogin() + { + long chklogin = 0; + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + PreparedStatement statement = con.prepareStatement("SELECT lastactive FROM accounts WHERE login=?"); + statement.setString(1, getAccountName()); + ResultSet rset = statement.executeQuery(); + + // Go though the recordset of this SQL query + while (rset.next()) + { + chklogin = rset.getLong("lastactive"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(chklogin); + sendMessage("Last Login:"+dateFormat.format(date)); + } + + rset.close(); + statement.close(); + } + catch (Exception e) + { + _log.warning("Could not restore Last Login: " + e); + } + return chklogin; + } } \ No newline at end of file Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java =================================================================== --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 5) +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy) @@ -79,7 +79,7 @@ getClient().closeNow(); return; } - + activeChar.cklastlogin(); if (activeChar.isGM()) { if (Config.GM_STARTUP_INVULNERABLE && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel())) Edited November 1, 2016 by madarismenos Quote
krauser12345 Posted November 1, 2016 Posted November 1, 2016 This is not your Code...+1.Same code have L2Primer Project from 2013. I don't think that is your. Quote
madarismenos Posted November 1, 2016 Author Posted November 1, 2016 (edited) My haters is individuals are all my children ;) +1.Same code have L2Primer Project from 2013. I don't think that is your. This is not your Code... Edited November 1, 2016 by madarismenos Quote
StinkyMadness Posted November 1, 2016 Posted November 1, 2016 Im not your hater... i dont even know you.......... just respect the creator and give the credits... Quote
krauser12345 Posted November 1, 2016 Posted November 1, 2016 My haters is individuals are all my children ;)all ppl are kids expect you. So why you tell lies to ppl huh? Quote
Psyancy Posted November 1, 2016 Posted November 1, 2016 ahhaahahaha again trying to show his self as a pro dev by using shared codes claiming as his. In fact this code is shared on l2jbrasil (no advertise) by bluur XD Quote
madarismenos Posted November 2, 2016 Author Posted November 2, 2016 (edited) I do not know that was shared and that maker myself do not do leached go away You are too cheap!!! ahhaahahaha again trying to show his self as a pro dev by using shared codes claiming as his. In fact this code is shared on l2jbrasil (no advertise) by bluur XD Edited November 2, 2016 by madarismenos Quote
Tessa Posted November 2, 2016 Posted November 2, 2016 (edited) New connection lol... Edited November 2, 2016 by Tessa Quote
Rootware Posted November 2, 2016 Posted November 2, 2016 What happens if i will use different databases for game and login server? Your code return a zero and spammed a log file. Better implementation when you uses LS <-> GS connection. In this case, it's useless shitcode. Quote
Inthedash6 Posted November 2, 2016 Posted November 2, 2016 I have error: public long cklastlogin() [javac] C:\workspace\L2jFrozen_GameServer\head-src\com\l2jfrozen\gameserver\model\actor\instance\L2PcInstance.java:10457: error: illegal start of expression [javac] public long cklastlogin(); [javac] ^ [javac] C:\workspace\L2jFrozen_GameServer\head-src\com\l2jfrozen\gameserver\model\actor\instance\L2PcInstance.java:10457: error: ';' expected [javac] public long cklastlogin(); [javac] Quote
SweeTs Posted November 2, 2016 Posted November 2, 2016 Errm don't you see the error? Which is " ; " ? Remove it. Quote
Inthedash6 Posted November 2, 2016 Posted November 2, 2016 delete from where? + + public long cklastlogin() + { + long chklogin = 0; + try (Connection con = L2DatabaseFactory.getInstance().getConnection()) + { + PreparedStatement statement = con.prepareStatement("SELECT lastactive FROM accounts WHERE login=?"); + statement.setString(1, getAccountName()); + ResultSet rset = statement.executeQuery(); + + // Go though the recordset of this SQL query + while (rset.next()) + { + chklogin = rset.getLong("lastactive"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(chklogin); + sendMessage("Last Login:"+dateFormat.format(date)); + } + + rset.close(); + statement.close(); + } + catch (Exception e) + { + _log.warning("Could not restore Last Login: " + e); + } + return chklogin; + } Quote
SweeTs Posted November 2, 2016 Posted November 2, 2016 (edited) Don't c/p code part as its fine, your code @ eclipse has ; 10457 line, you wrote public long cklastlogin(); <- from here. Eclipse should throw you the error. Edited November 2, 2016 by SweeTs Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.