[C++ / Python] İtem Trash Sistemi

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Merhaba,

Farklı bir forumdan alıntıdır, eğer item sil sat sistemini kullanmak istemiyor daha farklı yalnızca silme sistemi istiyorsanız uygun bir sistem tercihi olacaktır.

VirusTotal :

200534_a1b18174a64b9302ad770e1d81b35122.png


Not : Çalışıp çalışmadığı test edildi yalnızca, sistemin harici bir problemi var mı bilmemekteyim.
Metin2 Lobby olarak sunucu geliştirme konusunda uzmanlaşmış bir platform olarak, C++ ve Python tabanlı Item Trash Sistemi geliştirmek isteyen geliştiriciler için kapsamlı bir rehber hazırladık. Bu sistem, oyuncuların envanterinde yer almayan veya silmek istedikleri eşyaların geçici olarak depolandığı ve daha sonra geri alınabildiği ya da kalıcı olarak silindiği gelişmiş bir özelliktir. Bu yazıda hem C++ hem de Python tarafında nasıl entegre edileceği detaylıca anlatılacaktır.

Item Trash Sistemi Nedir?
Item Trash Sistemi, oyuncuların belirli eşyaları silmek yerine bir çöp kutusuna atarak, belirli bir süre boyunca erişimine açık tuttukları bir özelliktir. Bu sayede yanlışlıkla silinen eşyalar kolayca geri kazanılabilir. Bu sistem genellikle client-side (py) ve server-side (game/src) arasında senkronize çalışarak veritabanında saklanır.

Python Tarafında Uygulama (Py Root & UIScript)
Python tarafında bu sistemi entegre etmek için öncelikle bir arayüz (UI Script) tasarlamalısınız. Bu arayüzde, çöpe atılan eşyalar listelenir ve kullanıcılar bu eşyaları geri alabilir veya kalıcı olarak silebilirler. uiscript klasöründe yeni bir arayüz dosyası oluşturarak, trash_item_list.py gibi bir yapı kurabilirsiniz. Burada python GUI sınıflarını kullanarak butonlar, liste kutuları ve zamanlayıcılar tanımlayabilirsiniz.

Örnek Python Kod Yapısı:
Kod:
[B]import ui, net, player, item[/B][BR][/BR][B]class TrashWindow(ui.ScriptWindow):[/B][BR][/BR][B]def __init__(self):[/B][BR][/BR][B]ui.ScriptWindow.__init__(self)[/B][BR][/BR][B]self.LoadWindow()[/B][BR][/BR][B]def LoadWindow(self):[/B][BR][/BR][B]# UI setup logic here[/B][BR][/BR][B]pass[/B][BR][/BR][B]def OnCloseButton(self):[/B][BR][/BR][B]net.SendChatPacket('/close_trash')[/B][BR][/BR][B]self.Hide()[/B][/BR][/BR][B]def Show(self):[/B][BR][/BR][B]self.SetTop()[/BR][/BR][B]self.RefreshList()[/B][BR][/BR][B]ui.ScriptWindow.Show(self)[/B][/BR][/BR][B]


C++ Tarafında Uygulama (Game Server Src)
C++ tarafında sistem, game/src klasöründe yer alan char.cpp, item_manager.cpp gibi dosyalarda genişletilmelidir. Yeni bir komut tanımlamalısınız. Örneğin, '/trash_item' komutu ile bir eşya çöpe gönderilebilir. Bu işlem sırasında eşya, geçici olarak bir veritabanı tablosunda saklanır. Bu tablo genellikle player.trash_items gibi bir yapıda olur ve bir zaman aşımı süresiyle birlikte saklanır.

