Jump to content
×
×
  • Create New...

Request Auto Cancel by Overtime


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Hello devs.

I don't want to talk a lot about nothing, but I have to say what is this.
With this little modification the party and the friend requests are cancelled automatically in seconds what you can change in the Open method. ( pyObj.Open(sec) )

Preview video:

Spoiler

Songname: Selena Gomez - Kill Em With Kindness (Robby Burke Bootleg)

Make a backup before you are implementing it! And if you found a bug, please explain it.

0.) Open your uiCommon.py file and import chat module.
1.) Replace the whole QuestionDialogWithTimeLimit class in the uiCommon.py file with this:

class QuestionDialogWithTimeLimit(QuestionDialog2):
	def __init__(self):
		ui.ScriptWindow.__init__(self)

		self.__CreateDialog()
		self.endTime = 0
		self.timeOverMsg = 0
		self.timeOverEvent = None
		self.timeOverEventArgs = None

	def __del__(self):
		QuestionDialog2.__del__(self)

	def __CreateDialog(self):
		pyScrLoader = ui.PythonScriptLoader()
		pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")

		self.board = self.GetChild("board")
		self.textLine1 = self.GetChild("message1")
		self.textLine2 = self.GetChild("message2")
		self.acceptButton = self.GetChild("accept")
		self.cancelButton = self.GetChild("cancel")

	def Open(self, timeout):
		self.SetCenterPosition()
		self.SetTop()
		self.Show()

		self.endTime = app.GetTime() + timeout

	def SetTimeOverEvent(self, event, *args):
		self.timeOverEvent = event
		self.timeOverEventArgs = args

	def SetTimeOverMsg(self, msg):
		self.timeOverMsg = msg

	def OnTimeOver(self):
		if self.timeOverEvent:
			apply(self.timeOverEvent, self.timeOverEventArgs)
		if self.timeOverMsg:
			chat.AppendChat(chat.CHAT_TYPE_INFO, self.timeOverMsg)

	def OnUpdate(self):
		leftTime = max(0, self.endTime - app.GetTime())
		self.SetText2(localeInfo.UI_LEFT_TIME % (leftTime))
		if leftTime <= 0:
			self.OnTimeOver()

 

2.) Open your game.py file and replace each of these three methods to these:

	def OnMessengerAddFriendQuestion(self, name):
		messengerAddFriendQuestion = uiCommon.QuestionDialogWithTimeLimit()
		messengerAddFriendQuestion.SetText1(localeInfo.MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND % (name))
		messengerAddFriendQuestion.SetTimeOverMsg(localeInfo.MESSENGER_ADD_FRIEND_ANSWER_TIMEOVER)
		messengerAddFriendQuestion.SetTimeOverEvent(self.OnDenyAddFriend)
		messengerAddFriendQuestion.SetAcceptEvent(ui.__mem_func__(self.OnAcceptAddFriend))
		messengerAddFriendQuestion.SetCancelEvent(ui.__mem_func__(self.OnDenyAddFriend))
		messengerAddFriendQuestion.Open(10)
		messengerAddFriendQuestion.name = name
		self.messengerAddFriendQuestion = messengerAddFriendQuestion
	def RecvPartyInviteQuestion(self, leaderVID, leaderName):
		partyInviteQuestionDialog = uiCommon.QuestionDialogWithTimeLimit()
		partyInviteQuestionDialog.SetText1(leaderName + localeInfo.PARTY_DO_YOU_JOIN)
		partyInviteQuestionDialog.SetTimeOverMsg(localeInfo.PARTY_ANSWER_TIMEOVER)
		partyInviteQuestionDialog.SetTimeOverEvent(self.AnswerPartyInvite, False)
		partyInviteQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerPartyInvite(arg))
		partyInviteQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerPartyInvite(arg))
		partyInviteQuestionDialog.Open(10)
		partyInviteQuestionDialog.partyLeaderVID = leaderVID
		self.partyInviteQuestionDialog = partyInviteQuestionDialog
	def BINARY_OnQuestConfirm(self, msg, timeout, pid):
		confirmDialog = uiCommon.QuestionDialogWithTimeLimit()
		confirmDialog.SetText1(msg)
		confirmDialog.Open(timeout)
		confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		self.confirmDialog = confirmDialog

 

3.) Open your locale/xy/locale_game.txt and add these if these aren't exists:

MESSENGER_ADD_FRIEND_ANSWER_TIMEOVER	Friend request was cancelled.
PARTY_ANSWER_TIMEOVER	Party invite was cancelled.

Remove MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_2 line and change MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND_1 with this:

MESSENGER_DO_YOU_ACCEPT_ADD_FRIEND	%s added you as a friend, accept?

 

