Jump to content

[HowTo] Add Level and Time in PM


Recommended Posts

  • Premium

Hello, comm!

Here is a tutorial of how to display the level of character and the time in pm.

Spoiler

uHlSuYD.png

 

root/uiwhisper.py:

Spoiler

## Add if you don't have
import time
import player

## Search for:
                chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING)
                return

## Add Below:
            hour = time.strftime("%H:%M:%S")
            level = player.GetStatus(player.LEVEL)
            lv_whisper = "{} {}".format(localeInfo.LV_WHISPER, level)
            time_whisper = "{} {}".format(localeInfo.TIME_WHISPER, hour)
            whisper_message = "[" + lv_whisper + "] (" + time_whisper + "): " + text

## Search for:
            net.SendWhisperPacket(self.targetName, text)

## Replace with:
            net.SendWhisperPacket(self.targetName, whisper_message)

## Search for:
                chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, self.targetName, player.GetName() + " : " + text)

## Replace with:
                chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, self.targetName, player.GetName()+ " : " + whisper_message)
 

 

locale/en/locale_game.txt

Spoiler

# Add:
LV_WHISPER    Lv.
TIME_WHISPER    Hour:
 

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Metin2 Dev 10
  • Good 6
  • Love 3
Link to comment
Share on other sites

	def SendWhisper(self):
		text = self.chatLine.GetText()
		textLength = len(text)

		if textLength > 0:
			if net.IsInsultIn(text):
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING)
				return

			hour = time.strftime("%H:%M:%S")				# If you wanna time without text
			#level = str(player.GetStatus(player.LEVEL))	# If you wanna level without text

			#hour = "{} {}".format(localeInfo.WHISPER_TIME, time.strftime("%H:%M:%S"))			# If you wanna time with text
			level = "{} {}".format(localeInfo.WHISPER_LEVEL, player.GetStatus(player.LEVEL))	# If you wanna level with text

			string = "[" + level + "]" + " " + "[" + hour + "]" + " : " + text

			net.SendWhisperPacket(self.targetName, string)
			self.chatLine.SetText("")

			chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, self.targetName, player.GetName() + " : " + string)

 

  • Good 1
Link to comment
Share on other sites

  • 5 weeks later...
0430 22:01:47203 :: Traceback (most recent call last):

0430 22:01:47203 ::   File "ui.py", line 1060, in CallEvent

0430 22:01:47203 ::   File "ui.py", line 87, in __call__

0430 22:01:47204 ::   File "ui.py", line 69, in __call__

0430 22:01:47204 ::   File "uiWhisper.py", line 297, in SendWhisper

0430 22:01:47205 :: UnboundLocalError
0430 22:01:47205 :: : 
0430 22:01:47205 :: local variable 'whisper_message' referenced before assignment
0430 22:01:47205 :: 

when I try to send the message I get this error.. Is there anything that you left from the tutorial? I checked twice that everything is correct, that i inserted

Link to comment
Share on other sites

  • 5 months later...

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.