Dereceye Göre Bonus Sistemi Hata Düzeltmesi

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Merhabalar, bir kaynak dosyalarında gezerken buldum neden böyle birşey yapıldığını merak ettim ve sistemi denemeye başladım. Olay tam olarak şundan ibaret eğer
aligment == 10000 ise x bonusları ver tarzında yapılı olduğundan 10001 olunca update atıyor ve buda oyunda lag sapıtma vs. sebebiyeti vermekte vereceğim kod aligment almayı engelliyor. Elbette başka çözümde bulunabilir araştırma yaptıktan sonra fakat kullanmadığım bir sistem olduğu için gerisi sizin hayal gücünüze kalmış bir durum.

char.cpp***
//ARAT
Kod:
if (GetSectree() && !GetSectree()->IsAttr(GetX(), GetY(), ATTR_BANPK))         {             if (GetRealAlignment() < 0)             {                 if (IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_TIME))                     UpdateAlignment(120 * (dwPlayedTime / 60000));                 else                     UpdateAlignment(60 * (dwPlayedTime / 60000));             }             else                 UpdateAlignment(5 * (dwPlayedTime / 60000));         }

//DEGISTIR
Kod:
#ifdef _DERECEYE_GORE_BONUS_SISTEMI_FIX_         if (GetSectree() && !GetSectree()->IsAttr(GetX(), GetY(), ATTR_BANPK))         {             if (GetRealAlignment() < 0)             {                 if (IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_TIME))                     UpdateAlignment(120 * (dwPlayedTime / 60000), true);                 else                     UpdateAlignment(60 * (dwPlayedTime / 60000), true);             }             else                 UpdateAlignment(5 * (dwPlayedTime / 60000),true);         } #else         if (GetSectree() && !GetSectree()->IsAttr(GetX(), GetY(), ATTR_BANPK))         {             if (GetRealAlignment() < 0)             {                 if (IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_TIME))                     UpdateAlignment(120 * (dwPlayedTime / 60000));                 else                     UpdateAlignment(60 * (dwPlayedTime / 60000));             }             else                 UpdateAlignment(5 * (dwPlayedTime / 60000));         } #endif

char_battle.cpp***
//ARAT
Kod:
if (pkAttacker->IsPC())     {         if (GetLevel() - pkAttacker->GetLevel() >= -10)             if (pkAttacker->GetRealAlignment() < 0)             {                 if (pkAttacker->IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_KILL))                     pkAttacker->UpdateAlignment(14);                 else                     pkAttacker->UpdateAlignment(7);             }             else                 pkAttacker->UpdateAlignment(2);

//DEGISTIR
Kod:
#ifdef _DERECEYE_GORE_BONUS_SISTEMI_FIX_     if (pkAttacker->IsPC())     {         if (GetLevel() - pkAttacker->GetLevel() >= -10)             if (pkAttacker->GetRealAlignment() < 0)             {                 if (pkAttacker->IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_KILL))                     pkAttacker->UpdateAlignment(14, false);                 else                     pkAttacker->UpdateAlignment(7, false);             }             else                 pkAttacker->UpdateAlignment(2, false); #else     if (pkAttacker->IsPC())     {         if (GetLevel() - pkAttacker->GetLevel() >= -10)             if (pkAttacker->GetRealAlignment() < 0)             {                 if (pkAttacker->IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_KILL))                     pkAttacker->UpdateAlignment(14);                 else                     pkAttacker->UpdateAlignment(7);             }             else                 pkAttacker->UpdateAlignment(2); #endif

//ARAT
Kod:
pkChr->UpdateAlignment(m_iAmount / m_iCount);

//DEGISTIR
Kod:
#ifdef _DERECEYE_GORE_BONUS_SISTEMI_FIX_                     pkChr->UpdateAlignment(m_iAmount / m_iCount, false); #else                     pkChr->UpdateAlignment(m_iAmount / m_iCount); #endif


