Jump to content
  • 0

Lf Dev For Add Npc Change Passords


Question

2 answers to this question

Recommended Posts

  • 0
Posted

an 8es na sou perasei kapoios npc opws leei to title sou k na ton plhrwseis tzampa lefta lol

pes ti 8es  k an einai efkolo to ma8eneis na to kaneis monos

  • 0
Posted

code for frozen, other versions will need adaptation

### Eclipse Workspace Patch 1.0
#P L2jFrozen_DataPack
Index: data/html/mods/change_password.htm
===================================================================
--- data/html/mods/change_password.htm (revision 0)
+++ data/html/mods/change_password.htm (working copy)
@@ -0,0 +1,35 @@
+<html>
+ <body>
+ <center><img src=L2UI_CH3.herotower_deco width=256 height=32></center><br>
+ <center><font color="008080">Change Password</font></center>
+ <center>
+ <table cellspacing=-1>
+ <tr><td><img src="L2UI.SquareBlank" width=40 height=20></td></tr>
+ </table>
+ <center><img src=L2UI.SquareGray width=250 height=1></center>
+ <img src="L2UI.SquareBlank" width=40 height=2>
+ <center><img src="L2UI.SquareGray" width=300 height=1></center>
+ <table bgcolor=000000 width=300 height=47>
+ <tr><td><center>First fill in your <font color=LEVEL>current password</font> and then your new!</center></td></tr>
+ </table>
+ <center><img src="L2UI.SquareGray" width=300 height=1></center>
+ <img src="L2UI.SquareBlank" width=40 height=2>
+ <center><img src=L2UI.SquareGray width=250 height=1></center>
+ <table cellspacing=-1>
+ <tr><td><img src="L2UI.SquareBlank" width=40 height=20></td></tr>
+ </table>
+ </center>
+ <table width=256>
+ <tr><td align=right><font color="3366FF">Current Password:</font></td><td><edit var="curPass" type="password" width=125 height=15></td></tr>
+ <tr><td align=right><font color="3366FF">New Password:</font></td><td><edit var="newPass" type="password" width=125 height=15></td></tr>
+ <tr><td align=right><font color="3366FF">Repeat Password:</font></td><td><edit var="repPass" type="password" width=125 height=15></td></tr>
+ </table>
+ <br><br>
+ <center>
+ <button value="Change" action="bypass -h npc_%objectId%_change_password $curPass $newPass $repPass" width=75 height=21 back="L2UI_CH3.Btn1_normal_over" fore="L2UI_CH3.Btn1_normal">
+ <br><br>
+ <font color="LEVEL">Copyright 2013 i9 Games TM.</font><br1>
+ <font color="0066FF">www.i9games.com</font>
+ </center>
+ </body>
+</html>
\ No newline at end of file
#P L2jFrozen_GameServer
Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ChangePasswordInstance.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ChangePasswordInstance.java (revision 0)
+++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ChangePasswordInstance.java (working copy)
@@ -0,0 +1,220 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package com.l2jfrozen.gameserver.model.actor.instance;
+
+import java.security.MessageDigest;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.StringTokenizer;
+
+import com.l2jfrozen.Config;
+import com.l2jfrozen.crypt.Base64;
+import com.l2jfrozen.gameserver.ai.CtrlIntention;
+import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
+import com.l2jfrozen.gameserver.network.serverpackets.LeaveWorld;
+import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
+import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
+import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
+import com.l2jfrozen.util.CloseUtil;
+import com.l2jfrozen.util.database.L2DatabaseFactory;
+
+public class L2ChangePasswordInstance extends L2FolkInstance
+{
+ public L2ChangePasswordInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ @Override
+ public void onAction(L2PcInstance player)
+ {
+ if (!canTarget(player))
+ {
+ return;
+ }
+
+ player.setLastFolkNPC(this);
+
+ // Check if the L2PcInstance already target the L2NpcInstance
+ if (this != player.getTarget())
+ {
+ // Set the target of the L2PcInstance player
+ player.setTarget(this);
+
+ // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
+ MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
+ player.sendPacket(my);
+ my = null;
+
+ // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
+ player.sendPacket(new ValidateLocation(this));
+ }
+ else
+ {
+ // Calculate the distance between the L2PcInstance and the L2NpcInstance
+ if (!canInteract(player))
+ {
+ // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
+ }
+ else
+ {
+ showHtmlWindow(player);
+ }
+ }
+
+ player.sendPacket(new ActionFailed());
+ }
+
+ private void showHtmlWindow(L2PcInstance player)
+ {
+ String filename = "data/html/mods/change_password.htm";
+ NpcHtmlMessage html = new NpcHtmlMessage(1);
+ html.setFile(filename);
+ html.replace("%objectId%", String.valueOf(getObjectId()));
+ player.sendPacket(html);
+ filename = null;
+ html = null;
+ }
+
+ @Override
+ public void onBypassFeedback(L2PcInstance player, String command)
+ {
+ if (command.startsWith("change_password"))
+ {
+ StringTokenizer st = new StringTokenizer(command);
+ st.nextToken();
+ String curPass = null;
+ String newPass = null;
+ String repPass = null;
+ try
+ {
+ if (st.hasMoreTokens())
+ {
+ curPass = st.nextToken();
+ newPass = st.nextToken();
+ repPass = st.nextToken();
+ }
+ else
+ {
+ player.sendMessage("Please fill in all the blanks before requesting for a password change.");
+ return;
+ }
+ changePassword(curPass, newPass, repPass, player);
+ }
+ catch (StringIndexOutOfBoundsException e)
+ {
+ if (Config.ENABLE_ALL_EXCEPTIONS)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static boolean changePassword(String currPass, String newPass, String repeatNewPass, L2PcInstance activeChar)
+ {
+ if (newPass.length() < 3)
+ {
+ activeChar.sendMessage("The new password is too short!");
+ return false;
+ }
+ if (newPass.length() > 16)
+ {
+ activeChar.sendMessage("The new password is too long!");
+ return false;
+ }
+ if (!newPass.equals(repeatNewPass))
+ {
+ activeChar.sendMessage("Repeated password doesn't match the new password.");
+ return false;
+ }
+
+ Connection con = null;
+ String password = null;
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("SHA");
+ byte[] raw = currPass.getBytes("UTF-8");
+ raw = md.digest(raw);
+ String currPassEncoded = Base64.encodeBytes(raw);
+
+ con = L2DatabaseFactory.getInstance().getConnection(false);
+ PreparedStatement statement = con.prepareStatement("SELECT password FROM accounts WHERE login=?");
+ statement.setString(1, activeChar.getAccountName());
+ ResultSet rset = statement.executeQuery();
+ while (rset.next())
+ {
+ password = rset.getString("password");
+ }
+ rset.close();
+ statement.close();
+ byte[] password2 = null;
+ if (currPassEncoded.equals(password))
+ {
+ password2 = newPass.getBytes("UTF-8");
+ password2 = md.digest(password2);
+
+ PreparedStatement statement2 = con.prepareStatement("UPDATE accounts SET password=? WHERE login=?");
+ statement2.setString(1, Base64.encodeBytes(password2));
+ statement2.setString(2, activeChar.getAccountName());
+ statement2.executeUpdate();
+ statement2.close();
+
+ activeChar.sendMessage("Your password has been changed successfully! For security reasons, You will be disconnected. Please login again!");
+ try
+ {
+ Thread.sleep(3000L);
+ }
+ catch (Exception e)
+ {
+ if (Config.ENABLE_ALL_EXCEPTIONS)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ activeChar.deleteMe();
+ activeChar.sendPacket(new LeaveWorld());
+ }
+ else
+ {
+ activeChar.sendMessage("The current password you've inserted is incorrect! Please try again!");
+
+ return password2 != null;
+ }
+ }
+ catch (Exception e)
+ {
+ if (Config.ENABLE_ALL_EXCEPTIONS)
+ {
+ e.printStackTrace();
+ }
+
+ _log.warning("could not update the password of account: " + activeChar.getAccountName());
+ }
+ finally
+ {
+ CloseUtil.close(con);
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
SQL:
INSERT IGNORE INTO `custom_npc` VALUES ('55', '30026', 'Julio', '1', 'Change Password', '1', 'NPC.a_fighterguild_master_Mhuman', '8.00', '23.50', '70', 'male', 'L2ChangePassword', '40', '3862', '1493', '11.85', '2.78', '40', '43', '30', '21', '20', '10', '0', '0', '1314', '470', '780', '382', '278', '0', '333', '0', '0', '0', '55', '132', null, '0', '1', '0', 'LAST_HIT');

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ⚡ 5TB Storage + Gemini Advanced 12-18M upgrade active! Keeps your personal files 100% private with instant automated setup.     FINAL CALL: Google is Shutting This Down After October 2026! Google will NEVER bring back this window of opportunity again. Once this month ends, this massive backdoor upgrade is gone permanently!  BUY 2, GET 1 FREE IS STILL LIVE! Stock up now for yourself, your family, your business, and your friends! Think about it: Every single person you know uses a Gmail account, and everyone is running out of storage. Don't let your loved ones get trapped paying $20–$30 every single month when you can set them up with 5TB Cloud Storage + Gemini Advanced (12–18 Months) right now for only $15! Why Buy Bulk Activations Today? Instant Gift Value: Perfect lifetime-style gift for clients, family, or team members. 100% Private & Safe: Activates on personal Gmails—zero passwords or logins required. Global Access: Works worldwide with zero VPN hassles. Instant Automated Delivery: Receive your activation links in seconds 24/7! ‍ Time is running out fast—secure your extra free licenses before the October deadline hits! Order Your Bundle Now on the Website
    • Since technical talk offends people, I believe I should return back to writting my Lineage 2 lore stories. Here's the next one:   Once upon a time, there was a boy and a small adorable wolf.    The boy really loved the wolf but as the wolf grow older and bigger, it became agressive and would bite the boy. One day the boy and the wolf decided to go to the city to buy potions. The road was long and hilly so the boy moved all his adena to the wolf bags to help his legs and reach the city easier.   When they reached the city, the boy tried to take the adena out of the wolf's bags. But the wolf would not ! He bit the boy and said "You will not get this adena back, this is my adena". The boy got angry. He decided to go to the pet master and ask for help.    "Pet master, pet master ! My wolf is big, bad and angry and it won't obey me. I want my adena back and it bites me. "   The pet master looked at the big angry wolf, then looked at the boy and said. "I have a solution for your problem young one. I have magic. Dark magic. I can turn your big bad elder wolf into a younger puppy for free, all you have to do is spell the magic chants. Nothing more, no wolf modifying wands, just your say".   The boy thought about it for a bit, and decided that he indeed wanted to turn things back. But when he was about to spell the magic words, guards arrived at the pet master.    The city guard captain said "Is this the big bad angry wolf that bites people and doesn't give back his adena ? We will kill this wolf !"    For a moment the boy hesitated but he said "This wolf is big bad and angry, but I love this wolf and I dont want it to die ! Please don't kill the big bad angry wolf." But the boy was not fast enough. The guards jumped the wolf and started slashing on him with their swords. The boy didn't know what to do, so in it its final moments right as the wolf was about to die, it spelled the magic words. "Pet master, make my wolf young and adorable again !"   But he was not fast enough. The wolf got slashed and killed by the guards just one moment before the boy could finish his last word.    But as the words came out of his mouth, with the wolf's dead body on the floor, a younger wolf manifested out of thin air. The magic was real. The guards got scared and run away. Now the boy was left with a dead old bad angry wolf and next to him an alive younger version.    The boys joy was even bigger when it opened the new wolfs bags and his adena was finally there. He took the adena and went back to buy potions in the city.   Twenty four hours later, the boy couldn't believe how his fortune would change ...   (No AI was used to write this story)
    • This is like 2017 MaxCheaters. i love it.
    • NEW SEASON GRAND OPENING FROM - 30 OCTOBER 2026, FRIDAY, 20:00 +2 GMT !
    • My bug report was a proper submission. I shouldn't have shown the exploit, I will accept that. Let's end it here. 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and 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..