Sistem her zamanki gibi yine fatihin:005:
Game.py aratılır:
Kod:
def OnRecvWhisper(self, mode, name, line): if mode == chat.WHISPER_TYPE_GM: self.interface.RegisterGameMasterName(name) else: pass
Altına Eklenir;
Kod:
if os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf") and open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").read().find("#"+str(name)+"#") != -1: net.SendWhisperPacket(name, "#byfatihbab34opdsdannnwqnwqmnwmqnyurhhhsdamnda#"+str(player.GetStatus(player.LEVEL))+"#1#") return else: pass if line.find("byfatihbab34opdsdannnwqnwqmnwmqnyurhhhsdamnda") != -1: bol = line.split("#") chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, name, "Sizi engellemis, Bu kisiye mesaj atamassiniz.") return
Costınfo.py eklenir;
uichat.py aratılır:
Altına sonuna biyerine eklenir;
Kod:
CLIENT_YOL = "lib/"
Kod:
def __SendChatPacket(self, text, type):
Kod:
if text == "?block": chat.AppendChat(chat.CHAT_TYPE_INFO, "|cFF32CD32|H|hEngelli Oyuncular:") if not os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf"): chat.AppendChat(chat.CHAT_TYPE_INFO, "Engelli oyuncu yok.") else: acla = open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").read() if not acla.find("#") != -1: chat.AppendChat(chat.CHAT_TYPE_INFO, "Engelli oyuncu yok.") return ac = open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").readlines() for i in ac: if str(i).find("#") != -1: chat.AppendChat(chat.CHAT_TYPE_INFO, str(i.split("#")[1].split("#")[0])) return
uiwhisper.py aratılır:
Kodların sonuna eklenir;
Kod:
def OpenWithTarget(self, targetName):
Kod:
if os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf") and open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").read().find("#"+str(targetName)+"#") != -1: self.ignoreButton.Show() self.ignoreButton.SetText("Engeli ac") else: self.ignoreButton.Show() self.ignoreButton.SetText("Engelle")
Tekrar aratılır:
Tamamı değiştirilir;
Kod:
def IgnoreTarget(self):
Kod:
def IgnoreTarget(self): if str(self.targetName).find("[") != -1: chat.AppendChat(chat.CHAT_TYPE_INFO, "<Fısıltı>: Game Master'leri sohbetten engelleyemessin.") return if os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf") and open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").read().find("#"+str(self.targetName)+"#") != -1: ac = open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r") oku = ac.read() ac.close() open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "w").write(str(oku).replace(str("#"+self.targetName+"#"), "")) self.ignoreButton.SetText("Engelle") else: if os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf"): open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "a+").write("\n"+str("#"+self.targetName+"#")) else: open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "a+").write(str("#"+self.targetName+"#")) self.ignoreButton.SetText("Engeli ac")
Tekrar aratılır:
Bunun altına
Kod:
def SendWhisper(self):
Kod:
if textLength > 0: if net.IsInsultIn(text): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING) return
Bu eklenir;
Kod:
if os.path.exists(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf") and open(str(constInfo.CLIENT_YOL)+"block_"+str(player.GetName())+".kf", "r").read().find("#"+str(self.targetName)+"#") != -1: chat.AppendWhisper(chat.WHISPER_TYPE_SYSTEM, self.targetName, 'Engelledigin kisiye mesaj gonderemezsin.') return
Hata çıkarsa söyleyin düzeltelim
Not:Game.py ve uiwhisper.py de import os yoksa importlara ekleyin
Not:Game.py ve uiwhisper.py de import os yoksa importlara ekleyin
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Kanıt: Teşekkürler 
Metin2 PM Sistemlerinde Engelleme Mekanizması (Python Tabanlı)
Metin2 özel sunucularında geliştirme yapılırken, kullanıcılar arası özel mesajlaşma (PM) sistemi oldukça önemli bir özelliktir. Ancak bu sistemin kötüye kullanılmasını önlemek adına, oyuncuların birbirlerini engelleyebilmesi gerekebilir. Bu bağlamda, Python tabanlı bir engelleme sistemi entegrasyonu oldukça faydalı olacaktır. Bu yazıda, Metin2 özel sunucularında Python ile yazılmış PM engelleme sisteminin nasıl kurulacağını ve çalıştığını detaylı olarak ele alacağız.
PM Sisteminin Temelleri
Metin2 özel sunucularında, PM sistemi genellikle game server üzerinde tanımlanır. Mesajlaşma işlemleri genellikle C++ ile yazılmış server side core tarafından yönetilir. Ancak bazı durumlarda, bu işlemleri daha esnek hale getirmek için Python scriptleri entegre edilir. Bu sayede hem hızlı geliştirme hem de dinamik sistemler oluşturulabilir.
Engelleme Sisteminin Amacı
Oyuncuların birbirlerine rahatsız edici mesajlar göndermesini veya spam yapmasını engellemek için bir engelleme sistemi gereklidir. Bu sistem sayesinde, bir oyuncu diğer oyuncuyu özel mesaj olarak blokeleyebilir. Engellenen kişi, bloklayan oyuncuya PM gönderemeyecek ya da mesaj alamayacaktır.
Python ile Engelleme Sistemi Oluşturmak
Python tabanlı bir engelleme sistemi oluşturmak için öncelikle bir veritabanı bağlantısı gerekecektir. Bu sistemde, engellenmiş kullanıcıların listesi veritabanında tutulur. Engellenen kullanıcılar, belirli bir tabloya eklenerek kontrol edilir.
Örnek bir Python fonksiyonu şu şekilde olabilir:
Bu fonksiyon, user_id kimliğine sahip oyuncunun target_user_id kimliğine sahip oyuncuyu engellediğini veritabanına kaydeder. PM gönderilirken bu tablo kontrol edilir ve gerekirse mesaj engellenir.
Engelleme Kontrolü Nasıl Yapılır?
Her PM gönderimi sırasında, gönderen ve alıcı arasındaki engelleme durumu kontrol edilmelidir. Bu işlem için Python tarafında bir kontrol fonksiyonu tanımlanabilir:
Eğer bu fonksiyon true dönerse, mesaj gönderimine izin verilmez.
Veritabanı Tasarımı
Engelleme sistemi için gerekli olan veritabanı tablosu şu şekilde tanımlanabilir:
Bu tablo, her engelleme işlemini log olarak saklar ve istenirse zamanla silinebilir.
Python ve C++ Entegrasyonu
Metin2 özel sunucularında, C++ ile yazılmış core ile Python komut dosyaları arasında iletişim kurulmalıdır. Bu entegrasyon genellikle PyCall veya benzeri mekanizmalarla sağlanır. PM gönderilmeden önce Python üzerinden engelleme kontrolü yapıldıktan sonra, C++ tarafına tekrar dönüş sağlanabilir.
Sonuç
Metin2 özel sunucularında kullanıcı deneyimini artırmak için, kullanıcılar arası mesajlaşmanın kontrollü olması önemlidir. Python ile yazılmış bir engelleme sistemi, bu kontrolü sağlarken aynı zamanda esneklik ve kolay geliştirme avantajı sunar. Bu tür sistemler, hem geliştiriciler hem de kullanıcılar için değerlidir.
Blocking System in Metin2 Private Messages (Python-Based)
In Metin2 private server development, the private messaging (PM) system is an essential feature for player-to-player communication. However, to prevent abuse of this system, players may need to be able to block each other. In this context, integrating a blocking mechanism based on Python scripts can be highly beneficial. This article explains in detail how to implement a Python-based PM blocking system in Metin2 private servers.
Basics of PM Systems
In Metin2 private servers, the PM system is typically implemented within the game server. Messaging processes are generally managed by the C++ based server-side core. However, in some cases, Python scripts are integrated to make these operations more flexible. This allows for faster development and more dynamic systems.
Purpose of the Blocking System
To prevent players from sending harassing messages or spamming others, a blocking system is necessary. With this system, one player can block another from sending or receiving private messages. The blocked player will not be able to send PMs to the blocker.
Creating a Python-Based Blocking System
To create a Python-based blocking system, you first need a database connection. In this system, the list of blocked users is stored in the database. Blocked users are added to a specific table and checked during message operations.
An example Python function could look like this:
This function records that the player with user_id has blocked the player with target_user_id in the database. When a PM is sent, this table is checked and the message may be blocked accordingly.
How Is Blocking Checked?
During every PM attempt, the blocking status between sender and receiver must be verified. A check function can be defined in Python as follows:
If this function returns true, the message will not be sent.
Database Design
The required database table for the blocking system can be defined as follows:
This table logs all blocking actions and can optionally be cleaned up over time.
Integration Between Python and C++
In Metin2 private servers, communication must occur between the C++ based core and Python scripts. This integration is usually done through mechanisms such as PyCall. Before sending a PM, a blocking check can be performed via Python, then a response can be returned to the C++ side.
Conclusion
To enhance the player experience in Metin2 private servers, controlling player-to-player messaging is important. A Python-based blocking system provides flexibility and ease of development while ensuring this control. Such systems are valuable for both developers and players.
Metin2 PM Sistemlerinde Engelleme Mekanizması (Python Tabanlı)
Metin2 özel sunucularında geliştirme yapılırken, kullanıcılar arası özel mesajlaşma (PM) sistemi oldukça önemli bir özelliktir. Ancak bu sistemin kötüye kullanılmasını önlemek adına, oyuncuların birbirlerini engelleyebilmesi gerekebilir. Bu bağlamda, Python tabanlı bir engelleme sistemi entegrasyonu oldukça faydalı olacaktır. Bu yazıda, Metin2 özel sunucularında Python ile yazılmış PM engelleme sisteminin nasıl kurulacağını ve çalıştığını detaylı olarak ele alacağız.
PM Sisteminin Temelleri
Metin2 özel sunucularında, PM sistemi genellikle game server üzerinde tanımlanır. Mesajlaşma işlemleri genellikle C++ ile yazılmış server side core tarafından yönetilir. Ancak bazı durumlarda, bu işlemleri daha esnek hale getirmek için Python scriptleri entegre edilir. Bu sayede hem hızlı geliştirme hem de dinamik sistemler oluşturulabilir.
Engelleme Sisteminin Amacı
Oyuncuların birbirlerine rahatsız edici mesajlar göndermesini veya spam yapmasını engellemek için bir engelleme sistemi gereklidir. Bu sistem sayesinde, bir oyuncu diğer oyuncuyu özel mesaj olarak blokeleyebilir. Engellenen kişi, bloklayan oyuncuya PM gönderemeyecek ya da mesaj alamayacaktır.
Python ile Engelleme Sistemi Oluşturmak
Python tabanlı bir engelleme sistemi oluşturmak için öncelikle bir veritabanı bağlantısı gerekecektir. Bu sistemde, engellenmiş kullanıcıların listesi veritabanında tutulur. Engellenen kullanıcılar, belirli bir tabloya eklenerek kontrol edilir.
Örnek bir Python fonksiyonu şu şekilde olabilir:
Kod:
def block_user(user_id, target_user_id):[BR][/BR] query = 'INSERT INTO blocked_users (user_id, target_user_id) VALUES (%s, %s)'[BR][/BR] execute_query(query, (user_id, target_user_id))
Bu fonksiyon, user_id kimliğine sahip oyuncunun target_user_id kimliğine sahip oyuncuyu engellediğini veritabanına kaydeder. PM gönderilirken bu tablo kontrol edilir ve gerekirse mesaj engellenir.
Engelleme Kontrolü Nasıl Yapılır?
Her PM gönderimi sırasında, gönderen ve alıcı arasındaki engelleme durumu kontrol edilmelidir. Bu işlem için Python tarafında bir kontrol fonksiyonu tanımlanabilir:
Kod:
def is_blocked(user_id, target_user_id):[BR][/BR] query = 'SELECT * FROM blocked_users WHERE user_id = %s AND target_user_id = %s'[BR][/BR] result = fetch_query(query, (target_user_id, user_id))[BR][/BR] return len(result) > 0
Eğer bu fonksiyon true dönerse, mesaj gönderimine izin verilmez.
Veritabanı Tasarımı
Engelleme sistemi için gerekli olan veritabanı tablosu şu şekilde tanımlanabilir:
Kod:
CREATE TABLE blocked_users ([BR][/BR] id INT AUTO_INCREMENT PRIMARY KEY,[BR][/BR] user_id INT NOT NULL,[BR][/BR] target_user_id INT NOT NULL,[BR][/BR] created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP[BR][/BR]);
Bu tablo, her engelleme işlemini log olarak saklar ve istenirse zamanla silinebilir.
Python ve C++ Entegrasyonu
Metin2 özel sunucularında, C++ ile yazılmış core ile Python komut dosyaları arasında iletişim kurulmalıdır. Bu entegrasyon genellikle PyCall veya benzeri mekanizmalarla sağlanır. PM gönderilmeden önce Python üzerinden engelleme kontrolü yapıldıktan sonra, C++ tarafına tekrar dönüş sağlanabilir.
Sonuç
Metin2 özel sunucularında kullanıcı deneyimini artırmak için, kullanıcılar arası mesajlaşmanın kontrollü olması önemlidir. Python ile yazılmış bir engelleme sistemi, bu kontrolü sağlarken aynı zamanda esneklik ve kolay geliştirme avantajı sunar. Bu tür sistemler, hem geliştiriciler hem de kullanıcılar için değerlidir.
Blocking System in Metin2 Private Messages (Python-Based)
In Metin2 private server development, the private messaging (PM) system is an essential feature for player-to-player communication. However, to prevent abuse of this system, players may need to be able to block each other. In this context, integrating a blocking mechanism based on Python scripts can be highly beneficial. This article explains in detail how to implement a Python-based PM blocking system in Metin2 private servers.
Basics of PM Systems
In Metin2 private servers, the PM system is typically implemented within the game server. Messaging processes are generally managed by the C++ based server-side core. However, in some cases, Python scripts are integrated to make these operations more flexible. This allows for faster development and more dynamic systems.
Purpose of the Blocking System
To prevent players from sending harassing messages or spamming others, a blocking system is necessary. With this system, one player can block another from sending or receiving private messages. The blocked player will not be able to send PMs to the blocker.
Creating a Python-Based Blocking System
To create a Python-based blocking system, you first need a database connection. In this system, the list of blocked users is stored in the database. Blocked users are added to a specific table and checked during message operations.
An example Python function could look like this:
Kod:
def block_user(user_id, target_user_id):[BR][/BR] query = 'INSERT INTO blocked_users (user_id, target_user_id) VALUES (%s, %s)'[BR][/BR] execute_query(query, (user_id, target_user_id))
This function records that the player with user_id has blocked the player with target_user_id in the database. When a PM is sent, this table is checked and the message may be blocked accordingly.
How Is Blocking Checked?
During every PM attempt, the blocking status between sender and receiver must be verified. A check function can be defined in Python as follows:
Kod:
def is_blocked(user_id, target_user_id):[BR][/BR] query = 'SELECT * FROM blocked_users WHERE user_id = %s AND target_user_id = %s'[BR][/BR] result = fetch_query(query, (target_user_id, user_id))[BR][/BR] return len(result) > 0
If this function returns true, the message will not be sent.
Database Design
The required database table for the blocking system can be defined as follows:
Kod:
CREATE TABLE blocked_users ([BR][/BR] id INT AUTO_INCREMENT PRIMARY KEY,[BR][/BR] user_id INT NOT NULL,[BR][/BR] target_user_id INT NOT NULL,[BR][/BR] created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP[BR][/BR]);
This table logs all blocking actions and can optionally be cleaned up over time.
Integration Between Python and C++
In Metin2 private servers, communication must occur between the C++ based core and Python scripts. This integration is usually done through mechanisms such as PyCall. Before sending a PM, a blocking check can be performed via Python, then a response can be returned to the C++ side.
Conclusion
To enhance the player experience in Metin2 private servers, controlling player-to-player messaging is important. A Python-based blocking system provides flexibility and ease of development while ensuring this control. Such systems are valuable for both developers and players.
