Jump to content

One Safebox Password per Login


Recommended Posts

  • Honorable Member

Hello

Today I want to share with all of you a little thing. All times when you are trying to open your safebox, it's requesting the password, isn't it? But for what?
I modified to limit these requests to one input per login. Of course if you warp or change character, you need to retype your password again.
But with extra modifications you can do it to store the password until you close the client, but I don't recommend this.

So, first go to the uiSafeBox.py file and paste this line into the __init__ method of the PasswordDialog class, with taking care of the tabulators:

self.lastPassword = ""

This variable will store your last entered password.

Then replace the Accept method of the same class with this: (take a look for the syntax, modulename, and true/false!)

	def OnAccept(self):
		self.lastPassword = str(self.passwordValue.GetText())
		m2net.SendChatPacket(self.sendMessage + self.lastPassword)
		self.CloseDialog()
		return True

When you accept the password input dialog, the entered password will be saved, if it's correct if it isn't as well. Don't worry about it, it will be reset if you entered wrong password.

The next step is that to paste these new functions into the same class.

	def InitSafeboxPassword(self):
		self.lastPassword = ""

	def GetSafeboxPwd(self):
		return self.lastPassword

As you can see, here is a function which will reset the entered password ;).
With this, the file is done.

Open interfaceModule.py and serach this line: ## Safebox then paste this function below:

	def InitSafeboxPassword(self):
		self.dlgPassword.InitSafeboxPassword()

Then replace the AskSafeboxPassword and AskMallPassword functions with these:

	def AskSafeboxPassword(self):
		if self.wndSafebox.IsShow():
			return

		if self.dlgPassword.IsShow():
			self.dlgPassword.CloseDialog()
			return

		self.dlgPassword.SetSendMessage("/safebox_password ")
		if self.dlgPassword.GetSafeboxPwd() != "":
			self.dlgPassword.OnAccept()
			return

		self.dlgPassword.SetTitle(localeInfo.PASSWORD_TITLE)
		self.dlgPassword.ShowDialog()

	def AskMallPassword(self):
		if self.wndMall.IsShow():
			return

		if self.dlgPassword.IsShow():
			self.dlgPassword.CloseDialog()
			return

		self.dlgPassword.SetSendMessage("/mall_password ")
		if self.dlgPassword.GetSafeboxPwd() != "":
			self.dlgPassword.OnAccept()
			return

		self.dlgPassword.SetTitle(localeInfo.MALL_PASSWORD_TITLE)
		self.dlgPassword.ShowDialog()

With these functions, if the last entered password is correct, the storages will open automatically with the last entered password.
The file is done.

Next, open your game.py and search this function: OnSafeBoxError and extend it with this line:

self.interface.InitSafeboxPassword()

So, as you can see this is the answer from the server to entered wrong password and this function will reset the last entered password as well :).

That's all, I hope you like it, and have fun.

 

Edit.: Fix for change password.

game/src/input_db.cpp

void CInputDB::SafeboxChangePasswordAnswer(LPDESC d, const char* c_pData)
{
	//[...]

	d->GetCharacter()->ChatPacket(CHAT_TYPE_COMMAND, "safebox_change_passwd %d", p->flag); // to the bottom of the function
}
Spoiler

.png

client/UserInterface/PythonNetworkStreamCommand.cpp

void CPythonNetworkStream::ServerCommand(char * c_szCommand)
{
	// [...]
	const char * szCmd = TokenVector[0].c_str();
	if (!strcmpi(szCmd, "quit"))
	{
		// [...]
	}
	else if (!strcmpi(szCmd, "BettingMoney"))
	{
		// [...]
	}
	//Add between the "else if" cases:
	else if (!strcmpi(szCmd, "safebox_change_passwd"))
	{
		if (2 != TokenVector.size())
		{
			TraceError("CPythonNetworkStream::ServerCommand(c_szCommand=%s) - Strange Parameter Count : %d", c_szCommand, TokenVector.size());
			return;
		}

		const int iFlag = atoi(TokenVector[1].c_str());
		PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "RecvSafeboxPasswordChangeAnswer", Py_BuildValue("(i)", iFlag));
	}

	else if (!strcmpi(szCmd, "gift"))
	{
		// [...]
	}
	// [...]
}

client/root/game.py

# below of CommandCloseSafebox function add:

	def RecvSafeboxPasswordChangeAnswer(self, flag):
		self.interface.RecvSafeboxPasswordChangeAnswer(flag)

client/root/interfaceModule.py

