Jump to content

Last Login for Lucera


Recommended Posts

Hey ! I would like to share with you a simple script that shows the IP and date of the last login.

package listeners;

import l2.commons.dbutils.DbUtils;
import l2.gameserver.database.DatabaseFactory;
import l2.gameserver.listener.actor.player.OnPlayerEnterListener;
import l2.gameserver.model.Player;

import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LastLogin implements OnPlayerEnterListener {

    public void onPlayerEnter(Player var1) {

        Timestamp ts = new Timestamp(var1.getLastAccess() * 1000);
        Date la = new Date(ts.getTime());
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy, HH:mm");
        String ll = df.format(la);
        var1.sendMessage("Your character was last logged in " + ll);
        var1.sendMessage("Last IP: " + LastIP(var1));
        var1.sendMessage("Current IP: " + var1.getIP());

    public static String LastIP(Player var1)
        String var2 = "";
        Connection var3 = null;
        PreparedStatement var4 = null;
        ResultSet var5 = null;
            var3 = DatabaseFactory.getInstance().getConnection();
            var4 = var3.prepareStatement("select lastIP from accounts where login = ?");
            var4.setString(1, var1.getAccountName());
            var5 = var4.executeQuery();
                var2 = var5.getString("lastIP");
        } catch (SQLException ex) {

        } finally {
            DbUtils.closeQuietly(var3, var4, var5);
        return var2;



Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Join now

    Be part of the largest and oldest communities about Lineage2 in Latin America.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.