Veritabanı Yapısı Örneği:
CREATE TABLE trash_items (
id INT AUTO_INCREMENT PRIMARY KEY,
player_id INT NOT NULL,
item_vnum INT NOT NULL,
count SMALLINT DEFAULT 1,
time_left INT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Güvenlik ve Performans Notları:
Sistem tasarımı sırasında SQL injection gibi güvenlik açıklarına dikkat etmelisiniz. Ayrıca, trash_items tablosu zamanla büyüyebilir, bu yüzden periyodik temizlik süreçleri tanımlamalısınız. Martysama ve diğer geliştirici toplulukları üzerinden örnek sistemler inceleyebilirsiniz.

Sonuç:[/BR][/BR]Item Trash Sistemi, Metin2 özel sunucularında kullanıcı deneyimini artıran önemli bir özelliktir. Hem client-side hem de server-side doğru şekilde entegre edildiğinde, güvenli ve kullanıcı dostu bir sistem ortaya çıkar. Geliştiriciler bu yapıyı db core, game core ve auth sistemlerine uyumlu şekilde kurabilirler. Metin2Lobby olarak bu gibi gelişmiş sistemlerin kaynak kodlarını paylaşmaya devam edeceğiz.


Metin2 Lobby as a platform specialized in server development, we have prepared a comprehensive guide for developers who want to develop an Item Trash System based on C++ and Python. This system is an advanced feature where items that players do not have space for in their inventory or wish to delete are temporarily stored and can later be retrieved or permanently deleted. In this article, we will explain in detail how to implement it on both C++ and Python sides.

What is an Item Trash System?
The Item Trash System is a feature allowing players to place certain items into a trash bin instead of deleting them, keeping these items accessible for a specific period. This way, items accidentally deleted can easily be recovered. The system typically operates by synchronizing between the client-side (py) and server-side (game/src) and storing the items in a database.

Implementation in Python (Py Root & UIScript)
To integrate this system in Python, you first need to design a user interface (UI Script). Within this interface, the trashed items will be listed, and users can either retrieve or permanently delete them. By creating a new UI file in the uiscript folder, such as trash_item_list.py, you can define buttons, list boxes, and timers using Python GUI classes.

Sample Python Code Structure:
Kod:
[B]import ui, net, player, item[/B][BR][/BR][B]class TrashWindow(ui.ScriptWindow):[/B][BR][/BR][B]def __init__(self):[/B][BR][/BR][B]ui.ScriptWindow.__init__(self)[/B][BR][/BR][B]self.LoadWindow()[/B][BR][/BR][B]def LoadWindow(self):[/B][BR][/BR][B]# UI setup logic here[/B][BR][/BR][B]pass[/B][BR][/BR][B]def OnCloseButton(self):[/B][BR][/BR][B]net.SendChatPacket('/close_trash')[/B][BR][/BR][B]self.Hide()[/B][/BR][/BR][B]def Show(self):[/B][BR][/BR][B]self.SetTop()[/BR][/BR][B]self.RefreshList()[/B][BR][/BR][B]ui.ScriptWindow.Show(self)[/B][/BR][/BR][B]


Implementation in C++ (Game Server Src)
On the C++ side, the system must be extended within files located in the game/src folder, such as char.cpp, item_manager.cpp. You should define a new command, for example, '/trash_item', which sends an item to the trash. During this process, the item is temporarily stored in a database table. Typically, this table follows a structure like player.trash_items and includes a timeout duration.

Sample Database Structure:
CREATE TABLE trash_items (
id INT AUTO_INCREMENT PRIMARY KEY,
player_id INT NOT NULL,
item_vnum INT NOT NULL,
count SMALLINT DEFAULT 1,
time_left INT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Security and Performance Notes:
During system design, you must pay attention to security vulnerabilities such as SQL injection. Additionally, the trash_items table may grow over time, so periodic cleanup processes should be implemented. You can examine sample systems through developer communities like Martysama.

Conclusion:[/BR][/BR]The Item Trash System is an important feature that enhances the user experience in Metin2 private servers. When properly integrated on both client-side and server-side, it creates a secure and user-friendly system. Developers can install this structure compatibly with db core, game core, and auth systems. At Metin2Lobby, we will continue to share source codes for such advanced systems.
 

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

Benzer konular

Geri
Üst Alt