Extra olarak :
//ARATx2
Kod:
pkKiller->UpdateAlignment(-20000);

//DEGISTIRx2
Kod:
#ifdef _DERECEYE_GORE_BONUS_SISTEMI_FIX_                                 pkKiller->UpdateAlignment(-20000, false); #else                                 pkKiller->UpdateAlignment(-20000); #endif

Dereceye Göre Bonus Sistemi Hata Düzeltmesi

Metin2 özel sunucularında geliştirilen sistemlerden biri olan dereceye göre bonus sistemi, oyuncuların belirli seviyelere ulaşmalarıyla birlikte özel ödüller kazanmalarını sağlar. Ancak bu tür sistemlerin geliştirilmesinde bazı hatalarla karşılaşmak kaçınılmazdır. Bu makalede, dereceye göre bonus sistemi üzerinde meydana gelen hataların tespiti ve düzeltme yöntemleri detaylı şekilde ele alınacaktır.

Hata Nedir?

Genellikle C++ tabanlı game server tarafında çalışan derece bonus sistemi, oyuncu seviyesine göre belirli ödüllerin otomatik olarak verilmesini sağlar. Fakat bu sistemde bazı durumlarda ödüllerin doğru şekilde dağıtılmaması, bonusların eksik ya da fazla verilmesi gibi hatalar meydana gelebilir. Bunun temel nedenleri şunlardır:

- Level kontrol mekanizmasının doğru çalışmaması.
- Bonus verme işlemi sırasında Python veya C++ kaynak kodlarında mantık hatası.
- Database bağlantısında zaman aşımı veya veri eksikliği.
- Auth veya game sunucusu senkronizasyonunda problem oluşması.

Hatanın Tespiti

Sistemsel hatalar genellikle log dosyalarında belirtilir. Game server logları incelendiğinde, bonus sisteminin çalıştığı zamanlarda oluşan hata mesajları tespit edilebilir. Örneğin, bir oyuncu 99. levele ulaştığında bonus verilmesi gerekirken verilmemişse, bu olayla ilgili logda 'bonus not given' gibi bir mesaj yer alabilir. Bu mesajlar sayesinde hatanın tam olarak hangi aşamada meydana geldiği anlaşılır.

Ayrıca, client tarafında bonus ekranda görünmüyor fakat sistemde verildi ise, bu durumda UI tarafında bir uiscript hatası söz konusu olabilir. Bu tür hatalar genellikle py root klasöründe yer alan GUI dosyalarında bulunur.

Hata Düzeltme Yöntemleri

1. C++ Server tarafında level kontrol fonksiyonu yeniden gözden geçirilmelidir. Özellikle bonus verme koşulu, level değişikliği sonrası doğru şekilde kontrol edilmelidir.

2. Python tarafında bonus verme işlemi py gui üzerinden yapıldıysa, arayüz ile sunucu arasında veri aktarımı kontrol edilmelidir. Gerekirse socket bağlantısı güçlendirilmelidir.

3. Database tarafında bonus verilmiş ancak oyuncuya yansımamışsa, db core üzerinde bir sorgu hatası olabilir. Bu durumda bonus tablosunun doğru şekilde güncellenip güncellenmediği kontrol edilmelidir.

4. Martysama veya diğer geliştirici kaynakları üzerinden örnek sistemler karşılaştırılmalı, eksik veya hatalı kodlar doğrultulmalıdır.

Örnek Kod Parçası (C++)

