Jump to content

Private Shop Item Preview


Recommended Posts

  • Bronze

This is the hidden content, please

Metin2 Download

 

Players put items in their own private shop without being able to sell them as a sample

This is the hidden content, please

Edit: It will no longer message when you purchase the sample item

Open uishop.py and search:

            itemBuyQuestionDialog = uiCommon.QuestionDialog()
            itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
            itemBuyQuestionDialog.SetAcceptEvent(lambda arg=TRUE: self.AnswerBuyItem(arg))
            itemBuyQuestionDialog.SetCancelEvent(lambda arg=FALSE: self.AnswerBuyItem(arg))
            itemBuyQuestionDialog.Open()
            itemBuyQuestionDialog.pos = slotPos
            self.itemBuyQuestionDialog = itemBuyQuestionDialog

CHANGE WITH:

        if itemPrice == 0 :
            return;
        else:
            itemBuyQuestionDialog = uiCommon.QuestionDialog()
            itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
            itemBuyQuestionDialog.SetAcceptEvent(lambda arg=TRUE: self.AnswerBuyItem(arg))
            itemBuyQuestionDialog.SetCancelEvent(lambda arg=FALSE: self.AnswerBuyItem(arg))
            itemBuyQuestionDialog.Open()
            itemBuyQuestionDialog.pos = slotPos
            self.itemBuyQuestionDialog = itemBuyQuestionDialog

 

------------------------------------------------------------------------------------------------------

 

FROM UICOMMON.PY CHANGE ONLY THIS CODE 

Only this you change from uicommon.py

open uicommon and search    Only this you change from uicommon.py

class MoneyInputDialog(ui.ScriptWindow):
/................
.................
............................
................
..................

change with:


class MoneyInputDialog(ui.ScriptWindow):

	def __init__(self):
		ui.ScriptWindow.__init__(self)

		self.moneyHeaderText = localeInfo.MONEY_INPUT_DIALOG_SELLPRICE
		self.__CreateDialog()
		self.SetMaxLength(9)

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def __CreateDialog(self):

		pyScrLoader = ui.PythonScriptLoader()
		pyScrLoader.LoadScriptFile(self, "uiscript/moneyinputdialog.py")

		getObject = self.GetChild
		self.board = self.GetChild("board")
		self.acceptButton = getObject("AcceptButton")
		self.accept2Button = getObject("Accept2Button")
		self.cancelButton = getObject("CancelButton")
		self.inputValue = getObject("InputValue")
		self.inputValue.SetNumberMode()
		self.inputValue.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
		self.moneyText = getObject("MoneyValue")

	def Open(self):
		self.inputValue.SetText("0")
		self.inputValue.SetFocus()
		self.__OnValueUpdate()
		self.SetCenterPosition()
		self.SetTop()
		self.Show()

	def Close(self):
		self.ClearDictionary()
		self.board = None
		self.acceptButton = None
		self.accept2Button = None
		self.cancelButton = None
		self.inputValue = None
		self.Hide()

	def SetTitle(self, name):
		self.board.SetTitleName(name)

	def SetFocus(self):
		self.inputValue.SetFocus()

	def SetMaxLength(self, length):
		length = min(9, length)
		self.inputValue.SetMax(length)

	def SetMoneyHeaderText(self, text):
		self.moneyHeaderText = text

	def SetAcceptEvent(self, event):
		self.acceptButton.SetEvent(event)
		self.accept2Button.SetEvent(event)
		self.inputValue.OnIMEReturn = event

	def SetCancelEvent(self, event):
		self.board.SetCloseEvent(event)
		self.cancelButton.SetEvent(event)
		self.inputValue.OnPressEscapeKey = event

	def SetValue(self, value):
		value=str(value)
		self.inputValue.SetText(value)
		self.__OnValueUpdate()
		ime.SetCursorPosition(len(value))


	def GetText(self):
		return self.inputValue.GetText()

	def __OnValueUpdate(self):
		ui.EditLine.OnIMEUpdate(self.inputValue)

		text = self.inputValue.GetText()

		money = 0
		if text and text.isdigit():
			try:
				money = int(text)
			except ValueError:
				money = 199999999

		self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

 

 

