Create İtem [C++] (Oyun İçi Edit İtem Yaratma)

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Selamlar,
Sistem Videoda Gösteriliyor Kısaca Söylemek Gerekirse:
Oyun İçinde Kod İle Edit Yaratabiliyosunuz.
...



Kod:
[/B] [B]    //////////////////////////////////////////////                          ##cmd.cpp       ////////////////////////////////////////////// //Arat: ACMD(do_item); //Değiştir: ACMD(do_create_item); ACMD(do_item); //Arat:     { "item",        do_item,        0,            POS_DEAD,    GM_GOD        }, //Değiştir:     {"create_item",        do_create_item,        0,            POS_DEAD,    GM_IMPLEMENTOR        },     { "item",        do_item,        0,            POS_DEAD,    GM_GOD        },                    //////////////////////////////////////////////                        ##cmd_gm.cpp       ////////////////////////////////////////////// //En Üste Ekleyiniz: #include <iostream> #include <vector> #include <string> void split(const std::string& s, char delim, std::vector<std::string>& v) {     int i = 0;     int pos = s.find(delim);     while (pos != std::string::npos)     {         v.push_back(s.substr(i, pos-i));         i = ++pos;         pos = s.find(delim, pos);         if (pos == std::string::npos) v.push_back(s.substr(i, s.length()));     } } int countChars(char* s, char c) {     return *s == '\0' ? 0 : countChars( s + 1, c ) + (*s == c); } //Arat: ACMD(do_item); //Altına ekle: ACMD(do_create_item) {     char item[256];     char bonus[1024];     two_arguments(argument, item, sizeof(item), bonus, sizeof(bonus));     if (!*item || !*bonus)     {         ch->ChatPacket(CHAT_TYPE_INFO, "/create_item <cod_item> <b1:v1,b2:v2,b3:v3,b4:v4,b5:v5>");         return;     }     if (bonus[(strlen(bonus)-1)] == ',') {         ch->ChatPacket(CHAT_TYPE_INFO, "Lipseste , intre valoare si bonus.");         return;     }     if (bonus[(strlen(bonus)-1)] == ':') {         ch->ChatPacket(CHAT_TYPE_INFO, "Lipseste : intre bonus si valoare.");         return;     }     if (strstr(bonus, ":") == NULL) {         ch->ChatPacket(CHAT_TYPE_INFO, "Lipseste : intre bonus si valoare.");         return;     }     if (strstr(bonus, ",") == NULL) {         ch->ChatPacket(CHAT_TYPE_INFO, "Ai adaugat 1 bonus.");         int vnum=0;         str_to_number(vnum, item);         LPITEM i = ITEM_MANAGER::instance().CreateItem(vnum);         if (!i) {             ch->ChatPacket(CHAT_TYPE_INFO, "");             ch->ChatPacket(CHAT_TYPE_INFO, "Acest item nu exista.");             return;         }         int bonus_vnum=0;         int bonus_value=0;         std::vector<std::string> bonus2;         split(std::string(bonus), ':', bonus2);         str_to_number(bonus_vnum, std::string(bonus2[0]).c_str());         str_to_number(bonus_value, std::string(bonus2[1]).c_str());         i->SetForceAttribute(0, bonus_vnum, bonus_value);         i->SetSocket(0, 1);         int inventario = ch->GetEmptyInventory(i->GetSize());         if (inventario != -1) {             i->AddToCharacter(ch, TItemPos(INVENTORY, inventario));             ch->ChatPacket(CHAT_TYPE_INFO, "Succes!");         }else{             M2_DESTROY_ITEM(i);             ch->ChatPacket(CHAT_TYPE_INFO, "Nu ai suficient spatiu in inventar.");         }     }else{         std::vector<std::string> bonus1;         split(std::string(bonus), ',', bonus1);         if (bonus1.size()>0) {             ch->ChatPacket(CHAT_TYPE_INFO, "Ai adaugat %d bonusuri.", (int)bonus1.size());             if (countChars(bonus, ':') != (int)bonus1.size()) {                 ch->ChatPacket(CHAT_TYPE_INFO, "");                 ch->ChatPacket(CHAT_TYPE_INFO, "Lipseste , intre valoare si bonus.");                 return;                           }             int vnum=0;             str_to_number(vnum, item);             LPITEM i = ITEM_MANAGER::instance().CreateItem(vnum);             if (!i) {                 ch->ChatPacket(CHAT_TYPE_INFO, "Acest item nu exista.");                 return;             }             int b_size=bonus1.size();             if (bonus1.size()>6) b_size=7;             int bonus_vnum=0;             int bonus_value=0;             for (int n=0; n<b_size; n++) {                 std::vector<std::string> bonus2;                 split(std::string(bonus1[n]), ':', bonus2);                 str_to_number(bonus_vnum, std::string(bonus2[0]).c_str());                 str_to_number(bonus_value, std::string(bonus2[1]).c_str());                 i->SetForceAttribute(n, bonus_vnum, bonus_value);             }             i->SetSocket(0, 1);             int inventario = ch->GetEmptyInventory(i->GetSize());             if (inventario != -1) {                 i->AddToCharacter(ch, TItemPos(INVENTORY, inventario));                 ch->ChatPacket(CHAT_TYPE_INFO, "Succes!");             }else{                 M2_DESTROY_ITEM(i);                 ch->ChatPacket(CHAT_TYPE_INFO, "Nu ai suficient spatiu in inventar.");             }         }     } }



