Görsel,
uiscript ' e atılacak dosya için,
İNDİR:
VT:
Kod:
# Ekle HADES_ASK_DESTROY You're sure you want to destroy this object?
Kod:
# Sona ekle class Hades_QuestionDialogDestroy(QuestionDialog2): def __init__(self): ui.ScriptWindow.__init__(self) self.__CreateDialog() def __del__(self): QuestionDialog2.__del__(self) def __CreateDialog(self): pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "uiscript/hades_question_dialog_destroy.py") self.board = self.GetChild("board") self.textLine = self.GetChild("destroy") self.acceptButton = self.GetChild("accept") self.cancelButton = self.GetChild("cancel") def Open(self, timeout): self.SetCenterPosition() self.SetTop() self.Show() self.endTime = app.GetTime() + timeout def Close(self): self.Hide()
Kod:
# Arat def RequestDropItem(self, answer): # Kod bloğundan sonra ekle def RequestDestroyItem(self): self.itemDropQuestionDialog.Close() self.Hades_QuestionDialog = uiCommon.Hades_QuestionDialogDestroy() self.Hades_QuestionDialog.Open(1) self.Hades_QuestionDialog.SetAcceptText(localeInfo.UI_ACCEPT) self.Hades_QuestionDialog.SetCancelText(localeInfo.UI_DENY) self.Hades_QuestionDialog.SetAcceptEvent(lambda arg = True: self.__RequestDestroyItem(arg)) self.Hades_QuestionDialog.SetCancelEvent(lambda arg = False: self.__RequestDestroyItem(arg)) def __RequestDestroyItem(self, answer): if not self.Hades_QuestionDialog: return if answer: dropType = self.itemDropQuestionDialog.dropType dropNumber = self.itemDropQuestionDialog.dropNumber if player.SLOT_TYPE_INVENTORY == dropType: if dropNumber == player.ITEM_MONEY: return else: self.__SendDestroyItemPacket(dropNumber) self.Hades_QuestionDialog.Close() self.Hades_QuestionDialog = None # Arat def __DropItem(self, attachedType, attachedItemIndex, attachedItemSlotPos, attachedItemCount): # Ekle itemDropQuestionDialog.SetDestroyEvent(lambda arg=True: self.RequestDestroyItem())
uiscript ' e atılacak dosya için,
İNDİR:
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
VT:
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
[Python] Eşyaları Silmeden Önce Sor
Metin2 özel sunucularında güvenli sistem yönetimi için Python tabanlı eşya silme işlemi öncesi onay mekanizması nasıl yapılır?
Metin2 özel sunucu geliştirme sürecinde, oyuncuların hatalı veya istemeden silebileceği eşyalar konusunda dikkatli hareket etmek büyük önem taşır. Özellikle Python dilini kullanarak geliştirilen py GUI arayüzleriyle, kullanıcı dostu ve güvenli sistemler kurulabilir. Bu yazıda, eşyaları silmeden önce onay almayı sağlayan bir Python sistemi nasıl kurulur göreceğiz.
Neden Onay Sistemi Kullanmalıyız?
Metin2 özel sunucularında, eşya silme işlemleri genellikle doğrudan yapılır. Ancak bu, kullanıcı hatalarına yol açabilir. Örneğin, bir oyuncu yanlışlıkla bir değerli eşyayı silmek isteyebilir. Bu gibi durumlarda, bir onay penceresi gösterilmesi kullanıcıyı uyarır ve yanlış silmeleri önler.
Python GUI ile Onay Penceresi Oluşturmak[/BR][/BR]Python dilinde UIScript ve Py Root dosyaları ile arayüzler oluşturulabilir. Basit bir onay penceresi için aşağıdaki yapı kullanılabilir:
1. Onay Penceresi Tasarımı
Önce bir arayüz dosyası (.py) oluşturun. Bu dosya, onay penceresini tanımlar. Arka planda bir python GUI bileşeni çalışır. Kullanıcı 'Sil' butonuna bastığında doğrudan işlem yapılmasın. Bunun yerine, onay penceresi açılsın.
2. Silme İşlemi Öncesi Onay
Python üzerinden silme fonksiyonuna bir kontrol mekanizması eklenir. Kullanıcı silme komutunu verdiğinde, bir pencere açılır: 'Bu eşyayı gerçekten silmek istiyor musunuz?' Bu pencere evet/hayır seçenekleri içerir. Kullanıcı 'Evet' seçeneğini seçerse işlem tamamlanır.
Hata Yönetimi ve Güvenlik[/BR][/BR]Herhangi bir system geliştirme aşamasında hata yönetimi kritik öneme sahiptir. Bu sistemde, kullanıcı 'Hayır' derse, işlem iptal edilmelidir. Ayrıca, sunucu tarafında da bir kontrol yapılması önerilir. Bu sayede güvenlik açıklarının önüne geçilir.
Python ile Entegrasyon[/BR][/BR]Bu tür bir sistem, Metin2 Lobby tarzı platformlarda geliştirilen özel sunucularda yaygın olarak kullanılmaktadır. Python dilinin esnek yapısı sayesinde, hem game server hem de auth server üzerinde entegre çözümler geliştirilebilir. Py Root ve UIScript dosyaları sayesinde bu süreç kolayca yönetilebilir.
Sonuç[/BR][/BR]Oyuncu deneyimini artırmak ve hatalı silmeleri önlemek adına, Python tabanlı onay sistemleri büyük fayda sağlar. Bu tür sistemler, Metin2 özel sunucularında PvP sistemlerin de daha güvenli ve kontrollü çalışmasına yardımcı olur. Geliştiriciler, bu yapıyı core sistemlere entegre ederek hem kullanıcı dostu hem de güvenli çözümler sunabilirler.
[Python] Ask Before Deleting Items
How to create a confirmation mechanism before deleting items with a Python-based system for safe management of Metin2 private servers?
In the process of developing Metin2 private servers, it is very important to be careful about items that players might accidentally or mistakenly delete. Especially by using interfaces created with the Python language, such as py GUI, user-friendly and secure systems can be established. In this article, we will see how to set up a Python system that asks for confirmation before deleting items.
Why Should We Use a Confirmation System?
In Metin2 private servers, item deletion operations are usually done directly. However, this can lead to user errors. For example, a player may accidentally attempt to delete a valuable item. In such cases, displaying a confirmation window alerts the user and prevents unintended deletions.
Creating a Confirmation Window with Python GUI[/BR][/BR]In the Python language, interfaces can be created using UIScript and Py Root files. A simple confirmation window structure can be used as follows:
1. Designing the Confirmation Window
First, create an interface file (.py). This file defines the confirmation window. A python GUI component runs in the background. When the user presses the 'Delete' button, the action should not execute directly. Instead, a confirmation window should open.
2. Confirmation Before Deletion
A control mechanism is added to the deletion function via Python. When the user attempts to delete an item, a window appears: 'Are you sure you want to delete this item?' This window includes yes/no options. If the user selects 'Yes', the operation proceeds.
Error Handling and Security[/BR][/BR]Error handling is critical at every stage of system development. In this system, if the user selects 'No', the operation must be canceled. Additionally, a check on the server side is recommended. This helps prevent security vulnerabilities.
Integration with Python[/BR][/BR]Such systems are widely used in private servers developed on platforms like Metin2 Lobby. Thanks to the flexible nature of the Python language, integrated solutions can be developed on both game server and auth server. With Py Root and UIScript files, this process can be easily managed.
Conclusion[/BR][/BR]To enhance player experience and prevent accidental deletions, Python-based confirmation systems provide great benefits. Such systems help PvP systems in Metin2 private servers operate more securely and controllably. Developers can integrate this structure into core systems to offer both user-friendly and secure solutions.
