Süreler sadece görüntüdür.
Kodlar locale olarak verilmiştir, localeInfo kullananlar değiştirsinler.Az karakterli kodlar tab ayarsız eklenmiştir..
Root locale.py & localeInfo.py aratılır
Kod:
def GetAuxiliaryWordType(text):
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Kod:
def SehirTime(time): d, s = divmod(time, 60) ss, d = divmod(d, 60) return "%02d:%02d" % (d, s) def BuradaTime(time): d, s2 = divmod(time, 10) ss2, d = divmod(d, 10) return "%d" % (s2)
Kod:
import time import locale
Kod:
self.restartTownButton=self.GetChild("restart_town_button")
Kod:
self.sehirde_time = self.GetChild("sehirde_time") self.burada_time = self.GetChild("burada_time")
Kod:
def OpenDialog(self):
Kod:
self.sehirtime = app.GetGlobalTimeStamp() + 180 self.buradatime = app.GetGlobalTimeStamp() + 10
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Kod:
def Sehirstime(self, time): left = time - app.GetGlobalTimeStamp() if left < 0: left = 0 self.sehirde_time.SetText("%s" % locale.SehirTime(left)) def Buradastime(self, time): left = time - app.GetGlobalTimeStamp() if left < 0: left = 0 self.burada_time.SetText("%s" % locale.BuradaTime(left)) def OnUpdate(self): self.Sehirstime(int(self.sehirtime)) self.Buradastime(int(self.buradatime))
uiscript restartdialog.py aratılır
Kod:
restart_town_button
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Kod:
{ "name" : "sehirde_time", "type" : "text", "x" : 155, "y" : 53, "text" : "", }, { "name" : "burada_time", "type" : "text", "x" : 165, "y" : 23, "text" : "10", },
Kod:
self.sehirtime = app.GetGlobalTimeStamp() + 180
Kod:
self.buradatime = app.GetGlobalTimeStamp() + 10
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Metin2 Lobby'da Python Kullanarak Burada & Şehirde Yeniden Başla Süresini Gösterme
Giriş
Metin2 özel sunucularında oyun deneyimini zenginleştirmek, oyuncuların daha fazla zaman harcamasını sağlamak için birçok küçük ama etkili sistem geliştirilir. Bu sistemlerden biri de 'Burada & Şehirde Yeniden Başla Süresi Gösterme' özelliğidir. Bu yazıda, Python kullanarak bu süreyi kullanıcı arayüzünde nasıl göstereceğinizi detaylı olarak ele alacağız.
Neden Python?
Metin2 özel sunucularında hem C++ hem de Python dilleri aktif olarak kullanılır. Python, özellikle kullanıcı arayüzü (UI), oyun mantığı ve istemci tarafında hızlı geliştirme için tercih edilir. Python GUI (Py GUI), Uiscript ve Py Root gibi yapılar sayesinde UI üzerinde dinamik değişiklikler yapmak oldukça kolaydır.
Yeniden Başlama Süresi Nedir?
Metin2 oyununda oyuncu öldüğünde belirli bir süre sonra yeniden doğar. Bu süre, oyun kurallarına göre değişiklik gösterebilir. Öldüğü yerde (burada) veya şehirde yeniden başlayabilir. Her iki durumun da farklı bekleme süreleri vardır. Bu süreleri kullanıcıya göstermek, stratejik planlama yapabilmesi açısından önemlidir.
Python ile UI Entegrasyonu
Python tabanlı sistemlerde, örneğin uiscript dosyaları kullanılarak arayüz öğeleri tanımlanabilir. Bu dosyalarda bir label (etiket) nesnesi oluşturulup, buradaki yeniden başlatma süresi verisi dinamik olarak güncellenebilir.
Örnek Kod Yapısı
Aşağıda, basit bir Python koduyla bu sürenin nasıl alınabileceği ve ekranda nasıl gösterileceği anlatılmaktadır:
from ui import wndMgr, grpText, grpImage
def show_restart_time(time_left, location):
if location == 'here':
message = f'Burada yeniden baslama suresi: {time_left} sn'
else:[/COORD]
message = f'Sehirde yeniden baslama suresi: {time_left} sn'[/COORD]
wndMgr.SetText('restart_timer_label', message)[/COORD]
Süre Takibi ve Güncellenmesi
Oyuncu öldüğünde, sunucudan gelen bilgiye göre sayaç başlatılır. Bu sayaç, her saniye güncellenerek ekrana yazdırılır. Bu işlem genellikle bir zamanlayıcı (timer) ile yapılır. Python’da thread veya async yapılar kullanılarak bu sayaç senkronize edilebilir.
Sunucu Tarafı ile Eşgüdüm
Yeniden başlatma süresi sunucu tarafında hesaplanır ve istemciye gönderilir. Bu veri genellikle paket (packet) şeklinde gelir. Bu paketin doğru parse edilmesi gerekir. Paket yapısı, game server programming ve db core bilgisi gerektirir. Sunucu tarafında C++ ile yazılmış olan bu sistemlerle Python tarafı uyumlu çalışmalıdır.
UI Tasarımı ve Görsel Efekt
Kullanıcı dostu bir arayüz oluşturmak için görsel efektler ve renkler önemlidir. Örneğin, kalan süre kırmızı renkte yazılabilir ve geri sayım ilerledikçe font boyutu küçültülebilir. Bu gibi efektler için Py GUI ve grpText fonksiyonları kullanılabilir.
Sonuç
Metin2 özel sunucularında Python kullanarak 'Burada & Şehirde Yeniden Başla Süresi Gösterme' sistemi oldukça faydalıdır. Oyuncuların daha bilinçli kararlar almasını sağlar. Ayrıca, bu sistem ile kullanıcı deneyimi artırılırken, sunucu tarafındaki veri akışı ve istemci tarafındaki UI entegrasyonu arasındaki ilişki de güçlendirilir. Bu gibi sistemlerin geliştirilmesi, Metin2 Lobby üzerinden paylaşılacak örneklerle desteklenmelidir.
Showing Restart Time Here & In City with Python at Metin2 Lobby
Introduction
To enhance the gaming experience on Metin2 private servers and encourage players to spend more time in the game, many small but effective systems are developed. One of these systems is the 'Show Restart Time Here & In City' feature. In this article, we will explain in detail how to display this time on the user interface using Python.
Why Python?
Both C++ and Python languages are actively used in Metin2 private servers. Python is preferred especially for rapid development on the user interface (UI), game logic, and client-side operations. Thanks to structures such as Python GUI (Py GUI), Uiscript, and Py Root, making dynamic changes on the UI becomes quite easy.
What is the Restart Time?
In the Metin2 game, when a player dies, they respawn after a certain amount of time. This duration may vary depending on the game rules. The player can respawn either where they died (here) or in the city. Both situations have different waiting times. Showing these times to the user is important for strategic planning purposes.
UI Integration with Python
In Python-based systems, UI elements can be defined using uiscript files. A label object can be created in these files, and the restart time data can be dynamically updated on screen.
Sample Code Structure
Below is a simple Python code explaining how to retrieve and display this time on screen:
from ui import wndMgr, grpText, grpImage
def show_restart_time(time_left, location):
if location == 'here':[/COORD]
message = f'Respawn here time: {time_left} sec'[/COORD]
else:[/COORD]
message = f'Respawn in city time: {time_left} sec'[/COORD]
wndMgr.SetText('restart_timer_label', message)[/COORD]
Tracking and Updating the Timer
When the player dies, the timer starts based on the information received from the server. This timer is updated every second and displayed on the screen. This process is usually done with a timer. Using thread or async structures in Python, this timer can be synchronized.
Coordination with Server Side
The respawn time is calculated on the server side and sent to the client. This data usually comes in packet form. This packet needs to be parsed correctly. Understanding the packet structure requires knowledge of game server programming and db core. The Python side must work in harmony with these systems written in C++ on the server side.
UI Design and Visual Effects
Visual effects and colors are important to create a user-friendly interface. For example, the remaining time can be displayed in red, and as the countdown progresses, the font size can be reduced. Such effects can be achieved using Py GUI and grpText functions.
Conclusion
Using Python to implement the 'Show Restart Time Here & In City' system in Metin2 private servers is highly beneficial. It allows players to make more informed decisions. Additionally, while enhancing user experience through such systems, the relationship between data flow on the server side and UI integration on the client side is also strengthened. Development of such systems should be supported by examples shared via Metin2 Lobby.