#update tutorial in github fixxed with locale_game.txt 

OPEN NOW IN LOCALE LOCALE_GAME.TXT and locale_interface.txt

ADD

TOOLTIP_BUYPRICE_FREE Not Sell items my friends

 

---------------------------------------------------------------------------------------------

THIS COCE ONLY FOR SERVER WITH 0 YANG IN NPC

If you do not have a server with 0 yang in npc then you do not need to make this small change in source shop.cpp

idea from @TMP4

In shop.cpp edit this:

if (r_item.price < 0)

To this:

if (r_item.price < 0 || (IsPCShop() && r_item.price <= 0))

 

Edited by Draveniou1
I improved the code 100% check up post thanks
  • Metin2 Dev 118
  • Dislove 1
  • Angry 1
  • Not Good 2
  • Sad 1
  • Think 5
  • Confused 3
  • Good 29
  • Love 38
Link to comment
Share on other sites

  • Bronze
2 hours ago, xP3NG3Rx said:

Basically it just blocks the clientside popup message, right?
So if I send the packet anyway, the players whom are showing the items going to get screwed up.

No  block item in private shop ,   He has absolutely no problems

1 hour ago, TMP4 said:

To be safe as P3NG3R said, In shop.cpp edit this:

if (r_item.price < 0)

To this:

if (r_item.price < 0 || (IsPCShop() && r_item.price <= 0))

(You may have the original check with <= too)

+1

  • Confused 1
Link to comment
Share on other sites

  • Bronze
1 minute ago, TMP4 said:

@Draveniou1 That fix is actually for hackers who bypasses the clientside block.

I Know

Normal:

if (r_item.price < 0)  Normal change with   if (r_item.price <= 0)

 


Your method    I have not tried this, the children will tell us

if (r_item.price < 0 || (IsPCShop() && r_item.price <= 0))

1 minute ago, xP3NG3Rx said:

@Draveniou1 Apparently you have no clue what I was talking about neither how this process works, and how it can be exploited. 

As I can see @TMP4 was faster to answer, and explained my point of view.

it is safe, if it was not safe I would not publish it

Link to comment
Share on other sites

  • Bronze

# post update 100%  fixxed problem withs locale_game.txt 

OPEN NOW IN LOCALE LOCALE_GAME.TXT and locale_interface.txt

ADD TOOLTIP_BUYPRICE_FREE Not Sell items my friends

 

open uicommon and search    Only this you change from uicommon.py

class MoneyInputDialog(ui.ScriptWindow):
/................
.................
............................
................
..................

change with:


class MoneyInputDialog(ui.ScriptWindow):

	def __init__(self):
		ui.ScriptWindow.__init__(self)

		self.moneyHeaderText = localeInfo.MONEY_INPUT_DIALOG_SELLPRICE
		self.__CreateDialog()
		self.SetMaxLength(9)

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def __CreateDialog(self):

		pyScrLoader = ui.PythonScriptLoader()
		pyScrLoader.LoadScriptFile(self, "uiscript/moneyinputdialog.py")

		getObject = self.GetChild
		self.board = self.GetChild("board")
		self.acceptButton = getObject("AcceptButton")
		self.accept2Button = getObject("Accept2Button")
		self.cancelButton = getObject("CancelButton")
		self.inputValue = getObject("InputValue")
		self.inputValue.SetNumberMode()
		self.inputValue.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
		self.moneyText = getObject("MoneyValue")

	def Open(self):
		self.inputValue.SetText("0")
		self.inputValue.SetFocus()
		self.__OnValueUpdate()
		self.SetCenterPosition()
		self.SetTop()
		self.Show()

	def Close(self):
		self.ClearDictionary()
		self.board = None
		self.acceptButton = None
		self.accept2Button = None
		self.cancelButton = None
		self.inputValue = None
		self.Hide()

	def SetTitle(self, name):
		self.board.SetTitleName(name)

	def SetFocus(self):
		self.inputValue.SetFocus()

	def SetMaxLength(self, length):
		length = min(9, length)
		self.inputValue.SetMax(length)

	def SetMoneyHeaderText(self, text):
		self.moneyHeaderText = text

	def SetAcceptEvent(self, event):
		self.acceptButton.SetEvent(event)
		self.accept2Button.SetEvent(event)
		self.inputValue.OnIMEReturn = event

	def SetCancelEvent(self, event):
		self.board.SetCloseEvent(event)
		self.cancelButton.SetEvent(event)
		self.inputValue.OnPressEscapeKey = event

	def SetValue(self, value):
		value=str(value)
		self.inputValue.SetText(value)
		self.__OnValueUpdate()
		ime.SetCursorPosition(len(value))


	def GetText(self):
		return self.inputValue.GetText()

	def __OnValueUpdate(self):
		ui.EditLine.OnIMEUpdate(self.inputValue)

		text = self.inputValue.GetText()

		money = 0
		if text and text.isdigit():
			try:
				money = int(text)
			except ValueError:
				money = 199999999

		self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

 

