char_item.cpp Aratılır:
Kod:
if (iWearCell != WEAR_ARROW && (dwCurTime - GetLastAttackTime() <= 1500 || dwCurTime - m_dwLastSkillTime <= 1500)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("&#44032;&#47564;&#55176; &#51080;&#51012; &#46412;&#47564; &#52265;&#50857;&#54624; &#49688; &#51080;&#49845;&#45768;&#45796;.")); return false; }
Kod:
/*if (iWearCell != WEAR_ARROW && (dwCurTime - GetLastAttackTime() <= 1500 || dwCurTime - m_dwLastSkillTime <= 1500)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("&#44032;&#47564;&#55176; &#51080;&#51012; &#46412;&#47564; &#52265;&#50857;&#54624; &#49688; &#51080;&#49845;&#45768;&#45796;.")); return false; }*/
Hareket Ederken İtem Değiştirememe Fix[C++]
Metin2 özel sunucularında geliştirme yaparken karşılaşılan sorunlardan birisi, oyuncu hareket ederken item değiştirememektir. Bu durum kullanıcı deneyimini ciddi şekilde etkiler ve oyuncuların bazı ekipman değişikliklerini yapamamasına neden olur. Bu yazıda, C++ tabanlı bir Metin2 server üzerinde bu hatayı nasıl düzelteceğimizi adım adım anlatacağız.
Sorun Nedir?
Oyuncu hareket halindeyken bazı item slotları (örneğin silah veya zırh gibi) değiştirilemez. Bu durum genellikle client-server iletişiminde belirli bir kontrolün aktif olması sebebiyle oluşur. Özellikle PvP sunucularda bu tür kontroller güvenlik amaçlıdır ancak bazen yanlışlıkla diğer aksiyonları da bloklar.
Neden Olur?
Sebep genellikle client tarafında 'movement' sırasında item change event'lerinin server'a gönderilmesinin engellenmesidir. Bu engelleme, bazı güvenlik kontrolleri sonucu doğrudan C++ kodunda tanımlanmıştır. Örneğin:
game/core/entity.cpp dosyasında, karakterin hareket durumu kontrol edilir ve bu durumda item değiştirme isteği reddedilir.
Fix Nasıl Yapılır?
Öncelikle ilgili dosyaya gidelim. Sunucu tarafında genellikle char_item.cpp veya benzeri bir dosya içinde, item değişikliği kontrolü yapılırken hareket durumu kontrol ediliyor.
Aşağıdaki gibi bir kontrol mevcut olabilir:
if (ch->IsMoving()) {
return false;
}
Bu kontrolü kaldırmak veya daha spesifik hale getirmek gerekebilir. Örneğin sadece belirli item tipleri için hareket esnasında engelleme yapılabilir:
if (ch->IsMoving() && IsWeapon(item_type)) {
return false;
}
Python Client Tarafı Düzeltme
Client tarafında da benzer bir kontrol olabilir. uiscript/InventoryWindow.py gibi dosyalarda, item_usage_event fonksiyonu içinde hareket ederken işlem yapılmaması sağlanmıştır. Bu kısım da aynı şekilde gözden geçirilmeli.
Test Etme ve Uygulama
Yaptığınız değişiklikleri test etmek için local sunucunuzda karakter oluşturup hareket ederken item değiştirme işlemini denemelisiniz. Hatalar çıkmadan başarılı bir şekilde değişiklik yapabiliyorsanız, düzeltme başarılı demektir.
Bu fix, Metin2 özel sunucularında kullanıcı deneyimini artırmak için oldukça temel ve etkili bir yöntemdir. Daha fazla C++ tabanlı Metin2 geliştirme ipucu için Metin2Lobby sitesini takip edin.
Can't Change Item While Moving Fix[C++]
One of the common issues encountered during development of Metin2 private servers is the inability to change items while moving. This issue significantly affects user experience and prevents players from switching equipment at certain times. In this article, we will explain step by step how to fix this error on a C++ based Metin2 server.
What Is The Problem?
While a player is moving, some item slots (such as weapons or armor) cannot be changed. This usually occurs due to a specific check implemented in client-server communication. On PvP servers, these checks are often for security but may mistakenly block other actions.
Why Does It Happen?
The cause is typically that item change events are blocked from being sent to the server while the character is moving. Such blocking is often defined directly in C++ code as part of security checks. For example, in the file game/core/entity.cpp, the character's movement state is checked and item change requests are rejected if the character is moving.
How To Fix It?
First, navigate to the relevant file. On the server side, in files like char_item.cpp, item change checks may prevent swapping items while moving. You might encounter a control similar to this:
if (ch->IsMoving()) {
return false;
}
You can either remove this control or make it more specific. For example, you could allow item swaps except for specific types like weapons:
if (ch->IsMoving() && IsWeapon(item_type)) {
return false;
}
Python Client Side Fix
There might also be a similar check on the client side. In files such as uiscript/InventoryWindow.py, an item usage event function may prevent actions during movement. This section should also be reviewed accordingly.
Testing And Applying
To test your changes, create a character on your local server and try changing items while moving. If you can successfully swap items without errors, the fix has been applied correctly.
This fix is a fundamental and effective way to enhance user experience in Metin2 private servers. For more C++ based Metin2 development tips, follow Metin2Lobby.