# Below of CommandCloseSafebox function add:

	def RecvSafeboxPasswordChangeAnswer(self, flag):
		if flag:
			self.dlgPassword.SetSafeboxPwd(str(self.wndSafebox.dlgChangePassword.GetNewPasswordText()))

client/root/uiSafeBox.py

# change the OnAccept function of the PasswordDialog class with this:
	def OnAccept(self):
		if self.lastPassword == "" and "" != str(self.passwordValue.GetText()):
			self.lastPassword = str(self.passwordValue.GetText())

		net.SendChatPacket(self.sendMessage + self.lastPassword)
		self.CloseDialog()
		return True

# add this new function to the PasswordDialog class:
	def SetSafeboxPwd(self, pwd):
		self.lastPassword=pwd

# add this line into the ChangePasswordDialog.__init__ function:
		self.__newPassword = ""

# add this line into the ChangePasswordDialog.Open function:
		self.__newPassword = ""

# add this function to the ChangePasswordDialog class:
	def GetNewPasswordText(self):
		return self.__newPassword

# add the following line into the ChangePasswordDialog.OnAccept function (between the password check and the SendChatPacket):

		#	return True

		self.__newPassword = newPasswordText
		#m2net.SendChatPacket("/safebox_change_password %s %s" % (oldPasswordText, newPasswordText))

 

Edit: fix of flooding: moving the saving method of the password from the OnAccept function to a separated one and calling it when the Safebox opens, this will be enough I guess.

client/root/uiSafeBox.py

# add the following function to the PasswordDialog class:
	def SavePassword(self):
		if self.lastPassword == "" and "" != str(self.passwordValue.GetText()):
			self.lastPassword = str(self.passwordValue.GetText())

# make the changes on the function in the PasswordDialog class
	def OnAccept(self):
		net.SendChatPacket(self.sendMessage + (self.lastPassword if self.lastPassword != "" else self.passwordValue.GetText()))
		self.CloseDialog()
		return True

client/root/interfaceModule.py

# add the following line into the beginning of the OpenSafeboxWindow and the OpenMallWindow function
		self.dlgPassword.SavePassword()

 

Edited by xP3NG3Rx
change_password fix
  • Love 25
Link to comment
Share on other sites

  • 3 years later...
  • 4 months later...
  • 5 weeks later...
  • Silver
On 11/3/2020 at 10:48 PM, dedif2 said:

global name 'm2net' is not defined
 



	def OnAccept(self):
		self.lastPassword = str(self.passwordValue.GetText())
		m2net.SendChatPacket(self.sendMessage + self.lastPassword)
		self.CloseDialog()
		return True

 

need help

Change m2net with chat like this chat.SendChatPacket.... 

and import chat before this function at start file when you open it

Or import m2net

Edited by Vaynz
  • Not Good 1
  • Lmao 1
Link to comment
Share on other sites

  • Developer
On 12/3/2020 at 1:29 AM, Vaynz said:

Change m2net with chat like this chat.SendChatPacket.... 

and import chat before this function at start file when you open it

Or import m2net

 

SendChatPacket is from module "net", therefore you will need to use it like this:

net.SendChatPacket(...)

@xP3NG3Rxhas the "net" module renamed to "m2net", this is why you get that error @dedif2.

  • Lmao 2
  • Good 1

r

Link to comment
Share on other sites

  • 2 years later...

@ xP3NG3Rx Sorry for react to old topic, but I found little "bug" when you open for example safebox and put password and after you change password, you got after trying reopen safebox "wrong password" because variable save old password and its not refreshed if you change password directly before relog or reopen client..

Link to comment
Share on other sites

  • Bronze
1 hour ago, xP3NG3Rx said:

@Filachilla Done, let me know if there is something wrong with it.

ch->ChatPacket  ---> d->GetCharacter()->ChatPacket

 

Works perfectly, ty @ xP3NG3Rx

https://metin2.download/picture/6K91987G7k1uR0g0h0yT7JF6g5lOBSEK/.gif

Edited by Metin2 Dev International
Core X - External 2 Internal

spacer.png

Link to comment
Share on other sites

  • Bronze

@ xP3NG3Rx one more bug:

If you enter the wrong password and try to open the storage again, the wrong password will automatically be added again and again until you relogin. How to fix?

Something like this: If you enter the password wrong the auto fill addon won't work.

 

I added: 

self.interface.InitSafeboxPassword()

 

But it does not deactivate the autofill

 

My bad, I did not add: 

    def InitSafeboxPassword(self):
        self.dlgPassword.InitSafeboxPassword()

in interfacemodule.py