Edited by Draveniou1
  • Metin2 Dev 1
Link to comment
Share on other sites

Sorry i don't understand well, the system is for showing a "item" but you can't buyed, this is for don't put item for exmaple " sword +9 99wons and 99999999yang" and send you MP to buy item?

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

  • Bronze
31 minutes ago, nazox said:

Sorry i don't understand well, the system is for showing a "item" but you can't buyed, this is for don't put item for exmaple " sword +9 99wons and 99999999yang" and send you MP to buy item?

This system is .... to allow players to put an item without anyone being able to buy  in privateshop

Link to comment
Share on other sites

5 minutes ago, Draveniou1 said:

Este sistema es ... para permitir a los jugadores poner un artículo sin que nadie pueda comprar en la tienda privada.

oh i see thanks and sorry !! 🙂

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

3 minutes ago, Draveniou1 said:

Amazing!! thanks for the potho i come back when i add and thanks, and good job!! 🙂

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

Hello again, i add system, work great!! 

https://metin2.download/picture/nWuOwFj9GxSVbSTZpwA4IDz9aKha89Qh/.gif

i can't see "This item is not available" but is because i'm using won, so i'm fixing this, when  i have a fix i put here, but thanks, all work great! 🙂

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

  • Bronze
6 hours ago, nazox said:

Hello again, i add system, work great!! 

https://metin2.download/picture/nWuOwFj9GxSVbSTZpwA4IDz9aKha89Qh/.gif

i can't see "This item is not available" but is because i'm using won, so i'm fixing this, when  i have a fix i put here, but thanks, all work great! 🙂

You can make some small changes to the won system,   I can help you if you want

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

4 hours ago, Draveniou1 said:

You can make some small changes to the won system,   I can help you if you want

I would appreciate it, now I'm not on pc but then I'll show you how to edit it, but still I can't get it to execute the buyfree line, so if you can give me any ideas I'd really appreciate it, I use the won check from here from metin2dev!! And thanks again 

  • Good 1

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

  • Bronze
28 minutes ago, nazox said:

I would appreciate it, now I'm not on pc but then I'll show you how to edit it, but still I can't get it to execute the buyfree line, so if you can give me any ideas I'd really appreciate it, I use the won check from here from metin2dev!! And thanks again 

You have  PM

  • Love 1
Link to comment
Share on other sites

##Update With Won and Offline Shop by Great, special thanks to @Draveniou1 to help me anytime, and give me many ideas to working this 🙂

1-If you used Offline Shop by gret, go to shop.cpp on source game, and search  all :

Spoiler

if (r_item.price < 0)

replace with:

Spoiler

if (r_item.price < 0 || (IsPCShop() && r_item.price <= 0))

now compile, and you can use "0" to put items.

2-Now go to uiCommon.py and search:

Spoiler

    def Open(self):
        self.inputValue.SetText("")

Now replace with 0 or 1, this means that when they put an item, the value 0 or 1 or the one that you put comes out automatically.

Spoiler

    def Open(self):
        self.inputValue.SetText("1")

Now search:

Spoiler

class MoneyInputDialog(ui.ScriptWindow):

and add with other functions:

Spoiler

self.accept2Button = getObject("Accept2Button")

Search:

Spoiler

    def SetAcceptEvent(self, event):
        self.acceptButton.SetEvent(event)
        self.inputValue.OnIMEReturn = event

replace with:

Spoiler

    def SetAcceptEvent(self, event):
        self.acceptButton.SetEvent(event)
        self.accept2Button.SetEvent(event)
        self.inputValue.OnIMEReturn = event

Now, if  you don't use Won, replace this function:

Spoiler

def __OnValueUpdate(self):

with:

Spoiler

        def __OnValueUpdate(self):
            ui.EditLine.OnIMEUpdate(self.inputValue)

            text = self.inputValue.GetText()

            money = 0
            if text and text.isdigit():
                try:
                    money = int(text)
                except ValueError:
                    money = 199999999

            self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

If you use Cheque_won replace all function:

Spoiler

    if app.ENABLE_CHEQUE_SYSTEM:
        def SetCheque(self, cheque):
            cheque=str(cheque)
            self.inputChequeValue.SetText(cheque)
            self.__OnValueUpdate()
            ime.SetCursorPosition(len(cheque)+1)

        def GetTextCheque(self):
            return self.inputChequeValue.GetText()

        def __ClickChequeEditLine(self):
            self.inputChequeValue.SetFocus()
            if len(self.inputValue.GetText()) <= 0:
                self.inputValue.SetText(str(0))

        def __ClickValueEditLine(self):
            self.inputValue.SetFocus()
            if len(self.inputChequeValue.GetText()) <= 0:
                self.inputChequeValue.SetText(str(0))

        def GetCheque(self):
            return self.inputChequeValue.GetText()

        def __OnValueUpdate(self):
            if self.inputValue.IsFocus():
                ui.EditLine.OnIMEUpdate(self.inputValue)
            elif self.inputChequeValue.IsFocus():
                ui.EditLine.OnIMEUpdate(self.inputChequeValue)
            else:
                pass

            text = self.inputValue.GetText()
            cheque_text = self.inputChequeValue.GetText()

            money = 0
            cheque = 0
            GOLD_MAX = 2000000000 ##Put your Yang Max
            CHEQUE_MAX = 100 ##Put  your Won max

            if text and text.isdigit():
                try:
                    money = int(text)
                    
                    if money >= GOLD_MAX:
                        money = GOLD_MAX - 1
                        self.inputValue.SetText(str(money))
                except ValueError:
                    money = 0

            if cheque_text and cheque_text.isdigit():
                try:
                    cheque = int(cheque_text)
                    
                    if cheque >= CHEQUE_MAX:
                        cheque = CHEQUE_MAX - 1
                        self.inputValue.SetText(str(cheque))
                except ValueError:
                    cheque = 0
            self.chequeText.SetText(str(cheque) + " " + localeInfo.CHEQUE_SYSTEM_UNIT_WON)
            self.moneyText.SetText(localeInfo.NumberToGoldNotText(money) + " " + localeInfo.CHEQUE_SYSTEM_UNIT_YANG)
    else:
        def __OnValueUpdate(self):
            ui.EditLine.OnIMEUpdate(self.inputValue)

            text = self.inputValue.GetText()

            money = 0
            if text and text.isdigit():
                try:
                    money = int(text)
                except ValueError:
                    money = 199999999

            self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

3-Open uiToolTip.py and search :

Spoiler

def AppendPrice(self, price):

Before add:

Spoiler

    def GetPriceColorFree(self, price):
        if price == 0:
            return self.GREEN_COLOR_PRICE_FREE

Now Search:

Spoiler

    def AppendPrice(self, price):

and replace function with:

Spoiler

    def AppendPrice(self, price):
        if app.ENABLE_CHEQUE_SYSTEM:
            if price ==0:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
            else:
                self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                self.AppendSpace(5)
        else:
            self.AppendSpace(5)
            if price <= 0:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
            else:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))

Now search :

Spoiler

    def AppendSellingPrice(self, price):

And replace function with:

