[Python] Register environment based on server time

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Code:
  • <li data-xf-list-type="ul">
İstemcide test etmedim, uzun zaman önce bir arkadaşım için yazıyorum.
Fonksiyonu iki bölüm halinde otomatik olarak yüklemek için çalıştırabilirsiniz.

Dosya: root / game.py
İşlev açık:[/FONT]
  • <li data-xf-list-type="ul">def OnUpdate(self): - Kontrol her saati ve eklenen ortamı kontrol ettikten sonra, kontrol doğru olduğunda durumun durdurulmasına mola vermeniz gerekir. <li data-xf-list-type="ul">def Open(self): - Her başlatmada müşteriyi / teleportu kontrol et - Çok daha iyi optimizasyon.

Python ile Sunucu Zamanına Göre Register Ortamı Oluşturma

Metin2 özel sunucularında geliştirme yaparken zaman bazlı register ortamları oluşturmak, hem güvenlik hem de kullanıcı deneyimi açısından büyük önem taşır.

Register Ortamı Nedir?
Register ortamı, genellikle oyuncuların hesap oluşturma veya belirli eylemleri gerçekleştirmeden önce geçmesi gereken doğrulama adımıdır. Bu doğrulama genellikle zamanla ilişkilidir; örneğin, bir oyuncu sadece belirli saat aralığında kayıt olabilir ya da belirli bir zaman dilimi geçtikten sonra yeni bir karakter oluşturabilir.

Sunucu Zamanı Kullanımı Neden Gerekli?
Sunucu tabanlı zamanlama, istemci tarafında manipüle edilebilecek yerel zaman değerlerine kıyasla daha güvenilirdir. Özellikle Metin2 gibi MMORPG oyunlarında, zamanla sınırlı aktiviteler veya register süreçleri için sunucu saatinin kullanılması önerilir.

Python ile Uygulama
Python, özellikle Metin2 sunucularında backend işlemleri için yaygın olarak kullanılır. Py ROOT klasöründe bulunan Python dosyaları, sunucu davranışlarını doğrudan etkileyebilir. Register işlemlerinde zaman kontrolü için datetime modülünü kullanabiliriz:

Kod:
[B]import datetime[BR][/BR][BR][/BR]def check_server_time_for_register():[BR][/BR]    current_time = datetime.datetime.now()[BR][/BR]    start_time = datetime.time(10, 0)  # 10:00[BR][/BR]    end_time = datetime.time(18, 0)    # 18:00[BR][/BR][BR][/BR]    if start_time <= current_time.time() <= end_time:[BR][/BR]        return True[BR][/BR]    else:[BR][/BR]        return False[BR][/BR]


Zaman Aralığına Göre Register Kontrolü
Yukarıdaki fonksiyon, sabah 10 ile akşam 18 arasında register yapılmasına izin verir. Bu fonksiyon, auth_server.py veya game_core.py gibi dosyalarda kullanılabilir. Böylece kullanıcılar sadece belirlenen saatler arasında kayıt yapabilir.

Güvenlik ve Performans
Zaman tabanlı register sistemleri, bot kullanımını azaltabilir. Ayrıca, sistem yükünü yönetmek için belirli saatlerde yoğunluğu azaltmak da mümkündür. Bu tür sistemlerde loglama yapmak da önemlidir:

Kod:
[B]import logging[BR][/BR][BR][/BR]logging.basicConfig(filename='register.log', level=logging.INFO)[BR][/BR][BR][/BR]def log_register_attempt(username, allowed):[BR][/BR]    current_time = datetime.datetime.now()[BR][/BR]    status = 'SUCCESS' if allowed else 'FAILED'[BR][/BR]    logging.info(f'{username} tried to register at {current_time}. Status: {status}')


Py GUI ve UIscript ile Entegrasyon
Register ekranları genellikle Python GUI ile oluşturulur. UIscript ile entegre edilen register panelleri, sunucu zamanına göre aktif veya pasif olabilir. Örneğin, izin verilen saat dışında bir kullanıcı register ekranında uyarı alabilir.

Sonuç
Sunucu zamanına dayalı register sistemleri, Metin2 özel sunucularında hem güvenlik hem de kullanıcı yönetimi açısından faydalıdır. Python kullanarak bu tür sistemleri kolayca entegre edebilir ve zamanlamayı kontrol edebilirsiniz. Bu yöntem, DB Core ve Game Core ile uyumlu çalışarak sunucu performansını artırabilir.


Creating Register Environment Based on Server Time with Python

When developing Metin2 private servers, creating time-based register environments is crucial for both security and user experience.

What is a Register Environment?
A register environment usually refers to a validation step that players must pass before creating an account or performing specific actions. This validation often involves time constraints; for example, a player may only register during certain hours or create a new character after a specific time period has passed.

Why Use Server Time?
Server-based timing is more reliable compared to local time values that can be manipulated on the client side. In MMORPGs like Metin2, using the server's clock for time-limited activities or registration processes is highly recommended.

Implementation with Python
Python is widely used in backend operations for Metin2 servers. Python files located in the Py ROOT folder directly influence server behavior. To control time-based register processes, we can use the datetime module:

Kod:
[B]import datetime[BR][/BR][BR][/BR]def check_server_time_for_register():[BR][/BR]    current_time = datetime.datetime.now()[BR][/BR]    start_time = datetime.time(10, 0)  # 10:00 AM[BR][/BR]    end_time = datetime.time(18, 0)    # 6:00 PM[BR][/BR][BR][/BR]    if start_time <= current_time.time() <= end_time:[BR][/BR]        return True[BR][/BR]    else:[BR][/BR]        return False[BR][/BR]


Time-Based Register Control
The above function allows registration only between 10 AM and 6 PM. It can be implemented within files such as auth_server.py or game_core.py, ensuring users can only register during set hours.

Security and Performance
Time-based register systems can reduce bot usage. Additionally, managing peak loads by limiting registrations to specific hours is also possible. Logging these attempts is important too:

Kod:
[B]import logging[BR][/BR][BR][/BR]logging.basicConfig(filename='register.log', level=logging.INFO)[BR][/BR][BR][/BR]def log_register_attempt(username, allowed):[BR][/BR]    current_time = datetime.datetime.now()[BR][/BR]    status = 'SUCCESS' if allowed else 'FAILED'[BR][/BR]    logging.info(f'{username} tried to register at {current_time}. Status: {status}')


Integration with Py GUI and UIscript
Register screens are typically built using Python GUI. Register panels integrated via UIscript can become active or inactive based on server time. For instance, a user attempting to register outside allowed hours could receive a warning message.

Conclusion
Time-based register systems are beneficial for both security and user management in Metin2 private servers. Using Python, you can easily implement and manage these systems, ensuring compatibility with DB Core and Game Core for improved server performance.
 

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

Benzer konular

Geri
Üst Alt