Binekden indiğinizde itemin çıkarılmasını istiyorsanız
cmd_genaral.cpp de
Eğerki binek itemi envanterdeyken ctrl h ile binek itemini giymek istiyorsanız.
Çoğu kişide bu fonksiyon vardır. Eğer yoksa ona göre işlem yapınız.
cmd_general.cpp de
bul altına ekle
Yapamayan arkadaşlar olursa diye kendi do_ride mi bırakıyorum kendinize göre uyarlar veya değiştirirsiniz
Binekten İndiğimizde Itemi Çıkartan Sistem - Metin2 C++
Metin2 özel sunucularında geliştirme yaparken, oyuncu deneyimini artırmak adına birçok özelleştirilmiş sistem geliştirilebilir. Bunlardan biri de binekten indiğinizde belirli bir itemin otomatik olarak envanterden çıkarılmasıdır. Bu sistem özellikle binek sistemine özel olarak tasarlanmış itemler için oldukça kullanışlıdır. Bu yazıda, C++ tabanlı Metin2 sunucularda nasıl binekten indiğimizde itemin çıkartılacağını adım adım ele alacağız.
Neden Bu Sistemi Kullanmalıyız?
Metin2 oyununda binek sistemleri, oyuncuların hızla seyahat etmesini sağlar. Ancak bazı özel binek itemleri, oyuncu binekten indiğinde otomatik olarak kullanımdan kaldırılmalıdır. Örneğin, sınırlı süreli binek itemleri, tekrar kullanılabilirlik açısından binekten inince sistem tarafından otomatik olarak envanterden silinmelidir. Bu sayede hem hilelere karşı önlem alınmış olur hem de oyun içi ekonomi dengesi korunur.
Sistem Nasıl Çalışır?
Bu sistem, oyuncu binekten indiğinde tetiklenen bir event üzerinden çalışır. Oyuncu binekten indiğinde, sunucu tarafında tanımlı olan fonksiyon çalışır ve binek iteminin envanterden otomatik olarak kaldırılmasını sağlar. Bu işlem için öncelikle binek iteminin ID numarasının bilinmesi gerekir. Daha sonra bu ID ile envanterde arama yapılarak, itemin çıkartılması sağlanır.
C++ Kodlama Aşaması
Sunucu tarafında, CharacterManager.cpp dosyasında bulunan LeaveHorse() fonksiyonuna müdahale edilerek bu sistem entegre edilebilir. Fonksiyon, oyuncu binekten indiğinde çalışacak şekilde düzenlenir. Burada önemli olan, binek itemi tanıtımı ve envanterden çıkarma fonksiyonudur. Örnek olarak:
Özel Ayarlamalar ve Ekstra Güvenlik
Sistemde daha fazla güvenlik sağlamak için itemin envanterde olması durumunda silinmesi sağlanabilir. Ayrıca, binekten inmeden önce itemin gerçekten kullanılıp kullanılmadığı kontrol edilmeli. Bu sayede, hatalı kullanım engellenmiş olur. Aynı zamanda loglama sistemine de binekten inme olayı yazdırılarak, hata takibi kolaylaştırılabilir.
Olası Hatalar ve Çözümler
Bu sistemde oluşabilecek hatalardan biri, itemin yanlışlıkla birden fazla kez silinmesidir. Bu durumu önlemek için, itemin envanterde varlığını kontrol eden bir fonksiyon yazılmalı ve silme işlemi bu kontrolden sonra yapılmalıdır. Ayrıca, sunucu yeniden başlatıldığında sistem devreye girmemeli veya çakışmamalıdır. Bu nedenle, LeaveHorse fonksiyonu doğru şekilde test edilmelidir.
Sonuç
Binekten indiğimizde itemin otomatik olarak çıkarılması, Metin2 özel sunucularında kullanıcı deneyimini artıran ve oyun içi dengeyi sağlayan önemli bir sistemdir. C++ tabanlı geliştirme ile bu sistem, kolayca entegre edilebilir ve özelleştirilebilir. Bu sayede hem güvenli hem de kullanıcı dostu bir sunucu ortamı oluşturulabilir.
System for Removing Items When Getting Off Mount - Metin2 C++
When developing private Metin2 servers, many customized systems can be implemented to enhance player experience. One such system involves automatically removing a specific item from the inventory when dismounting. This system is particularly useful for mount-specific items. In this article, we will explain step by step how to implement an automatic item removal when dismounting in C++ based Metin2 servers.
Why Should We Use This System?
Mount systems in Metin2 allow players to travel quickly. However, certain special mount items should be automatically removed from use once the player dismounts. For example, limited-time mount items should be removed from the inventory upon dismounting to ensure reusability and maintain in-game economic balance.
How Does the System Work?
This system operates via an event triggered when the player dismounts. The function defined on the server side executes and ensures the mount item is removed from the inventory. To do this, the ID number of the mount item must first be known. Then, using this ID, the item is located and removed from the inventory.
C++ Coding Phase
In the server-side file CharacterManager.cpp, modifications can be made to the LeaveHorse() function. The function is adjusted to execute whenever the player dismounts. It's important here to define the mount item and implement the removal function. Example:
Customizations and Extra Security
To provide more security, the system can ensure that the item is only removed if it exists in the inventory. Additionally, before dismounting, whether the item is actually being used should be checked. This prevents misuse. Also, logging the dismounting action helps with debugging.
Possible Errors and Solutions
One potential error is accidentally removing the item multiple times. To prevent this, a function should verify the item's presence in the inventory before removal. Also, the system should not interfere after a server restart. Therefore, the LeaveHorse function must be tested properly.
Conclusion
Automatically removing an item when dismounting enhances user experience and maintains game balance in private Metin2 servers. With C++ based development, this system can be easily integrated and customized, creating both a secure and user-friendly environment.
cmd_genaral.cpp de
Kod:
if (ch->IsHorseRiding()) { dev_log (LOG_DEB0, "[DO_RIDE] stop riding"); ch->StopRiding(); return; }
Kod:
if (ch->IsHorseRiding()) { dev_log (LOG_DEB0, "[DO_RIDE] stop riding"); ch->StopRiding(); LPITEM wear_mount = ch->GetWear(WEAR_COSTUME_MOUNT); if (wear_mount) { dev_log(LOG_DEB0, "[DO_RIDE] Unequip WEAR_COSTUME_MOUNT"); ch->UnequipItem(wear_mount); } return; }
Eğerki binek itemi envanterdeyken ctrl h ile binek itemini giymek istiyorsanız.
Çoğu kişide bu fonksiyon vardır. Eğer yoksa ona göre işlem yapınız.
cmd_general.cpp de
Kod:
if (ch->GetHorse() != NULL) { dev_log (LOG_DEB0, "[DO_RIDE] start riding"); ch->StartRiding(); return; }
bul altına ekle
Kod:
for (BYTE i = 0; i < INVENTORY_MAX_NUM; ++i) { LPITEM item = ch->GetInventoryItem (i); if (NULL == item) { continue; } // À¯´ÏÅ© Å»°Í ¾ÆÀÌÅÛ if (item->IsRideItem()) { if (NULL == ch->GetWear (WEAR_UNIQUE1) || NULL == ch->GetWear (WEAR_UNIQUE2) || NULL == ch->GetWear (WEAR_COSTUME_MOUNT)) { dev_log (LOG_DEB0, "[DO_RIDE] USE UNIQUE ITEM"); //ch->EquipItem(item); ch->UseItem (TItemPos (INVENTORY, i)); return; } }
Yapamayan arkadaşlar olursa diye kendi do_ride mi bırakıyorum kendinize göre uyarlar veya değiştirirsiniz
Kod:
ACMD (do_ride) { dev_log (LOG_DEB0, "[DO_RIDE] start"); if (ch->IsDead() || ch->IsStun()) { return; } { if (ch->IsHorseRiding()) { dev_log (LOG_DEB0, "[DO_RIDE] stop riding"); ch->StopRiding(); LPITEM wear_mount = ch->GetWear(WEAR_COSTUME_MOUNT); if (wear_mount) { dev_log(LOG_DEB0, "[DO_RIDE] Unequip WEAR_COSTUME_MOUNT"); ch->UnequipItem(wear_mount); } return; } if (ch->GetMountVnum()) { dev_log (LOG_DEB0, "[DO_RIDE] unmount"); do_unmount (ch, NULL, 0, 0); return; } } { if (ch->GetHorse() != NULL) { dev_log (LOG_DEB0, "[DO_RIDE] start riding"); ch->StartRiding(); return; } for (BYTE i = 0; i < INVENTORY_MAX_NUM; ++i) { LPITEM item = ch->GetInventoryItem (i); if (NULL == item) { continue; } // À¯´ÏÅ© Å»°Í ¾ÆÀÌÅÛ if (item->IsRideItem()) { if (NULL == ch->GetWear (WEAR_UNIQUE1) || NULL == ch->GetWear (WEAR_UNIQUE2) || NULL == ch->GetWear (WEAR_COSTUME_MOUNT)) { dev_log (LOG_DEB0, "[DO_RIDE] USE UNIQUE ITEM"); //ch->EquipItem(item); ch->UseItem (TItemPos (INVENTORY, i)); return; } } // ÀÏ¹İ Å»°Í ¾ÆÀÌÅÛ // TODO : Å»°Í¿ë SubType Ãß°¡ switch (item->GetVnum()) { case 71114: // Àú½ÅÀÌ¿ë±Ç case 71116: // »ê°ß½ÅÀÌ¿ë±Ç case 71118: // ÅõÁö¹üÀÌ¿ë±Ç case 71120: // »çÀÚ¿ÕÀÌ¿ë±Ç dev_log (LOG_DEB0, "[DO_RIDE] USE QUEST ITEM"); ch->UseItem (TItemPos (INVENTORY, i)); return; } // GF mantis #113524, 52001~52090 ¹ø Å»°Í if ((item->GetVnum() > 52000) && (item->GetVnum() < 52091)) { dev_log (LOG_DEB0, "[DO_RIDE] USE QUEST ITEM"); ch->UseItem (TItemPos (INVENTORY, i)); return; } } } ch->ChatPacket (CHAT_TYPE_INFO, LC_TEXT ("Önce Bineğini çıkar.")); }
Binekten İndiğimizde Itemi Çıkartan Sistem - Metin2 C++
Metin2 özel sunucularında geliştirme yaparken, oyuncu deneyimini artırmak adına birçok özelleştirilmiş sistem geliştirilebilir. Bunlardan biri de binekten indiğinizde belirli bir itemin otomatik olarak envanterden çıkarılmasıdır. Bu sistem özellikle binek sistemine özel olarak tasarlanmış itemler için oldukça kullanışlıdır. Bu yazıda, C++ tabanlı Metin2 sunucularda nasıl binekten indiğimizde itemin çıkartılacağını adım adım ele alacağız.
Neden Bu Sistemi Kullanmalıyız?
Metin2 oyununda binek sistemleri, oyuncuların hızla seyahat etmesini sağlar. Ancak bazı özel binek itemleri, oyuncu binekten indiğinde otomatik olarak kullanımdan kaldırılmalıdır. Örneğin, sınırlı süreli binek itemleri, tekrar kullanılabilirlik açısından binekten inince sistem tarafından otomatik olarak envanterden silinmelidir. Bu sayede hem hilelere karşı önlem alınmış olur hem de oyun içi ekonomi dengesi korunur.
Sistem Nasıl Çalışır?
Bu sistem, oyuncu binekten indiğinde tetiklenen bir event üzerinden çalışır. Oyuncu binekten indiğinde, sunucu tarafında tanımlı olan fonksiyon çalışır ve binek iteminin envanterden otomatik olarak kaldırılmasını sağlar. Bu işlem için öncelikle binek iteminin ID numarasının bilinmesi gerekir. Daha sonra bu ID ile envanterde arama yapılarak, itemin çıkartılması sağlanır.
C++ Kodlama Aşaması
Sunucu tarafında, CharacterManager.cpp dosyasında bulunan LeaveHorse() fonksiyonuna müdahale edilerek bu sistem entegre edilebilir. Fonksiyon, oyuncu binekten indiğinde çalışacak şekilde düzenlenir. Burada önemli olan, binek itemi tanıtımı ve envanterden çıkarma fonksiyonudur. Örnek olarak:
Kod:
[B]void CHARACTER::LeaveHorse(){[BR][/BR] // Oyuncu binekten iniyor[BR][/BR] if (GetHorse()){[BR][/BR] DWORD binekItemID = 70001; // Örnek binek item ID[BR][/BR] TItemPos pos = FindItemByID(binekItemID);[BR][/BR] if (pos != ITEM_INVENTORY_MAX_NUM){[BR][/BR] // Item envanterde bulundu, siliniyor[BR][/BR] RemoveSpecifyItem(binekItemID, 1);[BR][/BR] }[BR][/BR] }[BR][/BR]}[/B]
Özel Ayarlamalar ve Ekstra Güvenlik
Sistemde daha fazla güvenlik sağlamak için itemin envanterde olması durumunda silinmesi sağlanabilir. Ayrıca, binekten inmeden önce itemin gerçekten kullanılıp kullanılmadığı kontrol edilmeli. Bu sayede, hatalı kullanım engellenmiş olur. Aynı zamanda loglama sistemine de binekten inme olayı yazdırılarak, hata takibi kolaylaştırılabilir.
Olası Hatalar ve Çözümler
Bu sistemde oluşabilecek hatalardan biri, itemin yanlışlıkla birden fazla kez silinmesidir. Bu durumu önlemek için, itemin envanterde varlığını kontrol eden bir fonksiyon yazılmalı ve silme işlemi bu kontrolden sonra yapılmalıdır. Ayrıca, sunucu yeniden başlatıldığında sistem devreye girmemeli veya çakışmamalıdır. Bu nedenle, LeaveHorse fonksiyonu doğru şekilde test edilmelidir.
Sonuç
Binekten indiğimizde itemin otomatik olarak çıkarılması, Metin2 özel sunucularında kullanıcı deneyimini artıran ve oyun içi dengeyi sağlayan önemli bir sistemdir. C++ tabanlı geliştirme ile bu sistem, kolayca entegre edilebilir ve özelleştirilebilir. Bu sayede hem güvenli hem de kullanıcı dostu bir sunucu ortamı oluşturulabilir.
System for Removing Items When Getting Off Mount - Metin2 C++
When developing private Metin2 servers, many customized systems can be implemented to enhance player experience. One such system involves automatically removing a specific item from the inventory when dismounting. This system is particularly useful for mount-specific items. In this article, we will explain step by step how to implement an automatic item removal when dismounting in C++ based Metin2 servers.
Why Should We Use This System?
Mount systems in Metin2 allow players to travel quickly. However, certain special mount items should be automatically removed from use once the player dismounts. For example, limited-time mount items should be removed from the inventory upon dismounting to ensure reusability and maintain in-game economic balance.
How Does the System Work?
This system operates via an event triggered when the player dismounts. The function defined on the server side executes and ensures the mount item is removed from the inventory. To do this, the ID number of the mount item must first be known. Then, using this ID, the item is located and removed from the inventory.
C++ Coding Phase
In the server-side file CharacterManager.cpp, modifications can be made to the LeaveHorse() function. The function is adjusted to execute whenever the player dismounts. It's important here to define the mount item and implement the removal function. Example:
Kod:
[B]void CHARACTER::LeaveHorse(){[BR][/BR] // Player is dismounting[BR][/BR] if (GetHorse()){[BR][/BR] DWORD mountItemID = 70001; // Example mount item ID[BR][/BR] TItemPos pos = FindItemByID(mountItemID);[BR][/BR] if (pos != ITEM_INVENTORY_MAX_NUM){[BR][/BR] // Item found in inventory, removing[BR][/BR] RemoveSpecifyItem(mountItemID, 1);[BR][/BR] }[BR][/BR] }[BR][/BR]}[/B]
Customizations and Extra Security
To provide more security, the system can ensure that the item is only removed if it exists in the inventory. Additionally, before dismounting, whether the item is actually being used should be checked. This prevents misuse. Also, logging the dismounting action helps with debugging.
Possible Errors and Solutions
One potential error is accidentally removing the item multiple times. To prevent this, a function should verify the item's presence in the inventory before removal. Also, the system should not interfere after a server restart. Therefore, the LeaveHorse function must be tested properly.
Conclusion
Automatically removing an item when dismounting enhances user experience and maintains game balance in private Metin2 servers. With C++ based development, this system can be easily integrated and customized, creating both a secure and user-friendly environment.