Spoiler

    def AppendSellingPrice(self, price):
        if app.ENABLE_CHEQUE_SYSTEM:
            if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
                self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
                self.AppendSpace(5)
            else:
                if price == 0 :
                    self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
                    self.AppendSpace(5)
                else:
                    self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG % (localeInfo.NumberToGold(price)), self.GetPriceColor(price))
                    self.AppendSpace(5)
        else:
            if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
                self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
                self.AppendSpace(5)
            else:
                if price == 0:
                    self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
                    self.AppendSpace(5)
                else:
                    self.AppendTextLine(localeInfo.TOOLTIP_SELLPRICE % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                    self.AppendSpace(5)

Now this:

Spoiler

LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)

replace with:

Spoiler

    LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
    GREEN_COLOR_PRICE_FREE = grp.GenerateColor(0.9, 0.5745, 0.5627, 1.0)

4-Open uiPrivateShopBuilder.py and search this function:

Spoiler

    def AcceptInputPrice(self):

inside this function find:

Spoiler

if int(cheque) <=0 and int(text)<=0:

and replace :

Spoiler

if int(cheque) <=0 and int(text)<=-1:

now search:

Spoiler

if int(text) <= 0:

and replace with:

Spoiler

if int(text) <= -1:

5-Now Open networkmodule.py and find:

Spoiler

AcceptButton = self.GetChild("accept")

after add:

Spoiler

Accept2Button = self.GetChild("accept")

Accept2Button.SetText(ButtonName)

6-Now Open uiShop.py and find:

Spoiler

itemBuyQuestionDialog = uiCommon.QuestionDialog()

replace all function with:

Spoiler

        if itemPrice == 0:
            return
        else:    
            itemBuyQuestionDialog = uiCommon.QuestionDialog()
            if app.ENABLE_CHEQUE_SYSTEM:
                if itemCheque > 0 and itemPrice <=0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM_CHEQUE_SIN_YANG(itemName, itemCount, localeInfo.NumberToCheque(itemCheque)))
                elif itemCheque <= 0 and itemPrice > 0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToGoldNotText(itemPrice)))
                elif itemCheque > 0 and itemPrice > 0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM_YANG_CHEQUE(itemName, itemCount, localeInfo.NumberToGoldNotText(itemPrice),localeInfo.NumberToGoldNotText(itemCheque) ))
            if itemPrice == 0 :
                return
            else:
                itemBuyQuestionDialog = uiCommon.QuestionDialog()
                itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
                itemBuyQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerBuyItem(arg))
                itemBuyQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerBuyItem(arg))
                itemBuyQuestionDialog.Open()
                itemBuyQuestionDialog.pos = slotPos
                self.itemBuyQuestionDialog = itemBuyQuestionDialog

And now you have adapted with Great and Cheque system.

Notes:

#1-If you want change "0 yang" when put item  go to uiToolTip and find "0 yang" and change for example "This item is not Avaliable"  you can find in def SetInventoryItem and  def SetShopItem , def SetPrivateShopBuilderItem

#2-I'm working in fix to put item in "edit section" but not update item, but if you want add item with 0 won and 0 yang, go to uiNewShop, and change all  if int(text) <= 0: with if int(text) <= -1:

#3-In Normal private shop, if you click to buy item work, great, in Offline shop, when you click to buy work great but say "you don't have  yang" (not problem is only visual ) this problem is coming from  SHOP_ERROR_DICT -> SHOP_NOT_ENOUGH_MONEY i'm working in this too.

#4-I try to use a negative values, like -1 yang for not using 0 but i can't so remember your players, you need 1 yang to put items,  :), ignoring this all work great, thanks again.

  • Metin2 Dev 1
  • Good 1
  • Love 1

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

  • Bronze
1 minute ago, nazox said:

##Update With Won and Offline Shop by Great, special thanks to @Draveniou1 to help me anytime, and give me many ideas to working this 🙂

1-If you used Offline Shop by gret, go to shop.cpp on source game, and search  all :

  Reveal hidden contents

if (r_item.price < 0)

replace with:

  Reveal hidden contents

if (r_item.price < 0 || (IsPCShop() && r_item.price <= 0))

now compile, and you can use "0" to put items.

2-Now go to uiCommon.py and search:

  Reveal hidden contents

    def Open(self):
        self.inputValue.SetText("")

Now replace with 0 or 1, this means that when they put an item, the value 0 or 1 or the one that you put comes out automatically.

  Reveal hidden contents

    def Open(self):
        self.inputValue.SetText("1")

