[PYTHON]Sohbet Penceresine Level ve Saat Eklemek(Fısıltı)

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 46

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
@ ; un konusunu inceledim, uğraştım ikisini birleştirdim.İnşallah işinize yarar.

Root uiwhisper.py
Aratılır;


Kod:
[COLOR=#0000cd][B][FONT=Verdana]def SendWhisper(self): [/FONT][/B][/COLOR]

Full Değiştirilir; Renkli Yapmak İsteyenler:
Renksiz Yapmak İsteyenler:
Kod:
[COLOR=#0000cd][FONT=Verdana]def SendWhisper(self):[/FONT] [FONT=Verdana]import time[/FONT] [FONT=Verdana]import player[/FONT] [FONT=Verdana]text = self.chatLine.GetText()[/FONT] [FONT=Verdana]textLength = len(text)[/FONT] [FONT=Verdana]if textLength > 0:[/FONT] [FONT=Verdana]if net.IsInsultIn(text):[/FONT] [FONT=Verdana]chat.AppendChat(chat.CHAT_TYPE_INFO, locale.CHAT_INSULT_STRING)[/FONT] [FONT=Verdana]return[/FONT] [FONT=Verdana]VectorsSaat = time.strftime("%H:%M:%S")[/FONT] [FONT=Verdana]net.SendWhisperPacket(self.targetName, "|cffADFF2F[Saat" + VectorsSaat + "|cFF00FFFF|h[Lv" + str(player.GetStatus(player.LEVEL)) + "]|cffffcc00: " + text)[/FONT] [FONT=Verdana]self.chatLine.SetText("")[/FONT] [FONT=Verdana]chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, self.targetName, player.GetName() + "|cffADFF2F[Saat" + VectorsSaat + "|cFF00FFFF|h[Lv" + str(player.GetStatus(player.LEVEL)) + "]|cffffcc00: " + text)[/FONT][/COLOR]



Not:renkli yapınca mesaj yazarken gerekli eşya:içgörü_küresi derse renksiz yapın

Bu arada renk kodları burada isteyen editler:
Yazı renk kodları:
GRİ -> â|cff888888â³
BEYAZ -> â|cFFFFFFFFâ
SARI -> â|cffffff00â³
MAVİ -> â|cff0000ffâ
YEŞİL -> â|cff00ff00â³
KIRMIZI -> â|cffff0000â³
SİYAH -> â|cFF000000â³
KAHVERENGİ -> â|cFFA52A2Aâ
PEMBE -> â|cFF800080â³

LIGHTRED - |cffff6060
LIGHTBLUE - |cff00ccff
TORQUISEBLUE - |cff00C78C
SPRINGGREEN - |cff00FF7F
GREENYELLOW - |cffADFF2F
Mavi - |cff0000ff
Mor - |cffDA70D6
YEşil - |cff00ff00
RED - |cffff0000
Altın - |cffffcc00
Altın2 - |cffFFC125
GRİ - |cff888888
Beyaz - |cffffffff
SUBWHITE - |cffbbbbbb
MAGENTA - |cffff00ff
YELLOW - |cffffff00
ORANGEY - |cffFF4500
CHOCOLATE - |cffCD661D
CYAN - |cff00ffff
IVORY - |cff8B8B83
LIGHTYELLOW - |cffFFFFE0

[PYTHON]Sohbet Penceresine Level ve Saat Eklemek(Fısıltı)

Metin2 özel sunucu geliştirmeleri yaparken kullanıcı deneyimini artırmak oldukça önemlidir. Bu yazıda, Python kullanarak sohbet penceresine level ve saat bilgisini nasıl ekleyeceğimizi ele alacağız. Özellikle fısıltı (whisper) sistemine entegre edilecek bu özellik, kullanıcıların sohbet ettiği kişiyle ilgili daha fazla bilgiye sahip olmasını sağlar. Bu sayede sunucu tarafında daha profesyonel bir yapı kurulabilir.

Python GUI üzerinde çalışırken, UIScript ve PY ROOT dosyalarıyla etkileşim kurmak gerekir. Öncelikle mevcut sohbet sistemine müdahale etmeden, level ve saat gibi bilgileri mesajın başına veya sonuna eklemek için bir yol bulmamız gerekir. Genellikle whisper mesajları ChatPacket üzerinden gönderilir ve bu paketler üzerinden mesaj içeriği oynatılabilir.

Öncelikle, mevcut whisper fonksiyonunu inceleyelim. Whisper mesajları genellikle client tarafında net.SendWhisperPacket fonksiyonu aracılığıyla gönderilir. Biz bu fonksiyona müdahale ederek level ve saat bilgilerini ekleyebiliriz. Ancak sadece göndericiye değil, alıcıya da bu bilgilerin ulaşması gerekir. Bunun için hem client hem de auth-server tarafında değişiklikler yapılması gerekir.

Py Root klasöründe yer alan chat.py dosyasında, whisper ile ilgili fonksiyonlar bulunur. Bu dosyada yer alan OnRecvWhisperPacket fonksiyonu, gelen fısıltı mesajlarını yakalar. Burada level ve saat bilgilerini ayrıştırarak ekrana yazdırabiliriz. Saat bilgisi için datetime modülünü kullanabiliriz. Örneğin:

Kod:
import datetime[BR][/BR]timestamp = datetime.datetime.now().strftime('%H:%M')[BR][/BR]formatted_message = f'[{level}] [{timestamp}] {message}'


Bu şekilde, her gelen whisper mesajının önüne level ve saat bilgisi eklenmiş olur. Tabii ki bu bilgilerin server tarafından gönderilmesi gerekir. Auth-server tarafında, oyuncuların level bilgileri zaten mevcuttur. Bu nedenle, whisper mesajı ile birlikte level bilgisini de göndermek mümkündür.

UIScript tarafında ise, chat window bileşeni üzerinde değişiklik yaparak bu bilgileri görsel olarak daha belirgin hale getirebiliriz. Örneğin level bilgisini yeşil renkte, saat bilgisini mavi renkte gösterebiliriz. Böylece kullanıcılar mesajın ne zaman geldiğini ve kimden geldiğini hızlıca anlayabilirler.

Bu işlem için chatWindow.py dosyasında, mesaj yazdırma fonksiyonlarını düzenlemek yeterlidir. Mesela, AppendChat fonksiyonuna bir filtre ekleyip, gelen mesajı önce parse edip ardından ekrana yazdırabiliriz.

Bu yöntemle, Metin2 özel sunucularında kullanıcı dostu bir sohbet sistemi oluşturulabilir. Ayrıca, bu yapı başka sistemlere de kolayca adapte edilebilir. Örneğin guild sohbetlerinde de benzer şekilde level ve saat bilgisi gösterilebilir.

Bu tip geliştirmeler, kullanıcıların sunucuya olan bağlılığını artırır. Aynı zamanda, C++ ile yazılmış server-side sistemlerle Python GUI arasında veri aktarımı yapabilmek, Metin2 geliştiricileri için oldukça değerlidir. Bu tür küçük ama etkili değişiklikler, sunucunuzun diğerlerinden fark çıkarmasını sağlar.


[PYTHON]Adding Level and Time to Chat Window (Whisper)

Developing Metin2 private server requires attention to user experience. In this article, we will explain how to add level and time information to the chat window using Python. Especially when integrated into the whisper system, this feature allows users to have more information about the person they are chatting with. This helps build a more professional structure on the server side.

When working with Python GUI, interaction with UIScript and PY ROOT files is required. First, without interfering with the current chat system, we need to find a way to append level and time information either at the beginning or end of messages. Generally, whisper messages are sent via ChatPacket, and these packets can be manipulated to enhance the message content.

Firstly, let's examine the existing whisper function. Whisper messages are usually sent through the net.SendWhisperPacket function on the client side. We can modify this function to include level and time information. However, not only the sender but also the receiver must receive this information. Therefore, modifications on both client and auth-server sides are necessary.

In the Py Root folder, the chat.py file contains functions related to whisper. The OnRecvWhisperPacket function catches incoming whisper messages. Here, we can parse and display the level and time information. For time information, we can use the datetime module. For example:

Kod:
import datetime[BR][/BR]timestamp = datetime.datetime.now().strftime('%H:%M')[BR][/BR]formatted_message = f'[{level}] [{timestamp}] {message}'


This way, the level and time information will be prepended to each incoming whisper message. Of course, this information needs to be sent by the server. On the auth-server side, player level information already exists. Therefore, sending the level along with the whisper message is possible.

On the UIScript side, we can make these details more visually distinct by modifying the chat window component. For instance, the level can be displayed in green, and the time in blue. This allows users to quickly see when and from whom the message was received.

To achieve this, we can modify the message printing functions in the chatWindow.py file. For example, we can add a filter to the AppendChat function to parse the incoming message before displaying it.

With this method, a user-friendly chat system can be built for Metin2 private servers. Additionally, this structure can easily be adapted to other systems. For example, level and time information can also be shown in guild chats.

Such improvements increase user engagement with the server. Moreover, being able to transfer data between the Python GUI and C++-based server-side systems is highly valuable for Metin2 developers. Such small yet impactful changes help your server stand out.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Benzer konular

Geri
Üst Alt