Edited by SCOOB
dumb mistake

spacer.png

Link to comment
Share on other sites

@ xP3NG3Rx Wow! Now it works perfectly!!! I dont found any problem, so its fixed already 😄 thank you, its nice to see someone who have time to fix old release, you are the best!


Edit: In void CInputDB::SafeboxChangePasswordAnswer ch is not declared, so its last little thing, you can edit your topic, because some begginers can got problems to solve it 😛
 

Ahahaha 😄 lmao and I found last one thing xd @SCOOB can you test it too? When you first time try open safebox or mall and you put wrong password, after 10s first next open send you wrong password.. After next 10s you got clean input for password 😄

Edited by Filachilla
Link to comment
Share on other sites

  • Bronze
40 minutes ago, Filachilla said:

@ xP3NG3Rx Wow! Now it works perfectly!!! I dont found any problem, so its fixed already 😄 thank you, its nice to see someone who have time to fix old release, you are the best!


Edit: In void CInputDB::SafeboxChangePasswordAnswer ch is not declared, so its last little thing, you can edit your topic, because some begginers can got problems to solve it 😛
 

Ahahaha 😄 lmao and I found last one thing xd @SCOOB can you test it too? When you first time try open safebox or mall and you put wrong password, after 10s first next open send you wrong password.. After next 10s you got clean input for password 😄

for me it's working fine: https://metin2.download/video/80gK24rpnTBwBVfhAMROj15Mwhu2ZMO4/.mp4

Edited by Metin2 Dev International
Core X - External 2 Internal

spacer.png

Link to comment
Share on other sites

Now I found out that it doesnt always do it.. Try to put wrong password and fast clicking to reopen safebox and if you got clean input, try to again and again put wrong password.. After some attemps I got wrong password board instadead clean input.. 😄

edit: Finally problem is only when you try to reopen safebox with wrong password before 10s limit, just by fast clickings.. 😄 When you wait 10s its without problem as your gif.. 😄

Edited by Filachilla
  • Good 1
Link to comment
Share on other sites

  • Bronze
37 minutes ago, Filachilla said:

Now I found out that it doesnt always do it.. Try to put wrong password and fast clicking to reopen safebox and if you got clean input, try to again and again put wrong password.. After some attemps I got wrong password board instadead clean input.. 😄

@Filachilla, there's an easy fix for this.

You have to move SetSafeboxLoadTime(); from ReqSafeboxLoad func. to the Safebox Load func. so:

 

(for safebox) In char.cpp:  void CHARACTER::ReqSafeboxLoad(const char* pszPassword)

comment or remove: 

SetSafeboxLoadTime();

and add it in void CHARACTER::LoadSafebox, under:

    bool bLoaded = false;

    //PREVENT_TRADE_WINDOW
    SetOpenSafebox(true);

(for mall) In cmd_general.cpp: Search: ACMD(do_mall_password) and find there:

ch->SetMallLoadTime(iPulse);

comment or remove it, because it is called anyway when the mall window is closed.

Edited by SCOOB

spacer.png

Link to comment
Share on other sites

58 minutes ago, SCOOB said:

@Filachilla, there's an easy fix for this.

You have to move SetSafeboxLoadTime(); from ReqSafeboxLoad func. to the Safebox Load func. so:

 

In char.cpp:  void CHARACTER::ReqSafeboxLoad(const char* pszPassword)

comment or remove: 

SetSafeboxLoadTime();

and add it in void CHARACTER::LoadSafebox, under:

    bool bLoaded = false;

    //PREVENT_TRADE_WINDOW
    SetOpenSafebox(true);

 

You are definetly right 😄 this makes sense 😄 I will test it in moment.. 😄  Ive been trying everything for about 20 minutes now and I havent found anything else besides this thing.. 😄

Edit: Its work 😄

Edited by Filachilla
Link to comment
Share on other sites

  • Bronze
1 hour ago, xP3NG3Rx said:

I added a little python modification to the bottom of the first post to avoid this flooding caused mistake.
Moved the password saving method to a different function from the Accept so now it will save the password when the Safebox opens up.

yeah but now the mall password is not saved anymore.

I think it's better with my fix from above.

spacer.png

Link to comment
Share on other sites

11 hours ago, SCOOB said:

yeah but now the mall password is not saved anymore.

I think it's better with my fix from above.

Both corrections have their advantages and disadvantages.. For you, it is an opportunity to test the password combination faster..

Edit: @ xP3NG3Rx tested and now it works all correctly 😄 finally fixed all issues 😄 

Edited by Filachilla
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / 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.