Kod:
[B]int[/B] [B]check_level_bonus[/B]([B]int[/B] level, [B]char*[/B] player_name) {[BR][/BR]    [B]if[/B] (level % 10 == 0) { // Her 10 levele bonus verilsin[BR][/BR]        [B]give_item_to_player[/B](player_name, BONUS_ITEM_ID, 1);[BR][/BR]        [B]return[/B] 1;[BR][/BR]    }[BR][/BR]    [B]return[/B] 0;[BR][/BR]}


Yukarıdaki kod parçası, her 10 levele geldiğinde oyuncuya bonus verir. Ancak bu fonksiyonun doğru şekilde tetiklenip tetiklenmediği, level değişikliği sırasında çağrılıp çağrılmadığı önemlidir. Eğer tetiklenmiyorsa, event handler kısmında bir ekleme yapılmalıdır.

Sonuç

Metin2 özel sunucularında dereceye göre bonus sistemi oldukça popülerdir. Ancak bu sistemin stabil çalışabilmesi için hem server hem de client tarafında dikkatli kodlama yapılmalıdır. Hataların erken tespiti ve düzeltilmesi, oyuncu memnuniyetini artırmak açısından büyük önem taşır. Geliştiricilerin bu tür sistemleri geliştirirken source edit, compile, core gibi teknik detaylara dikkat etmeleri, sistemin uzun süre sorunsuz çalışmasını sağlar.

Daha fazla Metin2 geliştirme kaynağı için Metin2Lobby'yi takip edin.


Fixing Errors in Level-Based Bonus System

The level-based bonus system is one of the most popular features implemented in Metin2 private servers. It rewards players with special bonuses upon reaching certain levels. However, during the development of such systems, encountering errors is inevitable. This article will detail the detection and fixing methods for common errors found in the level-based bonus system.

What Is the Error?

Typically running on the game server side using C++, the level bonus system automatically grants rewards to players upon reaching specific levels. However, sometimes the system fails to distribute rewards correctly, resulting in missing or excessive bonuses. Common causes include:

- Incorrect functioning of the level check mechanism.
- Logic errors in Python or C++ source codes during bonus distribution.
- Database connection timeouts or missing data.
- Issues with synchronization between auth and game servers.

Detecting the Error

Systematic errors are usually logged in log files. By examining the game server logs, error messages occurring during the bonus system's operation can be identified. For example, if a player reaches level 99 and does not receive the expected reward, the log might contain a message like 'bonus not given'. Such messages help pinpoint exactly where the error occurred.

Additionally, if the bonus was granted but not displayed in the client, this could indicate a uiscript error in the UI layer. These types of errors are generally located within GUI files in the py root directory.

Methods to Fix the Error

1. The level-check function in the C++ server should be reviewed carefully. Especially, the condition for granting bonuses must be checked properly after a level change occurs.

2. If the bonus is granted through py gui on the Python side, the data transfer between the UI and server should be verified. If necessary, the socket connection should be strengthened.

3. If the bonus was recorded in the database but did not reflect on the player's side, there may be a query issue in the db core. In such cases, whether the bonus table was updated correctly should be checked.

4. Systems should be compared with examples from sources like Martysama to identify and correct missing or incorrect code sections.

Sample Code (C++)

Kod:
[B]int[/B] [B]check_level_bonus[/B]([B]int[/B] level, [B]char*[/B] player_name) {[BR][/BR]    [B]if[/B] (level % 10 == 0) { // Grant bonus every 10 levels[BR][/BR]        [B]give_item_to_player[/B](player_name, BONUS_ITEM_ID, 1);[BR][/BR]        [B]return[/B] 1;[BR][/BR]    }[BR][/BR]    [B]return[/B] 0;[BR][/BR]}


The above code snippet grants a bonus to the player every 10 levels. However, it is crucial that this function is triggered correctly and called upon level changes. If not, an addition to the event handler section might be required.

Conclusion

The level-based bonus system is very popular among Metin2 private servers. However, for the system to run stably, careful coding on both the server and client sides is essential. Early detection and correction of errors significantly improve player satisfaction. Developers should pay attention to technical details like source edit, compile, and core while implementing such systems to ensure long-term, trouble-free operation.

For more Metin2 development resources, follow Metin2Lobby.
 

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

Geri
Üst Alt