Jump to content

Input K Format in Pick Money Dialog


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

This is the hidden content, please
( GitHub )

Hello, came by to share something simple yet helpful for players, someone requested me this feature that allows you to input money with k format on the pick money dialog window, this will enable you to input “1kk” instead of “1000000”


Hope it comes in handy for who is planning to use it.

Spoiler

gL0Mp4H.gif

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 118
  • kekw 1
  • Dislove 1
  • Not Good 1
  • Cry 1
  • Confused 3
  • Lmao 1
  • Good 26
  • Love 4
  • Love 66
Link to comment
Share on other sites

  • Honorable Member
14 minutes ago, jeddawee said:

nice release 

 

hmm is it possible to make "pick money dialog" separated by dots ?

ex: 850.000.000

 

i think it would be good


@jeddawee
 

uiPickMoney.py

# Search
str(maxValue))

# Replace with
str(localeInfo.NumberToMoneyString(maxValue)))

 

  • Love 1
Link to comment
Share on other sites

  • Honorable Member
39 minutes ago, jeddawee said:

sorry but i meant this one , the black box

 

ba3dc53830863eac79029a21a0fda87f.png

 

 

 

@jeddawee

 

Just use localeInfo.NumberToMoneyString

 

uiExchange.py

# Search
		self.OwnerMoney.SetText(str(exchange.GetElkFromSelf()))
		self.TargetMoney.SetText(str(exchange.GetElkFromTarget()))

# Replace with
		self.OwnerMoney.SetText(localeInfo.NumberToMoneyString(exchange.GetElkFromSelf()))
		self.TargetMoney.SetText(localeInfo.NumberToMoneyString(exchange.GetElkFromTarget()))

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

  • Premium

Nice idea, good job.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Honorable Member
3 hours ago, HITRON said:

Better:


USE_MONEY_K_FORMAT = True

if USE_MONEY_K_FORMAT:
	def FormatMoneyToK(string):
		moneyString = str(string)
		moneyString = moneyString.replace("K","k")

		money = 0

		if len(moneyString) > 1 and 'k' in moneyString:
			money = int(moneyString.replace('k', '000'))

		return money

 

you can use lower instead of replace

moneyString.lower()

 

  • Good 1
  • Love 1

 

Link to comment
Share on other sites

  • Forum Moderator
On 1/8/2020 at 10:34 PM, Owsap said:

if USE_MONEY_K_FORMAT:
	def FormatMoneyToK(string):
		moneyString = str(string)
		money = 0

		if len(moneyString) > 1:
			if 'k' in moneyString:
				money = int(moneyString.replace('k', '000'))
			elif 'K' in moneyString:
				money = int(moneyString.replace('K', '000'))

		return money

 

 

The idea is good, but the code is bugged and unreadable, here're the bugs:

 

text = '1kks'

  • ValueError: invalid literal for int() with base 10: '1000000s'

text = '1kk500'

  • 1000000500

text = '1abcd'

  • '1abcd'

 

If I'm the one who do this, i would do it more extendable and using a proficient way.

 

8f9d06c2fcb7f4525c2fe219a878a09d.png 4807153bd1bb3f4e9e4b00f492054864.png

 

9197a657a56afcab56b8b17ce77806e1.png 2be07686886205e82d437108f547bbbd.png

This is the hidden content, please

At least, keep the copyright.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 65
  • Eyes 1
  • Sad 1
  • Smile Tear 1
  • Confused 1
  • Scream 1
  • Good 16
  • Love 1
  • Love 57
Link to comment
Share on other sites

  • Bronze

hmm.. i like to see my idea start to have so many different methods of implementation...  Thanks all for doing this! respect.

Another idea for you guys xD and this can be a little complicated i think :D

"The storage can now be opened without the password. In addition, it will not close automatically as soon as you run a bit."

Link to comment
Share on other sites

  • Honorable Member

@VegaS™ I was aware that It was not the best method neither the best code, although it never went trough my mind to try the bugs you mentioned, since it did what it supposed to I stopped there but it was my fault to not try possible erros.

 

Thanks for sharing your correction and making the feature better, also wanna thank everyone that gave their feedback on the same.

  • Love 2
Link to comment
Share on other sites

  • 3 months later...

Sorry to bring this one up. But i'm fairly new to scripts (python).
Can someone explain me this?

 

