İmportların arasında yoksa eklenir.
Örnek ;
Bu işlemi gerçekleştirdiğinizde o buton sadece GM hesaplarda gözükecektir.
Kod:
import chr import player
Örnek ;
Kod:
if chr.IsGameMaster(player.GetMainCharacterIndex()): self.mallbutton.Show() else: self.mallbutton.Hide()
Bu işlemi gerçekleştirdiğinizde o buton sadece GM hesaplarda gözükecektir.
Python ile Metin2 Sunucusunda Sadece GM'ler İçin Görünür Buton Oluşturma
Metin2 özel sunucularında yetkilendirme sistemleri oldukça önemlidir. Özellikle sunucu yönetimi sırasında bazı kontrollerin sadece yetkili oyuncular yani Game Master (GM) kullanıcılar tarafından yapılmasını isteyebiliriz. Bu yazıda Python tabanlı GUI sistemlerinde nasıl bir butonun sadece GM kullanıcılar tarafından görülebilir hale getirebileceğimizi ele alacağız. Bu yöntem hem güvenlik açısından faydalıdır hem de kullanıcı deneyimini optimize eder.
Metin2'de GM Yetki Sistemi Nedir?
Metin2 özel sunucularında yetki seviyeleri genellikle karakter seviyesi ya da bir veritabanı değeri üzerinden belirlenir. GM kullanıcılar genellikle özel komutları, yetenekleri veya arayüz öğelerini kullanabilir. Bu yetkiler genellikle auth server, game server ve client tarafında koordine edilerek uygulanır.
Python GUI Sistemlerinde Yetki Kontrolü
Python ile geliştirilen UI Script (uiscript) dosyalarında bir butonun görünümünü kontrol etmek için öncelikle kullanıcının yetki seviyesini kontrol etmemiz gerekir. Bunun için örneğin bir karakterin yetki seviyesini veritabanından çekeriz ya da client tarafında bir değişken üzerinden tanımlarız.
Aşağıda örnek bir Python kod parçası verilmiştir:
Kod:
[B]if character_level >= 9999: # Örnek GM seviyesi[/B][BR][/BR][B] button.Show()[/B][BR][/BR][B]else:[/B][BR][/BR][B] button.Hide()[/B]
Bu yapı sayesinde buton sadece GM seviyesindeki karakterler tarafından görüntülenebilir. Yetki kontrol mekanizması auth-server ve game-server üzerinden entegre bir şekilde çalışmalıdır.
Butonun Py Root ve Pack İçerisinde Tanımlanması
Py Root klasöründe bulunan GUI dosyaları genellikle XML benzeri yapıda olup, burada tanımlanan nesneler Python kodları tarafından kontrol edilir. Bir butonun görünümü bu dosyalarda tanımlanır ve daha sonra Python tarafında yetki durumuna göre gösterilir veya gizlenir.
Ayrıca bu yapılar paketlenerek client içerisine dahil edilir. Pack dosyası içindeki ui dosyaları doğru tanımlanmışsa, buton sadece yetkili kullanıcılar tarafından görülebilir.
Güvenlik Uyarısı
Yetki kontrolünün sadece client tarafında değil, aynı zamanda server tarafında da yapılması gerekir. Aksi takdirde yetkisiz kullanıcılar client üzerinde değişiklik yaparak GM yetkilerini elde edebilirler. Bu nedenle yetki kontrolü hem client hem de server tarafında mutlaka doğrulanmalıdır.
Özet
Python ile geliştirilen Metin2 GUI sistemlerinde bir butonun sadece GM kullanıcılar tarafından görülmesi için karakterin yetki seviyesi kontrol edilmeli ve buna göre buton görünümü ayarlanmalıdır. Bu işlem py root ve pack sistemleriyle entegre bir şekilde yapılmalı ve güvenlik açısından server taraflı kontrol de unutulmamalıdır.
Implementing a GM-Only Visible Button in Python for Metin2 Servers
Authorization systems are crucial in Metin2 private servers. Especially during server management, we may want certain controls to be accessible only by authorized players, such as Game Masters (GMs). In this article, we'll explore how to make a button visible only to GM users within Python-based GUI systems. This approach is beneficial for security and helps optimize user experience.
What is the GM Authority System in Metin2?
Authority levels in Metin2 private servers are usually determined via character level or database values. GM users typically have access to special commands, abilities, or interface elements. These privileges are generally applied through coordinated operations between the auth server, game server, and client side.
Authority Control in Python GUI Systems
In Python-based UI Script (uiscript) files, to control the visibility of a button, we first need to check the user's authority level. For example, we can retrieve the character's authority level from the database or define it via a variable on the client side.
Here is an example Python code snippet:
Kod:
[B]if character_level >= 9999: # Example GM level[/B][BR][/BR][B] button.Show()[/B][BR][/BR][B]else:[/B][BR][/BR][B] button.Hide()[/B]
With this structure, the button will only be visible to characters at the GM level. The authorization mechanism must work integrated between the auth-server and game-server.
Defining the Button in Py Root and Pack Files
GUI files located in the Py Root folder are usually in an XML-like structure. Objects defined here are controlled by Python codes. The appearance of a button is defined in these files and then shown or hidden based on the authority status via Python scripts.
Additionally, these structures are packaged and included in the client. If the UI files inside the pack are correctly defined, the button will only be visible to authorized users.
Security Warning
Authority checks should not only be done on the client side but also on the server side. Otherwise, unauthorized users could gain GM privileges by modifying the client. Therefore, authority checks must be validated on both the client and server sides.
Summary
To make a button visible only to GM users in Python-based Metin2 GUI systems, the character's authority level must be checked, and the button's visibility should be set accordingly. This process must be integrated with py root and pack systems, and server-side validation must not be overlooked for security purposes.