Metin2 Oyunu İçin C++ ile Oyun İçi Öğe Yaratma Rehberi

Metin2 Lobby olarak, Metin2 özel sunucu geliştirme sürecinde Create Item sistemi, oyun içi özel nesne yaratımı için kritik öneme sahiptir. Bu sistem özellikle C++ tabanlı sunucu kaynak kodlarında geliştirilerek, oyun içinde dinamik eşya yaratma imkanı sunar. Bu yazıda, C++ kullanarak Metin2 özel sunucularında Edit Item yani oyun içi öğe düzenleme veya yaratma sistemini nasıl kuracağınızı detaylıca anlatacağız.

C++ ile Oyun İçinde Eşya Oluşturmak

Metin2 sunucu tarafında C++ kodlama ile eşya yaratmak için öncelikle game core üzerinde çalışmanız gerekir. Bu işlem sırasında item_manager.cpp, char_item.cpp gibi dosyalar üzerinde değişiklikler yapmanız gerekir. Bu dosyalar sayesinde sunucu tarafında bir eşyanın doğuşunu, özelliklerini ve kullanım süreçlerini kontrol edebilirsiniz.

Yeni Eşya Tanımı Oluşturmak

Önce bir eşya numarası tanımlanmalıdır. Bu numara item_proto.txt dosyasında yer alır. Bu dosya DB Core ile entegre çalışarak, sunucu başlatıldığında tüm eşyaların doğru yüklenmesini sağlar. C++ üzerinden eşya yaratma fonksiyonları, bu prototiplere dayanarak çalışır. Örneğin:

ItemManager::Instance().CreateItem(item_vnum, count, x, y);

Bu fonksiyon ile belirtilen konumda belirli bir eşya yaratılabilir. Count parametresi ile adet sayısı, x,y[/COORD] ile konum ayarlanabilir.

Oyun İçinde Eşya Yaratma Komutları

Sunucu tarafında bir GM komutu tanımlanarak, oyun içinden eşya yaratma işlemi yapılabilir. Bunun için cmd_gm.cpp dosyasına özel bir fonksiyon yazılır. Örnek komut şu şekilde olabilir:

/createitem 71001 1

Bu komut, ID'si 71001 olan eşyadan 1 adet yaratır. Bu işlem sırasında C++ fonksiyonları ile hem DB'ye kayıt yapılır hem de karakterin envanterine eklenir.

Python ile Entegrasyon

Metin2 sistemlerinde Python tarafı da önemli rol oynar. Özellikle uiscript ve py root[/COORD] yapıları ile GUI üzerinden eşya yaratma işlemleri yapılabilir. Bu yapılarla birlikte Py GUI kullanarak, admin paneli gibi arayüzlerle kolayca eşya yönetimi sağlanabilir.

