Hi Today we’re going to fix a common issue with the PvP mode setting in the game. As you’ve probably noticed, the setting never saves. A relog, channel switch or logout is enough to reset it, and you have to set it again every time.
I’ll show you the simplest way to fix it. Let’s get started
Merhaba! Bugün, oyundaki PvP Modu ayarının kaydedilmemesiyle ilgili yaygın bir sorunu çözeceğiz. Bildiğiniz gibi, bu ayar hiçbir zaman kalıcı olmuyor – yeniden giriş yapmak, kanal değiştirmek veya oyundan çıkmak bile yeterli, ve her seferinde tekrar ayarlamak gerekiyor.
Neyse ki, bunun için basit bir çözümümüz var. Hadi başlayalım!
Code:
Metin2 PvP Modu Çıkıştan Sonra Kaydetmiyor Hatası İçin C++ Tabanlı Çözüm
Metin2 özel sunucularında geliştirilen PvP sistemlerinde karşılaşılan yaygın sorunlardan birisi, oyuncu oturumdan çıktığında PvP modunun tekrar varsayılan moda dönmesidir. Bu durum, PvP sistemlerinin oyuncu veritabanı ile entegre olmayan yapılarla geliştirilmesinden kaynaklanabilir. Bu yazıda, C++ tabanlı bir sunucu yapılandırmasında bu hatayı nasıl çözeceğimizi detaylıca ele alacağız.
Problemin Tanımı
Metin2 özel sunucularında PvP modları genellikle oyuncunun kanalda veya harita üzerinde diğer oyuncularla savaşabilmesini sağlar. Ancak bazı durumlarda, oyuncu oyundan çıktığında PvP modu kayıt edilmez ve bir sonraki girişte varsayılan mod aktif olur. Bu, kullanıcı deneyimini ciddi şekilde olumsuz etkiler.
Sunucu Tarafında C++ Kodlama Gereklilikleri
Sunucu kodlarında PvP modunun veritabanına yazılması ve oyuncu tekrar bağlandığında bu değerin okunması gerekir. Bu işlem genellikle game_src klasöründe bulunan char.cpp, char.h gibi dosyalarda gerçekleştirilir. LoadPlayerData fonksiyonuna PvP modunun veritabanından çekilmesi ve SavePlayerData fonksiyonuna da PvP modunun veritabanına yazılması gerekir.
Çözüm Adımları
Adım 1: Oyuncu veritabanında pvp_mode adında bir sütun oluşturun. Örneğin player.account_data veya player.player_index tablosunda tutulabilir.
Adım 2: C++ tarafında LoadPlayerData fonksiyonuna aşağıdaki gibi bir kod bloğu ekleyin:
Adım 3: Aynı şekilde SavePlayerData fonksiyonuna da şu kodu ekleyin:
Olası Ekstra Geliştirmeler
Bu temel çözüm üzerine oyuncu seviyesine göre PvP izni vermek, belli bölgelerde PvP modunu kilitlemek veya PvP moduna göre ekstra efekt eklemek gibi gelişmiş sistemler entegre edilebilir. Bu tür geliştirmeler için martysama forumları ve Metin2Dev toplulukları destek sağlayabilir.
Sonuç
Metin2 özel sunucularında PvP modunun çıkıştan sonra korunması için C++ seviyesinde veritabanı entegrasyonu şarttır. Bu makale sayesinde sunucu geliştiricileri, kullanıcı deneyimini artırmak için bu temel adımları takip edebilirler.
Fix for PvP Mode Not Saving After Logout [C++]
One of the common issues encountered in PvP systems developed for Metin2 private servers is that the PvP mode resets to default after a player logs out. This issue stems from PvP systems not being integrated with the player database. In this article, we will examine how to fix this issue within a C++ based server configuration.
Problem Definition
In Metin2 private servers, PvP modes allow players to fight other players on the same channel or map. However, sometimes the PvP mode is not saved upon logout, causing the default mode to become active again during the next login. This significantly affects user experience.
Server-Side C++ Coding Requirements
The PvP mode must be written to the database on the server-side, and read again when the player reconnects. This process typically occurs in files like char.cpp and char.h located in the game_src folder. The LoadPlayerData function should retrieve the PvP mode from the database, and the SavePlayerData function must save the PvP mode into the database.
Solution Steps
Step 1: Create a column named pvp_mode in the player database table. It can be stored in tables such as player.account_data or player.player_index.
Step 2: Add the following code block to the LoadPlayerData function in C++:
Step 3: Similarly, add the following code to the SavePlayerData function:
Possible Additional Enhancements
On top of this basic solution, advanced features such as granting PvP permissions based on player level, locking PvP mode in certain areas, or adding extra effects based on PvP mode can be implemented. Such enhancements can be supported by communities like martysama forums and Metin2Dev.
Conclusion
To ensure PvP mode persists after logout in Metin2 private servers, database integration at the C++ level is essential. With this article, server developers can follow these fundamental steps to enhance user experience.
I’ll show you the simplest way to fix it. Let’s get started
Merhaba! Bugün, oyundaki PvP Modu ayarının kaydedilmemesiyle ilgili yaygın bir sorunu çözeceğiz. Bildiğiniz gibi, bu ayar hiçbir zaman kalıcı olmuyor – yeniden giriş yapmak, kanal değiştirmek veya oyundan çıkmak bile yeterli, ve her seferinde tekrar ayarlamak gerekiyor.
Neyse ki, bunun için basit bir çözümümüz var. Hadi başlayalım!
Code:
Kod:
cmd_general.cpp Find: ACMD(do_pkmode) add before: ch->SetPKMode(mode); this: // Bir soğuma süresi eklemenizi öneririm ama gerekli değil if (!PulseManager::Instance().IncreaseCount(ch->GetPlayerID(), ePulse::Cooldown, std::chrono::milliseconds(2000), 1)) { return; } // Bir soğuma süresi eklemenizi öneririm ama gerekli değil ch->SetQuestFlag("pkmode.muchomor", mode); input_login.cpp Find: EnterGame Add: BYTE savedPkMode = ch->GetQuestFlag("pkmode.muchomor"); if (savedPkMode > 0 && savedPkMode <= PK_MODE_FREE) { ch->SetPKMode(savedPkMode); } now we will fix visual error on .py uisystem.py Find: def __ClickGameOptionButton(self): self.Close() if not self.gameOptionDlg: self.gameOptionDlg = uiGameOption.OptionDialog() self.gameOptionDlg.Show() add after Show() self.gameOptionDlg.OnChangePKMode() And done!
Metin2 PvP Modu Çıkıştan Sonra Kaydetmiyor Hatası İçin C++ Tabanlı Çözüm
Metin2 özel sunucularında geliştirilen PvP sistemlerinde karşılaşılan yaygın sorunlardan birisi, oyuncu oturumdan çıktığında PvP modunun tekrar varsayılan moda dönmesidir. Bu durum, PvP sistemlerinin oyuncu veritabanı ile entegre olmayan yapılarla geliştirilmesinden kaynaklanabilir. Bu yazıda, C++ tabanlı bir sunucu yapılandırmasında bu hatayı nasıl çözeceğimizi detaylıca ele alacağız.
Problemin Tanımı
Metin2 özel sunucularında PvP modları genellikle oyuncunun kanalda veya harita üzerinde diğer oyuncularla savaşabilmesini sağlar. Ancak bazı durumlarda, oyuncu oyundan çıktığında PvP modu kayıt edilmez ve bir sonraki girişte varsayılan mod aktif olur. Bu, kullanıcı deneyimini ciddi şekilde olumsuz etkiler.
Sunucu Tarafında C++ Kodlama Gereklilikleri
Sunucu kodlarında PvP modunun veritabanına yazılması ve oyuncu tekrar bağlandığında bu değerin okunması gerekir. Bu işlem genellikle game_src klasöründe bulunan char.cpp, char.h gibi dosyalarda gerçekleştirilir. LoadPlayerData fonksiyonuna PvP modunun veritabanından çekilmesi ve SavePlayerData fonksiyonuna da PvP modunun veritabanına yazılması gerekir.
Çözüm Adımları
Adım 1: Oyuncu veritabanında pvp_mode adında bir sütun oluşturun. Örneğin player.account_data veya player.player_index tablosunda tutulabilir.
Adım 2: C++ tarafında LoadPlayerData fonksiyonuna aşağıdaki gibi bir kod bloğu ekleyin:
Kod:
[COLOR=#006600]int pvpMode = 0;[/COLOR][BR][/BR][COLOR=#006600]LPDESC d = ch->GetDesc();[/COLOR][BR][/BR][COLOR=#006600]SQLMsg sql = DBManager::instance().DirectQuery(“SELECT pvp_mode FROM player WHERE id = %u”, ch->GetPlayerID());[/COLOR][BR][/BR][COLOR=#006600]if(sql.Get()->num_rows > 0) {[/COLOR][BR][/BR][COLOR=#006600]MYSQL_ROW row = sql.Get()->fetch_row();[/COLOR][BR][/BR][COLOR=#006600]pvpMode = atoi(row[0]);[/COLOR][BR][/BR][COLOR=#006600]}[/COLOR][BR][/BR][COLOR=#006600]ch->SetPvPMode(pvpMode);[/COLOR]
Adım 3: Aynı şekilde SavePlayerData fonksiyonuna da şu kodu ekleyin:
Kod:
[COLOR=#006600]DBManager::instance().DirectQuery(“UPDATE player SET pvp_mode = %d WHERE id = %u”, ch->GetPvPMode(), ch->GetPlayerID());[/COLOR]
Olası Ekstra Geliştirmeler
Bu temel çözüm üzerine oyuncu seviyesine göre PvP izni vermek, belli bölgelerde PvP modunu kilitlemek veya PvP moduna göre ekstra efekt eklemek gibi gelişmiş sistemler entegre edilebilir. Bu tür geliştirmeler için martysama forumları ve Metin2Dev toplulukları destek sağlayabilir.
Sonuç
Metin2 özel sunucularında PvP modunun çıkıştan sonra korunması için C++ seviyesinde veritabanı entegrasyonu şarttır. Bu makale sayesinde sunucu geliştiricileri, kullanıcı deneyimini artırmak için bu temel adımları takip edebilirler.
Fix for PvP Mode Not Saving After Logout [C++]
One of the common issues encountered in PvP systems developed for Metin2 private servers is that the PvP mode resets to default after a player logs out. This issue stems from PvP systems not being integrated with the player database. In this article, we will examine how to fix this issue within a C++ based server configuration.
Problem Definition
In Metin2 private servers, PvP modes allow players to fight other players on the same channel or map. However, sometimes the PvP mode is not saved upon logout, causing the default mode to become active again during the next login. This significantly affects user experience.
Server-Side C++ Coding Requirements
The PvP mode must be written to the database on the server-side, and read again when the player reconnects. This process typically occurs in files like char.cpp and char.h located in the game_src folder. The LoadPlayerData function should retrieve the PvP mode from the database, and the SavePlayerData function must save the PvP mode into the database.
Solution Steps
Step 1: Create a column named pvp_mode in the player database table. It can be stored in tables such as player.account_data or player.player_index.
Step 2: Add the following code block to the LoadPlayerData function in C++:
Kod:
[COLOR=#006600]int pvpMode = 0;[/COLOR][BR][/BR][COLOR=#006600]LPDESC d = ch->GetDesc();[/COLOR][BR][/BR][COLOR=#006600]SQLMsg sql = DBManager::instance().DirectQuery(“SELECT pvp_mode FROM player WHERE id = %u”, ch->GetPlayerID());[/COLOR][BR][/BR][COLOR=#006600]if(sql.Get()->num_rows > 0) {[/COLOR][BR][/BR][COLOR=#006600]MYSQL_ROW row = sql.Get()->fetch_row();[/COLOR][BR][/BR][COLOR=#006600]pvpMode = atoi(row[0]);[/COLOR][BR][/BR][COLOR=#006600]}[/COLOR][BR][/BR][COLOR=#006600]ch->SetPvPMode(pvpMode);[/COLOR]
Step 3: Similarly, add the following code to the SavePlayerData function:
Kod:
[COLOR=#006600]DBManager::instance().DirectQuery(“UPDATE player SET pvp_mode = %d WHERE id = %u”, ch->GetPvPMode(), ch->GetPlayerID());[/COLOR]
Possible Additional Enhancements
On top of this basic solution, advanced features such as granting PvP permissions based on player level, locking PvP mode in certain areas, or adding extra effects based on PvP mode can be implemented. Such enhancements can be supported by communities like martysama forums and Metin2Dev.
Conclusion
To ensure PvP mode persists after logout in Metin2 private servers, database integration at the C++ level is essential. With this article, server developers can follow these fundamental steps to enhance user experience.