Quote

0419 10:51:22482 :: Traceback (most recent call last):

0419 10:51:22482 ::   File "ui.py", line 1363, in CallEvent

0419 10:51:22482 ::   File "ui.py", line 88, in __call__

0419 10:51:22482 ::   File "ui.py", line 70, in __call__

0419 10:51:22482 ::   File "uiPickMoney.py", line 102, in OnAccept

0419 10:51:22482 :: AttributeError
0419 10:51:22482 :: : 
0419 10:51:22482 :: 'module' object has no attribute '_PickMoneyDialog__ConvertMoneyText'
0419 10:51:22482 :: 


I tried to follow his tutorial but..i didn't could reproduce / follow one step of him.

 

Quote
''' 2. ENABLE_CHEQUE_SYSTEM '''
  # Search @ def OnAccept
  money_text = self.pickValueEditLine.GetText()
   
  # Add below
  if constInfo.USE_KMB_MONEY_FORMAT:
  if money_text:
  moneyValue = min(constInfo.__ConvertMoneyText(text), self.maxValue)
  if moneyValue:
  if self.eventAccept:
  self.eventAccept(moneyValue)



 

Sorry fixed the Problem myself :)

Edited by Leafxc
Link to comment
Share on other sites

  • 3 weeks later...
On 4/19/2020 at 11:56 AM, Leafxc said:

Sorry to bring this one up. But i'm fairly new to scripts (python).
Can someone explain me this?

 


I tried to follow his tutorial but..i didn't could reproduce / follow one step of him.

 



 

Sorry fixed the Problem myself :)

I have the same problem.

'module' object has no attribute '_PickMoneyDialog__ConvertMoneyText'

Can you tell me how to solve it?

BTW The "system" is interesting

Link to comment
Share on other sites

On 5/9/2020 at 3:30 PM, xGetHigh said:

I have the same problem.

'module' object has no attribute '_PickMoneyDialog__ConvertMoneyText'


'module' object has no attribute '_PickMoneyDialog__ConvertMoneyText'

Can you tell me how to solve it?

BTW The "system" is interesting

uipickmoney.py

search:

moneyValue = min(constInfo.__ConvertMoneyText(text), self.maxValue)

replace

moneyValue = min(constInfo.ConvertMoneyText(text), self.maxValue)

open constinfo.py

search:

def ConvertMoneyText(self, text, powers = dict(k = 10**3, m = 10**6, b = 10**9)):

replace:

def ConvertMoneyText(text, powers = dict(k = 10**3, m = 10**6, b = 10**9)):

add: 
import re


problems solved?

  • Good 1
  • Love 2
Link to comment
Share on other sites

  • 2 years later...
On 11/29/2022 at 1:39 PM, ‚Point‘ said:

Thanks for the release @ VegaS™ and @ Owsap - working like a charm!

Maybe one of you could help to handle a point/comma aswell?
I tried by my self but im not really into regex 😄

Thanks in advance & Best Regards

Its from old copy but might work can't test it rn take a look

 

	def value_to_float(self, x):
		if type(x) == float or type(x) == int:
			return x
		result = 1
		while 'K' in x:
			a = int(x.find('K'))
			x = x[0 : a : ] + x[a + 1 : : ]
			result = result * 1000
		return float(x) * result
	def OnAccept(self):
		allowed = "0123456789kK."
		text = self.pickValueEditLine.GetText()

		if len(text) > 0 and text.isdigit():

			money = long(text)
			money = min(money, self.maxValue)

			if money > 0:
				if self.eventAccept:
					self.eventAccept(money)
		elif len(text) > 0 and text.isdigit() == False:
			TXT = text
			TXT = TXT.replace('k', 'K')
			TXT = TXT.replace(',', '.')
			ct = True
			nG = -1
			pG = -1
			lG = -1
			for i in range(0, len(TXT)):
				if allowed.find(TXT[i]) == -1 and allowed.find(TXT[i].upper()) == -1:
					ct = False
					break
			if (TXT.count('.') > 1) or (TXT.find('.') > TXT.find('K') and TXT.find('K') != -1 and TXT.find('.') != -1):
				ct = False
			if ct == True:
				money = int(self.value_to_float(TXT))
				if money > 0:
					if self.eventAccept:
						self.eventAccept(money)
		self.Close()

 

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.