gm ler /i komutunu kullanarak item yaratabiliyorlar, normalde /i 27992 komutunu kullandığında 1 adet beyaz inci üretilir ve /i 27992 10 komutunu kullandığında ise 10 adet beyaz inci üretilir. Bu güncellemeyle birlikte /i 27992 10 10 komutunu kullandığınızda 10 adet 10 lu beyaz inci üretebilirsiniz. stacklenmeyen itemler için komut örneği: /i 19 0 10 (10 adet +9 kılıç üretir)
do_item Döngü Güncellemesi Nedir?
Metin2 özel sunucularında geliştirme yaparken karşılaşılan önemli konulardan birisi olan 'do_item' döngüsü, oyuncuların envanterindeki itemleri kontrol eden ve belirli aksiyonları gerçekleştiren sistemdir. Bu döngü, genellikle C++ tabanlı sunucu kaynak kodlarında bulunur ve oyuncu etkileşimleri sırasında aktif hale gelir. Ancak eski versiyonlarda performans sorunlarına neden olabilir. Bu yazıda do_item döngüsünün ne olduğu, nasıl çalıştığı ve nasıl güncellenmesi gerektiği konusunda detaylı bilgi vereceğiz.
do_item Döngüsünün Temelleri
do_item fonksiyonu, oyuncunun envanterindeki her bir itemi kontrol ederek belirli işlemleri başlatır. Bu işlemler, örneğin bir itemin süresinin dolması, efektin bitmesi ya da pasif bonusların yenilenmesi olabilir. Eski sistemlerde bu işlem her frame'de tüm slotlar için tekrarlanır, bu da CPU üzerinde ciddi bir yük oluşturur. Bu durum özellikle yoğun oyunculu sunucularda performans düşüklüğüne sebep olabilir.
Performans Etkileri
Geliştiriciler, özellikle PvP sunucularında, her milisaniyenin kritik olduğunu bilirler. Eski do_item döngüsü, her oyuncu için her frame'de çalıştığı için sunucu gecikmelerine neden olabilir. Özellikle 100+ oyunculu sunucularda bu durum daha belirgin hale gelir. Bu nedenle döngü güncellenmeli ve sadece gerekli durumlarda çalışacak şekilde optimize edilmelidir.
do_item Döngüsünü Nasıl Güncelleyebiliriz?
Güncellemek için ilk adım, döngüyü sabit aralıklarla değil, sadece item durumu değiştiğinde çalıştırmaktır. Bunun için item event sistemleri kullanılabilir. Örneğin bir itemin süresi doluyorsa, sadece o itemi etkileyen bir event tetiklenebilir. Bu sayede tüm envanter taranmak yerine sadece etkilenen slot kontrol edilir.
Ayrıca C++ seviyesinde, item slotlarını bir vektörde tutmak ve sadece dolu slotları döngüye almak da etkili bir yöntemdir. Böylece boş slotlara harcanan CPU zamanı ortadan kalkar. Ayrıca, Python kök dosyalarında da benzer optimizasyonlar yapılabilir. Özellikle py root içinde tanımlanan fonksiyonlar, item etkileşimlerini daha akıllıca yönetebilir.
Örnek Kod Yapısı
Yeni sistemde, item slotları için bir event queue kullanılabilir. Her item süresi dolacaksa, bir zamanlayıcıya alınır ve sadece o an geldiğinde işlem yapılır. Bu sayede do_item döngüsü, artık her frame çalışmayacaktır. Bu güncelleme, hem game server hem de auth server üzerinde ciddi bir performans artışı sağlayabilir.
Sonuç
do_item döngüsü güncellemesi, Metin2 özel sunucularında büyük önem taşır. Doğru yapıldığında, hem sunucu stabilitesi artar hem de oyuncu deneyimi olumlu yönde etkilenir. Özellikle PvP sistemlerinde, her milisaniye fark yaratır. Bu nedenle geliştiricilerin bu konuya özel önem göstermesi gerekir.
What is the do_item Loop Update?
In Metin2 private server development, one of the important topics encountered is the 'do_item' loop, which controls items in player inventory and executes certain actions. This loop is typically found in C++ based server source codes and becomes active during player interactions. However, in older versions, it can cause performance issues. In this article, we will provide detailed information about what the do_item loop is, how it works, and how it should be updated.
Basics of the do_item Loop
The do_item function checks each item in the player's inventory and initiates specific operations. These operations may include expiration of an item's duration, ending effects, or refreshing passive bonuses. In old systems, this process repeats for all slots every frame, creating significant load on the CPU. This situation can especially cause performance drops on servers with high player traffic.
Performance Effects
Developers, especially those working on PvP servers, know that every millisecond counts. The old do_item loop runs for each player every frame, potentially causing server delays. This issue becomes more noticeable on servers with over 100 players. Therefore, the loop should be updated and optimized to run only when necessary.
How Can We Update the do_item Loop?
To update, the first step is to run the loop not at fixed intervals but only when an item status changes. For this, item event systems can be used. For example, if an item's duration expires, an event affecting only that item can be triggered. Thus, instead of scanning the entire inventory, only the affected slot is checked.
Additionally, at the C++ level, storing item slots in a vector and looping only through filled slots is also effective. This eliminates CPU time wasted on empty slots. Moreover, similar optimizations can be applied in Python root files. Functions defined in py root, for instance, can manage item interactions more intelligently.
Sample Code Structure
In the new system, an event queue can be used for item slots. If an item's time expires, it is added to a timer and processed only when the time arrives. This way, the do_item loop no longer runs every frame. This update can significantly improve performance on both the game server and auth server.
Conclusion
Updating the do_item loop is crucial for Metin2 private servers. When done correctly, it increases both server stability and enhances player experience. Especially in PvP systems, every millisecond matters. Hence, developers must pay special attention to this topic.
Kod:
ACMD(do_item) { char arg1[256], arg2[256], arg3[256]; one_argument(two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3)); DWORD dwVnum = 0; int iCount = 1; int loop_count = 1; if (!*arg1) { ch->ChatPacket(CHAT_TYPE_INFO, "Usage: item <item vnum>"); return; } if (isnhdigit(*arg1)) str_to_number(dwVnum, arg1); else { if (!ITEM_MANAGER::instance().GetVnum(arg1, dwVnum)) { ch->ChatPacket(CHAT_TYPE_INFO, "#%u item not exist by that vnum.", dwVnum); return; } } if (*arg2) { str_to_number(iCount, arg2); iCount = MINMAX(1, iCount, ITEM_MAX_COUNT); } if (*arg3) { str_to_number(loop_count, arg3); loop_count = MINMAX(1, loop_count, 20);//ITEM_MAX_COUNT gibi sabit oluşturmadan yaptım, siz değiştirebilirsiniz.Not: 20 sayısı sınırdır ve bunu çok arttırmayın. } for (int i = 0; i < loop_count; ++i) { LPITEM item = ITEM_MANAGER::instance().CreateItem(dwVnum, iCount, 0, true); if (!item) { ch->ChatPacket(CHAT_TYPE_INFO, "#%u item not exist by that vnum.", dwVnum); break;//item yoksa for döngüsünden çık } if (item->IsDragonSoul()) { int iEmptyPos = ch->GetEmptyDragonSoulInventory(item); if (iEmptyPos != -1) { item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos)); LogManager::instance().ItemLog(ch, item, "GM", item->GetName()); } else { M2_DESTROY_ITEM(item); if (!ch->DragonSoul_IsQualified()) { ch->ChatPacket(CHAT_TYPE_INFO, "Àκ¥ÀÌ È°¼ºÈ µÇÁö ¾ÊÀ½."); } else { ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space."); } break;//envanterde yer yoksa for döngüsünden çık } } else { int iEmptyPos = ch->GetEmptyInventory(item->GetSize()); if (iEmptyPos != -1) { item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos)); LogManager::instance().ItemLog(ch, item, "GM", item->GetName()); } else { M2_DESTROY_ITEM(item); ch->ChatPacket(CHAT_TYPE_INFO, "Not enough inventory space."); break;//envanterde yer yoksa for döngüsünden çık } } } }
do_item Döngü Güncellemesi Nedir?
Metin2 özel sunucularında geliştirme yaparken karşılaşılan önemli konulardan birisi olan 'do_item' döngüsü, oyuncuların envanterindeki itemleri kontrol eden ve belirli aksiyonları gerçekleştiren sistemdir. Bu döngü, genellikle C++ tabanlı sunucu kaynak kodlarında bulunur ve oyuncu etkileşimleri sırasında aktif hale gelir. Ancak eski versiyonlarda performans sorunlarına neden olabilir. Bu yazıda do_item döngüsünün ne olduğu, nasıl çalıştığı ve nasıl güncellenmesi gerektiği konusunda detaylı bilgi vereceğiz.
do_item Döngüsünün Temelleri
do_item fonksiyonu, oyuncunun envanterindeki her bir itemi kontrol ederek belirli işlemleri başlatır. Bu işlemler, örneğin bir itemin süresinin dolması, efektin bitmesi ya da pasif bonusların yenilenmesi olabilir. Eski sistemlerde bu işlem her frame'de tüm slotlar için tekrarlanır, bu da CPU üzerinde ciddi bir yük oluşturur. Bu durum özellikle yoğun oyunculu sunucularda performans düşüklüğüne sebep olabilir.
Performans Etkileri
Geliştiriciler, özellikle PvP sunucularında, her milisaniyenin kritik olduğunu bilirler. Eski do_item döngüsü, her oyuncu için her frame'de çalıştığı için sunucu gecikmelerine neden olabilir. Özellikle 100+ oyunculu sunucularda bu durum daha belirgin hale gelir. Bu nedenle döngü güncellenmeli ve sadece gerekli durumlarda çalışacak şekilde optimize edilmelidir.
do_item Döngüsünü Nasıl Güncelleyebiliriz?
Güncellemek için ilk adım, döngüyü sabit aralıklarla değil, sadece item durumu değiştiğinde çalıştırmaktır. Bunun için item event sistemleri kullanılabilir. Örneğin bir itemin süresi doluyorsa, sadece o itemi etkileyen bir event tetiklenebilir. Bu sayede tüm envanter taranmak yerine sadece etkilenen slot kontrol edilir.
Ayrıca C++ seviyesinde, item slotlarını bir vektörde tutmak ve sadece dolu slotları döngüye almak da etkili bir yöntemdir. Böylece boş slotlara harcanan CPU zamanı ortadan kalkar. Ayrıca, Python kök dosyalarında da benzer optimizasyonlar yapılabilir. Özellikle py root içinde tanımlanan fonksiyonlar, item etkileşimlerini daha akıllıca yönetebilir.
Örnek Kod Yapısı
Yeni sistemde, item slotları için bir event queue kullanılabilir. Her item süresi dolacaksa, bir zamanlayıcıya alınır ve sadece o an geldiğinde işlem yapılır. Bu sayede do_item döngüsü, artık her frame çalışmayacaktır. Bu güncelleme, hem game server hem de auth server üzerinde ciddi bir performans artışı sağlayabilir.
Sonuç
do_item döngüsü güncellemesi, Metin2 özel sunucularında büyük önem taşır. Doğru yapıldığında, hem sunucu stabilitesi artar hem de oyuncu deneyimi olumlu yönde etkilenir. Özellikle PvP sistemlerinde, her milisaniye fark yaratır. Bu nedenle geliştiricilerin bu konuya özel önem göstermesi gerekir.
What is the do_item Loop Update?
In Metin2 private server development, one of the important topics encountered is the 'do_item' loop, which controls items in player inventory and executes certain actions. This loop is typically found in C++ based server source codes and becomes active during player interactions. However, in older versions, it can cause performance issues. In this article, we will provide detailed information about what the do_item loop is, how it works, and how it should be updated.
Basics of the do_item Loop
The do_item function checks each item in the player's inventory and initiates specific operations. These operations may include expiration of an item's duration, ending effects, or refreshing passive bonuses. In old systems, this process repeats for all slots every frame, creating significant load on the CPU. This situation can especially cause performance drops on servers with high player traffic.
Performance Effects
Developers, especially those working on PvP servers, know that every millisecond counts. The old do_item loop runs for each player every frame, potentially causing server delays. This issue becomes more noticeable on servers with over 100 players. Therefore, the loop should be updated and optimized to run only when necessary.
How Can We Update the do_item Loop?
To update, the first step is to run the loop not at fixed intervals but only when an item status changes. For this, item event systems can be used. For example, if an item's duration expires, an event affecting only that item can be triggered. Thus, instead of scanning the entire inventory, only the affected slot is checked.
Additionally, at the C++ level, storing item slots in a vector and looping only through filled slots is also effective. This eliminates CPU time wasted on empty slots. Moreover, similar optimizations can be applied in Python root files. Functions defined in py root, for instance, can manage item interactions more intelligently.
Sample Code Structure
In the new system, an event queue can be used for item slots. If an item's time expires, it is added to a timer and processed only when the time arrives. This way, the do_item loop no longer runs every frame. This update can significantly improve performance on both the game server and auth server.
Conclusion
Updating the do_item loop is crucial for Metin2 private servers. When done correctly, it increases both server stability and enhances player experience. Especially in PvP systems, every millisecond matters. Hence, developers must pay special attention to this topic.