Now search:

  Reveal hidden contents

class MoneyInputDialog(ui.ScriptWindow):

and add with other functions:

  Reveal hidden contents

self.accept2Button = getObject("Accept2Button")

Search:

  Reveal hidden contents

    def SetAcceptEvent(self, event):
        self.acceptButton.SetEvent(event)
        self.inputValue.OnIMEReturn = event

replace with:

  Reveal hidden contents

    def SetAcceptEvent(self, event):
        self.acceptButton.SetEvent(event)
        self.accept2Button.SetEvent(event)
        self.inputValue.OnIMEReturn = event

Now, if  you don't use Won, replace this function:

  Reveal hidden contents

def __OnValueUpdate(self):

with:

  Reveal hidden contents

        def __OnValueUpdate(self):
            ui.EditLine.OnIMEUpdate(self.inputValue)

            text = self.inputValue.GetText()

            money = 0
            if text and text.isdigit():
                try:
                    money = int(text)
                except ValueError:
                    money = 199999999

            self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

If you use Cheque_won replace all function:

  Reveal hidden contents

    if app.ENABLE_CHEQUE_SYSTEM:
        def SetCheque(self, cheque):
            cheque=str(cheque)
            self.inputChequeValue.SetText(cheque)
            self.__OnValueUpdate()
            ime.SetCursorPosition(len(cheque)+1)

        def GetTextCheque(self):
            return self.inputChequeValue.GetText()

        def __ClickChequeEditLine(self):
            self.inputChequeValue.SetFocus()
            if len(self.inputValue.GetText()) <= 0:
                self.inputValue.SetText(str(0))

        def __ClickValueEditLine(self):
            self.inputValue.SetFocus()
            if len(self.inputChequeValue.GetText()) <= 0:
                self.inputChequeValue.SetText(str(0))

        def GetCheque(self):
            return self.inputChequeValue.GetText()

        def __OnValueUpdate(self):
            if self.inputValue.IsFocus():
                ui.EditLine.OnIMEUpdate(self.inputValue)
            elif self.inputChequeValue.IsFocus():
                ui.EditLine.OnIMEUpdate(self.inputChequeValue)
            else:
                pass

            text = self.inputValue.GetText()
            cheque_text = self.inputChequeValue.GetText()

            money = 0
            cheque = 0
            GOLD_MAX = 2000000000 ##Put your Yang Max
            CHEQUE_MAX = 100 ##Put  your Won max

            if text and text.isdigit():
                try:
                    money = int(text)
                    
                    if money >= GOLD_MAX:
                        money = GOLD_MAX - 1
                        self.inputValue.SetText(str(money))
                except ValueError:
                    money = 0

            if cheque_text and cheque_text.isdigit():
                try:
                    cheque = int(cheque_text)
                    
                    if cheque >= CHEQUE_MAX:
                        cheque = CHEQUE_MAX - 1
                        self.inputValue.SetText(str(cheque))
                except ValueError:
                    cheque = 0
            self.chequeText.SetText(str(cheque) + " " + localeInfo.CHEQUE_SYSTEM_UNIT_WON)
            self.moneyText.SetText(localeInfo.NumberToGoldNotText(money) + " " + localeInfo.CHEQUE_SYSTEM_UNIT_YANG)
    else:
        def __OnValueUpdate(self):
            ui.EditLine.OnIMEUpdate(self.inputValue)

            text = self.inputValue.GetText()

            money = 0
            if text and text.isdigit():
                try:
                    money = int(text)
                except ValueError:
                    money = 199999999

            self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))

3-Open uiToolTip.py and search :

  Reveal hidden contents

def AppendPrice(self, price):

Before add:

  Reveal hidden contents

    def GetPriceColorFree(self, price):
        if price == 0:
            return self.GREEN_COLOR_PRICE_FREE

Now Search:

  Reveal hidden contents

    def AppendPrice(self, price):

and replace function with:

  Reveal hidden contents

    def AppendPrice(self, price):
        if app.ENABLE_CHEQUE_SYSTEM:
            if price ==0:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
            else:
                self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                self.AppendSpace(5)
        else:
            self.AppendSpace(5)
            if price <= 0:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
            else:
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))

