Jump to content

Recommended Posts

Hi. How can i edit chat like: if player sent message "hi noob" it will be shown "hi n**b". I know that i should use 

if idkwhat.find("noob") != -1:
			idkwhat = idkwhat.replace('noob', 'n**b')

but idk where should i use that in uichat or idk where. Any ideas? 

Link to comment
https://metin2.dev/topic/21196-change-chattext-by-replace-function/
Share on other sites

  • Forum Moderator

root/uiChat.py

  • def __SendChatPacket(self, text, type):

root/uiWhisper.py

  • def SendWhisper(self):

Change variable idkwhat with text.

  • Love 3
  • Active+ Member
16 hours ago, avertuss said:

Hi. How can i edit chat like: if player sent message "hi noob" it will be shown "hi n**b". I know that i should use 


if idkwhat.find("noob") != -1:
			idkwhat = idkwhat.replace('noob', 'n**b')

but idk where should i use that in uichat or idk where. Any ideas? 

Make a array like here :

 Words = ["noob", "l33t", "ggwp"]

 

for v in Words:

 if text.find(v) != -1:

   BWords = text.replace(v, '****')

 

  • Love 1
  • Forum Moderator
4 hours ago, Kori said:

BWords = text.replace(v, '****')
#text = text.replace(word, word[0] + "*" * (len(word) - 2) + word[-1])
text = text.replace(word, '{first}{filter_char}{last}'.format(
					first = word[0], filter_char = "*" * (len(word) - 2), last = word[-1]))
>>> Don't call me a l******y. 

With that type of replace you'll get asterisks by the length of your specific word, and will show just the first and the last character.

@avertuss Btw you already have CInsultChecker::FilterInsult  (which is used just for server-2-client TPacketGCChat), you can modify/duplicate the functions which are related about it and return the specific string which is detected from sentence and replace it with that method in python.

  • Active+ Member
1 hour ago, VegaS™ said:

#text = text.replace(word, word[0] + "*" * (len(word) - 2) + word[-1])
text = text.replace(word, '{first}{filter_char}{last}'.format(
					first = word[0], filter_char = "*" * (len(word) - 2), last = word[-1]))
>>> Don't call me a l******y. 

With that type of replace you'll get asterisks by the length of your specific word, and will show just the first and the last character.

@avertuss Btw you already have CInsultChecker::FilterInsult  (which is used just for server-2-client TPacketGCChat), you can modify/duplicate the functions which are related about it and return the specific string which is detected from sentence and replace it with that method in python.

Good code, yes I have typed my code on mobile phone 

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.