At last take a look at your files and correct the net module calls and the True-False syntax.  net <--> m2net, True <--> TRUE

  • Metin2 Dev 6
  • Love 16
  • Good 1
  • Not Good 1
Link to comment
Share on other sites

Nice Thanks for release, but for users without src Python modules changed like this:

 

confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())

change to this 

 

confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())

 

  • Metin2 Dev 1
Link to comment
Share on other sites

  • Honorable Member

That is just the name of the net module. Easy to handle this problem from the error message if someone doesn't notice.
And no need source to change the name of the built-in modules :), but yeah need to care of it if someone doesn't renamed it.

Link to comment
Share on other sites

  • 1 year later...
Dnia 5.12.2018 o 22:14, Mind Rapist napisał:

Can someone explain me how is it possible that chat.AppendChat(chat.CHAT_TYPE_INFO, self.timeOverMsg) has a syntax error???????????????? Please someone show me what I'm doing wrong here? 

Try to change from UTF-8 to ANSI remove artifacts then paste again or rewrite whole code :D

  • Love 2
Link to comment
Share on other sites

  • 1 year later...
1103 16:53:54261 ::   File "uiCommon.py", line 349, in OnUpdate

1103 16:53:54261 ::   File "uiCommon.py", line 343, in OnTimeOver

1103 16:53:54262 :: NameError
1103 16:53:54262 :: : 
1103 16:53:54262 :: global name 'chat' is not defined

 

how can i do for erase this sysser ingame i don't got a problems but i wana erease the sysser

 

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
  • Premium
Posted (edited)

@ xP3NG3Rx First of all, thanks for the release. But you did a mistake with this:

On 4/14/2017 at 8:29 PM, xP3NG3Rx said:
def BINARY_OnQuestConfirm(self, msg, timeout, pid):
		confirmDialog = uiCommon.QuestionDialogWithTimeLimit()
		confirmDialog.SetText1(msg)
		confirmDialog.Open(timeout)
		confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: m2net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		self.confirmDialog = confirmDialog

dialog won't close because there is missing the "event" which is closing the dialog.

I solved that by these changes:

Open: root/game.py

Finddef BINARY_OnQuestConfirm(self, msg, timeout, pid):

Replace whole function with this:

Spoiler
def BINARY_OnQuestConfirm(self, msg, timeout, pid):
		confirmDialog = uiCommon.QuestionDialogWithTimeLimit2()
		confirmDialog.SetText1(msg)
		confirmDialog.SetText2(localeInfo.UI_ACCEPT_MARRIAGE)
		confirmDialog.SetTimeOverMsg(localeInfo.MARRIAGE_ANSWER_TIMEOVER)
		confirmDialog.SetAcceptEvent(lambda answer=True, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.SetCancelEvent(lambda answer=False, pid=pid: net.SendQuestConfirmPacket(answer, pid) or self.confirmDialog.Hide())
		confirmDialog.Open(timeout)
		self.confirmDialog = confirmDialog

 

Now add this to locale/locale_game.txt:

Spoiler
UI_ACCEPT_MARRIAGE	Accept request?
MARRIAGE_ANSWER_TIMEOVER	Time limit for marriage accept is over!

 

Then open root/uicommon.py:

And add a new class:

Spoiler
class QuestionDialogWithTimeLimit2(QuestionDialog2):

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

		self.__CreateDialog()
		self.endTime = 0
		self.timeOverMsg = 0

	def __del__(self):
		QuestionDialog2.__del__(self)

	def __CreateDialog(self):
		pyScrLoader = ui.PythonScriptLoader()
		pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")

		self.board = self.GetChild("board")
		self.textLine1 = self.GetChild("message1")
		self.textLine2 = self.GetChild("message2")
		self.acceptButton = self.GetChild("accept")
		self.cancelButton = self.GetChild("cancel")

	def Open(self, timeout):
		self.SetCenterPosition()
		self.SetTop()
		self.Show()

		self.endTime = app.GetTime() + timeout
	
	def Close(self):
		self.Hide()

	def SetTimeOverMsg(self, msg):
		self.timeOverMsg = msg

	def OnUpdate(self):
		leftTime = max(0, self.endTime - app.GetTime())
		# self.SetText2(localeInfo.UI_LEFT_TIME % (leftTime))

		if leftTime <= 0:
			self.Close()
			self.cancelButton.CallEvent()

			if self.timeOverMsg:
				chat.AppendChat(chat.CHAT_TYPE_INFO, self.timeOverMsg)

	def OnPressEscapeKey(self):
		self.Close()
		self.cancelButton.CallEvent()
		return True

 

Enjoy!

If anyone got an idea for better solution, I'll be really glad for that.

Edited by ReFresh
  • Metin2 Dev 1

I'll be always helpful! 👊 

Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


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.