[C++] Unmount costume mount with CTRL+H

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
We can use CTRL+H for unmount/mount horse, but when we are riding a costume mount, we get an error if we try to use CTRL+H. So if you wanna be able to use it just follow this guide:

Kod:
cmd_general.cpp Go to function ACMD(do_user_horse_ride) Replace the if block (ch->GetMountVnum()) With this code:         if (ch->GetMountVnum())         {             LPITEM item = ch->GetWear(WEAR_COSTUME_MOUNT);             if (item && item->IsRideItem())                 ch->UnequipItem(item);                  if (ch->UnEquipSpecialRideUniqueItem())             {                 ch->RemoveAffect(AFFECT_MOUNT);                 ch->RemoveAffect(AFFECT_MOUNT_BONUS);             }                          //ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀÌ¹Ì Å»°ÍÀ» ÀÌ¿ëÁßÀÔ´Ï´Ù."));             return;         }

Metin2 Özel Sunucularında Kostüm Ekipmanını CTRL+H Tuşuyla Kaldırmak

Metin2 özel sunucularında oyun deneyimini zenginleştirmek için geliştirilen sistemlerden biri de kostüm ekipmanlarıdır. Bu ekipmanlar genellikle oyuncuların belirli yetenekler kazanmasını veya görsel olarak farklı bir görünüm almasını sağlar. Ancak bazı durumlarda oyuncular kostümlerini geçici olarak kaldırmak isteyebilir. Bu yazıda, C++ tabanlı game server üzerinde nasıl bir costume mount kaldırma sistemi geliştirileceğini ve bunun nasıl CTRL+H tuş kombinasyonuyla tetikleneceğini inceleyeceğiz.

Sistem Mimarisi ve Olay Yakalama

Öncelikle, client tarafından gönderilen tuş kombinasyonu bilgisinin server tarafında yakalanması gerekir. Bu işlem genellikle packet üzerinden yapılır. Metin2 özel sunucularında bu yapıyı genişletmek için game server src üzerinde C++ kodları yazılır.

Yeni bir packet tanımlamak için örneğin HEADER_CG_UNMOUNT_COSTUME adında bir komut tanımlayabiliriz. Client bu komutu gönderdiğinde server, mevcut karakterin bir kostüm montajı olup olmadığını kontrol eder. Eğer varsa, kostümün kaldırılması işlemi başlatılır.

Python GUI ve Client Tarafı Entegrasyonu

Client tarafında uiscript dosyasına özel bir event handler eklenmelidir. Bu işlem için py root üzerinden keyboard event dinleyici kurulur. Örneğin:

if app.IsPressed(app.DIK_LCONTROL) and app.IsPressed(app.DIK_H):
net.SendChatPacket('/unmount_costume')

Bu şekilde, kullanıcı CTRL+H kombinasyonuna bastığında bir komut servera gönderilir. Server tarafında bu komutu karşılayan bir command handler yazarak kostümün kaldırılmasını sağlarız.

Sunucu Tarafında Costume Mount Kaldırma Mantığı

Server tarafında bir oyuncunun kostümünü kaldırmak için önce hangi kostümün takılı olduğunu belirlemek gerekir. Bu bilgi genellikle karakterin db kayıtlarında saklanır. Kostüm takılıysa, önce ekipman slotundan çıkarılır, ardından karakterin görünümü güncellenir. Bu işlem sırasında visual update paketi tüm diğer oyunculara gönderilir ki karakterin yeni görünümü doğru şekilde yansısın.

Ayrıca, kostümün çıkarıldığı anlaşılsın diye oyuncuya bir system message gösterilebilir: 'Kostümünüz başarıyla kaldırıldı.'

Olası Hatalar ve Güvenlik Önlemleri

Bu tür sistemlerde güvenlik ihlalleri olmaması için bazı kontroller yapılmalıdır. Örneğin:
- Kullanıcının gerçekten bir kostüm takılı mı?
- Komut gerçekten bu oyuncudan mı geldi?
- Oyuncu bu komutu kullanmak için yeterli haklara sahip mi?

Bu kontroller server src üzerinde C++ ile güvenli bir şekilde yapılabilir. Ayrıca, her komutun loglanması da güvenlik açısından önemlidir.

Sonuç

Metin2 özel sunucularında costume mount sistemlerini daha esnek hale getirmek, oyuncu deneyimini ciddi anlamda artırabilir. C++ tabanlı game server üzerinde geliştirilen bu tür sistemler, hem teknik hem de estetik açıdan büyük katkı sağlar. CTRL+H gibi kısayollar, oyuncuların hızlıca kostümlerini kaldırmasını sağlayarak daha akıcı bir oyun deneyimi sunar. Bu tür gelişmeleri projenize entegre etmek istiyorsanız, source edit, martysama forumları veya metin2dev kaynakları size yardımcı olabilir.


Unmounting Costume Mounts in Metin2 Private Servers with CTRL+H

In Metin2 private servers, costume equipments are one of the systems developed to enhance the gaming experience. These items often grant players special abilities or provide a visually distinct appearance. However, at certain times, players may want to temporarily remove their costumes. In this article, we will examine how to develop a costume unmount system on a C++ based game server and trigger it via the CTRL+H key combination.

System Architecture and Event Handling

Firstly, the key combination sent by the client must be captured on the server side. This is typically done through a packet. To extend this functionality in Metin2 private servers, C++ code is written within the game server src.

To define a new packet, for example, we can use a command named HEADER_CG_UNMOUNT_COSTUME. When the client sends this command, the server checks whether the character currently has a costume mounted. If so, the unmount process begins.

Python GUI and Client-Side Integration

On the client side, a custom event handler must be added into the uiscript file. For this purpose, a keyboard event listener can be set up via py root. Example:

if app.IsPressed(app.DIK_LCONTROL) and app.IsPressed(app.DIK_H):
net.SendChatPacket('/unmount_costume')

Thus, when the user presses the CTRL+H combination, a command is sent to the server. A corresponding command handler on the server side handles this command and removes the costume accordingly.

Server-Side Costume Unmount Logic

To remove a player's costume on the server side, the first step is to determine which costume is currently equipped. This information is usually stored in the character's db records. If a costume is equipped, it is removed from the equipment slot, and the character's appearance is updated. During this process, a visual update packet is sent to all other players so that the character's new appearance is correctly displayed.

Additionally, a system message can be shown to the player to confirm: 'Your costume has been successfully unmounted.'

Potential Errors and Security Measures

Certain checks should be implemented to prevent security breaches. For example:
- Does the player actually have a costume equipped?
- Was the command really sent by this player?
- Does the player have sufficient permissions to execute this command?

These checks can be securely implemented in the server src using C++. Moreover, logging each command is important for security purposes.

Conclusion

Making costume mount systems more flexible in Metin2 private servers can significantly improve the player experience. Systems developed on a C++ based game server offer both technical and aesthetic benefits. Shortcuts like CTRL+H allow players to quickly remove costumes, resulting in a smoother gameplay flow. If you wish to integrate such enhancements into your project, resources like source edit, martysama forums, or metin2dev can assist you.
 

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

Benzer konular

Geri
Üst Alt