Now search :

  Reveal hidden contents

    def AppendSellingPrice(self, price):

And replace function with:

  Reveal hidden contents

    def AppendSellingPrice(self, price):
        if app.ENABLE_CHEQUE_SYSTEM:
            if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
                self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
                self.AppendSpace(5)
            else:
                if price == 0 :
                    self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
                    self.AppendSpace(5)
                else:
                    self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG % (localeInfo.NumberToGold(price)), self.GetPriceColor(price))
                    self.AppendSpace(5)
        else:
            if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
                self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
                self.AppendSpace(5)
            else:
                if price == 0:
                    self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE_FREE, self.GetPriceColorFree(price))
                    self.AppendSpace(5)
                else:
                    self.AppendTextLine(localeInfo.TOOLTIP_SELLPRICE % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
                    self.AppendSpace(5)

Now this:

  Reveal hidden contents

LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)

replace with:

  Reveal hidden contents

    LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
    GREEN_COLOR_PRICE_FREE = grp.GenerateColor(0.9, 0.5745, 0.5627, 1.0)

4-Open uiPrivateShopBuilder.py and search this function:

  Reveal hidden contents

    def AcceptInputPrice(self):

inside this function find:

  Reveal hidden contents

if int(cheque) <=0 and int(text)<=0:

and replace :

  Reveal hidden contents

if int(cheque) <=0 and int(text)<=-1:

now search:

  Reveal hidden contents

if int(text) <= 0:

and replace with:

  Reveal hidden contents

if int(text) <= -1:

5-Now Open networkmodule.py and find:

  Reveal hidden contents

AcceptButton = self.GetChild("accept")

after add:

  Reveal hidden contents

Accept2Button = self.GetChild("accept")

Accept2Button.SetText(ButtonName)

6-Now Open uiShop.py and find:

  Reveal hidden contents

itemBuyQuestionDialog = uiCommon.QuestionDialog()

replace all function with:

  Reveal hidden contents

        if itemPrice == 0:
            return
        else:    
            itemBuyQuestionDialog = uiCommon.QuestionDialog()
            if app.ENABLE_CHEQUE_SYSTEM:
                if itemCheque > 0 and itemPrice <=0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM_CHEQUE_SIN_YANG(itemName, itemCount, localeInfo.NumberToCheque(itemCheque)))
                elif itemCheque <= 0 and itemPrice > 0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToGoldNotText(itemPrice)))
                elif itemCheque > 0 and itemPrice > 0:
                    itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM_YANG_CHEQUE(itemName, itemCount, localeInfo.NumberToGoldNotText(itemPrice),localeInfo.NumberToGoldNotText(itemCheque) ))
            if itemPrice == 0 :
                return
            else:
                itemBuyQuestionDialog = uiCommon.QuestionDialog()
                itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
                itemBuyQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerBuyItem(arg))
                itemBuyQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerBuyItem(arg))
                itemBuyQuestionDialog.Open()
                itemBuyQuestionDialog.pos = slotPos
                self.itemBuyQuestionDialog = itemBuyQuestionDialog

And now you have adapted with Great and Cheque system.

Notes:

#1-If you want change "0 yang" when put item  go to uiToolTip and find "0 yang" and change for example "This item is not Avaliable"  you can find in def SetInventoryItem and  def SetShopItem , def SetPrivateShopBuilderItem

#2-I'm working in fix to put item in "edit section" but not update item, but if you want add item with 0 won and 0 yang, go to uiNewShop, and change all  if int(text) <= 0: with if int(text) <= -1:

#3-In Normal private shop, if you click to buy item work, great, in Offline shop, when you click to buy work great but say "you don't have  yang" (not problem is only visual ) this problem is coming from  SHOP_ERROR_DICT -> SHOP_NOT_ENOUGH_MONEY i'm working in this too.

#4-I try to use a negative values, like -1 yang for not using 0 but i can't so remember your players, you need 1 yang to put items,  :), ignoring this all work great, thanks again.

GG #FIX FOR OFFLINESHOP - WON

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.