Martysama ve Diğer Geliştirici Kaynakları

Metin2Dev toplulukları ve Martysama[/COORD] gibi geliştirici kaynakları, bu tür sistemlerin geliştirilmesinde büyük destek sağlar. Bu kaynaklarda bulunan C++ scriptleri, örnek kodlar ve derleme süreçleri hakkında bilgi edinmek mümkündür. Ayrıca pack[/COORD] dosyaları ile client tarafında da özel değişiklikler yapılabilir.

Derleme ve Test Süreci

Tüm değişikliklerden sonra compile[/COORD] işlemi yapılmalıdır. Game[/COORD] ve Auth[/COORD] serverlar yeniden derlenir. Source edit[/COORD] işlemleri sonrası test sunucusunda tüm işlemler kontrol edilmelidir. Client SRC[/COORD] ile uyumlu olacak şekilde eşya görselleri ve tanımları güncellenmelidir.

Sonuç

Create Item[/COORD] sistemi, Metin2 özel sunucularında güçlü ve esnek bir içerik yönetim aracıdır. C++[/COORD] ile geliştirilen bu sistem sayesinde, sunucu yöneticileri oyun içi etkinliklere özel eşyalar yaratabilir, PvP sistemlerine özel bonuslar ekleyebilirler. Metin2 Lobby[/COORD] olarak, bu tür gelişmiş sistemleri öğrenmek isteyen geliştiricilere destek olmaya devam ediyoruz.


Creating In-Game Items with C++ for Metin2

Metin2 Lobby provides critical support for creating Create Item systems within private servers. This system, especially developed on C++-based server source codes, enables dynamic item creation inside the game. In this article, we will explain in detail how to implement an Edit Item system, which allows creating or editing items in-game, using C++.

Creating Items Inside the Game with C++

To create items using C++ on the Metin2 server side, you first need to work on the game core. During this process, modifications must be made to files such as item_manager.cpp and char_item.cpp. These files allow you to control the spawning, properties, and usage of items within the game.

Defining a New Item

An item number must first be defined. This number appears in the item_proto.txt file, which integrates with the DB Core to ensure all items are correctly loaded when the server starts. The C++ functions for item creation rely on these prototypes. For example:

ItemManager::Instance().CreateItem(item_vnum, count, x, y);

This function creates a specific item at a given location. The count parameter sets the quantity, while x,y[/COORD] set the position.

In-Game Commands for Item Creation

GM commands can be defined on the server side to create items directly in-game. To do so, a custom function can be added to the cmd_gm.cpp file. An example command could look like this:

/createitem 71001 1

This command creates one instance of the item with ID 71001. During this process, C++ functions register the item into the database and add it to the character's inventory.

Integration with Python

The Python side plays an important role in Metin2 systems. With structures like uiscript and py root[/COORD], item creation operations can be performed via GUI. Interfaces such as Py GUI[/COORD] allow easy management of items through admin panels or similar interfaces.

Resources Like Martysama and Developer Communities

Metin2Dev[/COORD] communities and developer resources like Martysama[/COORD] offer significant support during the development of such systems. You can find sample codes, compilation guides, and C++[/COORD] scripts on these platforms. Additionally, special modifications can be made on the client-side using pack[/COORD] files.

Compilation and Testing Process

After making all changes, a compile[/COORD] operation must be performed. Both Game[/COORD] and Auth[/COORD] servers should be recompiled. After source edit[/COORD] processes, all operations should be tested on a test server. Item visuals and definitions must also be updated to be compatible with Client SRC[/COORD].

Conclusion

The Create Item[/COORD] system is a powerful and flexible content management tool in Metin2 private servers. Thanks to this C++[/COORD]-developed system, server administrators can create special items for in-game events and add bonuses to PvP systems. As Metin2 Lobby[/COORD], we continue to support developers looking to learn more about such advanced systems.
 

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

Benzer konular

Geri
Üst Alt