Neler yeni

Foruma hoş geldin, Ziyaretçi

Metin2Lobby.com Metin2 Private Server Tanıtım Advertising Ve Geliştirme Forumudur.Metin2 pvp serverler,1-99,1-105,1-120,55-120 global serverları paylaş yada ara.
Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Başlangıç İtemlerini Mysqlden Anlık Çeksin Efsunlu Ve Taşlı Şekilde.

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Konular
48,285
Mesajlar
48,595
Tepkime puanı
75
M2 Yaşı
3 yıl 11 ay 10 gün
Trophy Puan
48
Konum
Web sitesi
M2 Yang
488,819
Ticaret : 1 / 0 / 0
Ticaret Oranı : 100%
Başlangıç itemlerini sunucudan veya srcden veya quest'ten çektirmek düzenlemek zahmetli oluyordu bi nevi şuan üzerinde
çalışmış olduğum metin2 yönetim paneli için ayarladım diyebilirim ama kullanılmasını
tavsiye ederim çünkü en ufak değişiklikte herhangi bir reload gerektirmez anlık çeker.

baslangic_itemleri.sql'yi player kısmına atıp sunucunuza göre düzenleyebilirsiniz.

Örnek Video:



Kod:
void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data)


Kod:
void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data) {     if (!d)         return;     TPacketDGCreateSuccess * pPacketDB = (TPacketDGCreateSuccess *)data;     if (pPacketDB->bAccountCharacterIndex >= PLAYER_PER_ACCOUNT)     {         d->Packet(encode_byte(HEADER_GC_CHARACTER_CREATE_FAILURE), 1);         return;     }     long lIndex = 0;     if (!CMapLocation::instance().Get(pPacketDB->player.x,         pPacketDB->player.y,         lIndex,         pPacketDB->player.lAddr,         pPacketDB->player.wPort))     {         sys_err("InputDB::PlayerCreateSuccess: cannot find server for mapindex %d %d x %d (name %s)",             lIndex,             pPacketDB->player.x,             pPacketDB->player.y,             pPacketDB->player.szName);     }     TAccountTable & r_Tab = d->GetAccountTable();     r_Tab.players[pPacketDB->bAccountCharacterIndex] = pPacketDB->player;     TPacketGCPlayerCreateSuccess pack;     pack.header = HEADER_GC_CHARACTER_CREATE_SUCCESS;     pack.bAccountCharacterIndex = pPacketDB->bAccountCharacterIndex;     pack.player = pPacketDB->player;     d->Packet(&pack, sizeof(TPacketGCPlayerCreateSuccess));     unsigned job = pPacketDB->player.byJob;         if (job >= JOB_MAX_NUM)         job = job % 4;         DWORD dwPlayerID = r_Tab.players[pPacketDB->bAccountCharacterIndex].dwID;         char szQuery[1024];     snprintf(szQuery, sizeof(szQuery),         "SELECT window_type, position, count, item_vnum, "         "socket0, socket1, socket2, socket3, socket4, "         "attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, "         "attrtype3, attrvalue3, attrtype4, attrvalue4, attrtype5, attrvalue5, "         "attrtype6, attrvalue6 "         "FROM player.baslangic_itemleri "         "WHERE job = %u AND is_active = 1 "         "ORDER BY window_type DESC, position",         job);         std::unique_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(szQuery));         if (pMsg.get() && pMsg->Get()->uiNumRows > 0)     {         MYSQL_ROW row;         TPlayerItem t;                 while ((row = mysql_fetch_row(pMsg->Get()->pSQLResult)))         {             memset(&t, 0, sizeof(t));                         int col = 0;             t.owner = dwPlayerID;             t.id = ITEM_MANAGER::instance().GetNewID();                         t.window = atoi(row[col++]);             t.pos = atoi(row[col++]);             t.count = atoi(row[col++]);             t.vnum = atoi(row[col++]);                         // Socketler (5 taş Sizde Kaç Taş Varsa Ona Göre Ayarlayın)             t.alSockets[0] = atoll(row[col++]);             t.alSockets[1] = atoll(row[col++]);             t.alSockets[2] = atoll(row[col++]);             t.alSockets[3] = atoll(row[col++]);             t.alSockets[4] = atoll(row[col++]);                         // Efsunlar (5+2 7 bonus)             for (int i = 0; i < 7; i++)             {                 t.aAttr[i].bType = atoi(row[col++]);                 t.aAttr[i].sValue = atoi(row[col++]);             }                         db_clientdesc->DBPacketHeader(HEADER_GD_ITEM_SAVE, 0, sizeof(TPlayerItem));             db_clientdesc->Packet(&t, sizeof(TPlayerItem));         }     }     else     {         sys_err("baslangic_itemleri: [HATA] İtemler Karaktere Verilemedi Lütfen Mysql baslangic_temleri Tablosunu Kontrol Ediniz.", job);     }     LogManager::instance().CharLog(pack.player.dwID, 0, 0, 0, "CREATE PLAYER", "", d->GetHostName()); }


Kod:
/*  Navicat Premium Dump SQL  Source Server         : 1-99 Altay2 Börü  Source Server Type    : MySQL  Source Server Version : 110403 (11.4.3-MariaDB)  Source Host           : 192.168.1.99:3306  Source Schema         : player  Target Server Type    : MySQL  Target Server Version : 110403 (11.4.3-MariaDB)  File Encoding         : 65001  Date: 08/01/2026 19:48:10 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for baslangic_itemleri -- ---------------------------- DROP TABLE IF EXISTS `baslangic_itemleri`; CREATE TABLE `baslangic_itemleri`  (   `id` int NOT NULL AUTO_INCREMENT,   `job` tinyint NOT NULL COMMENT '0=Savasci, 1=Ninja, 2=Sura, 3=Saman',   `window_type` tinyint NOT NULL COMMENT '0=EQUIPMENT, 1=INVENTORY',   `position` tinyint NOT NULL,   `count` int NULL DEFAULT 1,   `item_vnum` int NOT NULL,   `attrtype0` tinyint NULL DEFAULT 0,   `attrvalue0` smallint NULL DEFAULT 0,   `attrtype1` tinyint NULL DEFAULT 0,   `attrvalue1` smallint NULL DEFAULT 0,   `attrtype2` tinyint NULL DEFAULT 0,   `attrvalue2` smallint NULL DEFAULT 0,   `attrtype3` tinyint NULL DEFAULT 0,   `attrvalue3` smallint NULL DEFAULT 0,   `attrtype4` tinyint NULL DEFAULT 0,   `attrvalue4` smallint NULL DEFAULT 0,   `attrtype5` tinyint NULL DEFAULT 0,   `attrvalue5` smallint NULL DEFAULT 0,   `attrtype6` tinyint NULL DEFAULT 0,   `attrvalue6` smallint NULL DEFAULT 0,   `socket0` bigint NULL DEFAULT 0,   `socket1` bigint NULL DEFAULT 0,   `socket2` bigint NULL DEFAULT 0,   `socket3` bigint NULL DEFAULT 0,   `socket4` bigint NULL DEFAULT 0,   `is_active` tinyint(1) NULL DEFAULT 1,   PRIMARY KEY (`id`) USING BTREE,   INDEX `idx_job`(`job`) USING BTREE ) ENGINE = MyISAM AUTO_INCREMENT = 38 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Fixed; -- ---------------------------- -- Records of baslangic_itemleri -- ---------------------------- INSERT INTO `baslangic_itemleri` VALUES (1, 0, 1, 8, 1, 11207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28443, 28438, 28442, 28439, 28441, 1); INSERT INTO `baslangic_itemleri` VALUES (2, 0, 1, 0, 1, 12207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (3, 0, 1, 1, 1, 15007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (4, 0, 1, 2, 1, 14007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (5, 0, 1, 9, 1, 17, 63, 50, 72, 50, 71, 35, 17, 25, 9, 20, 0, 0, 0, 0, 28430, 28431, 28432, 28437, 28433, 1); INSERT INTO `baslangic_itemleri` VALUES (6, 0, 1, 3, 1, 16007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (7, 0, 1, 4, 1, 17007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (8, 0, 1, 6, 1, 13007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (9, 0, 1, 5, 1, 40004, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (10, 1, 1, 0, 1, 11407, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28443, 28438, 28442, 28439, 28441, 1); INSERT INTO `baslangic_itemleri` VALUES (11, 1, 1, 1, 1, 12347, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (12, 1, 1, 2, 1, 15007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (13, 1, 1, 3, 1, 14007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (14, 1, 1, 4, 1, 1007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28430, 28431, 28432, 28437, 28433, 1); INSERT INTO `baslangic_itemleri` VALUES (15, 1, 1, 5, 1, 16007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (16, 1, 1, 6, 1, 17007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (17, 1, 1, 10, 1, 13007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (18, 1, 1, 0, 1, 40004, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (19, 2, 1, 0, 1, 11607, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28443, 28438, 28442, 28439, 28441, 1); INSERT INTO `baslangic_itemleri` VALUES (20, 2, 1, 1, 1, 12487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (21, 2, 1, 2, 1, 15007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (22, 2, 1, 3, 1, 14007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (23, 2, 1, 4, 1, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28430, 28431, 28432, 28437, 28433, 1); INSERT INTO `baslangic_itemleri` VALUES (24, 2, 1, 5, 1, 16007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (25, 2, 1, 6, 1, 17007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (26, 2, 1, 10, 1, 13007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (27, 2, 1, 0, 1, 40004, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (28, 3, 1, 0, 1, 11807, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28443, 28438, 28442, 28439, 28441, 1); INSERT INTO `baslangic_itemleri` VALUES (29, 3, 1, 1, 1, 12627, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (30, 3, 1, 2, 1, 15007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (31, 3, 1, 3, 1, 14007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (32, 3, 1, 4, 1, 7007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28430, 28431, 28432, 28437, 28433, 1); INSERT INTO `baslangic_itemleri` VALUES (33, 3, 1, 5, 1, 16007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (34, 3, 1, 6, 1, 17007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (35, 3, 1, 10, 1, 13007, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); INSERT INTO `baslangic_itemleri` VALUES (36, 3, 1, 0, 1, 40004, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); SET FOREIGN_KEY_CHECKS = 1;


Başlangıç İtemlerini MySQL'den Anlık Çeksin: Efsunlu ve Taşlı Şekilde

Metin2 özel sunucularında kullanıcı deneyimini artırmak için başlangıç itemleri büyük önem taşır. Özellikle oyuncuların yeni karakter oluşturduklarında ellerinde güçlü ve dikkat çekici itemlerle başlaması, onları oyun içi sistemlere yönlendirmenin etkili yollarından biridir. Bu yazıda, başlangıç itemlerinin veritabanı üzerinden dinamik olarak çekilmesini sağlayacağız. Ayrıca bu itemlerin efsunlu ya da taşlı olarak atanmasını ele alacağız. Bu sistem sayesinde, sunucu yöneticisi olarak item listelerini kolayca değiştirebilir ve her karakter oluşturma anında farklı itemlerin atanmasını sağlayabilirsiniz.

MySQL Veritabanı ve Item Bilgileri

Öncelikle, item bilgilerinin tutulduğu bir tabloya ihtiyacımız var. Bu tablo, item ID, efsun seviyesi, taş ID gibi bilgileri içermelidir. Örneğin 'start_items' adında bir tablo oluşturabiliriz:

- id
- item_vnum
- socket0
- socket1
- socket2
- attr_type1
- attr_value1

Bu tabloya örnek veriler:

(1, 71030, 27001, 0, 0, 30, 2)
(2, 71031, 27002, 0, 0, 30, 3)

Sunucu Tarafında Dinamik Item Atama

Game server tarafında, karakter oluşturulduğunda veya harita yüklendiğinde bir fonksiyon çalıştırılır. Bu fonksiyon, MySQL bağlantısı kurarak 'start_items' tablosundan rastgele bir item çeker. Seçilen item, oyuncuya efsun ve socket bilgileriyle birlikte verilir. Bu işlem için C++ tarafında bir SQL sorgusu yazılır:

'SELECT item_vnum, socket0, socket1, socket2, attr_type1, attr_value1 FROM start_items ORDER BY RAND() LIMIT 1'

Python ile GUI Üzerinden Yönetimi Kolaylaştırın

Eğer daha kullanıcı dostu bir yönetim istiyorsanız, Python GUI kullanarak bu tabloyu düzenleyebileceğiniz bir panel oluşturabilirsiniz. PyQT veya Tkinter gibi kütüphanelerle basit bir arayüz tasarlayabilirsiniz. Bu panel sayesinde yeni itemler eklenebilir, mevcutlar güncellenebilir.

Olası Hatalar ve Güvenlik

SQL injection gibi güvenlik açıklarına karşı önlem almanız gerekir. Prepared statements kullanarak bu tür saldırılara karşı korunabilirsiniz. Ayrıca, item ID'lerin doğru girildiğinden emin olmalısınız. Aksi takdirde, oyunculara geçersiz itemler verilebilir.

Sonuç

Bu yapı sayesinde, Metin2 özel sunucularında başlangıç itemlerini esnek ve güçlü bir şekilde yönetebilirsiniz. Oyunculara özel itemler vererek onların dikkatini çekebilir ve oyun içi motivasyonlarını artırabilirsiniz. Sistem, DB tarafında yapılan değişikliklerden anında etkilenir ve dinamik bir yapı sunar.


Fetch Starting Items from MySQL: Enchanted and Socketed Style

In Metin2 private servers, starting items play a key role in enhancing the player experience. Giving players strong and eye-catching items when they create a new character can effectively guide them into the game systems. In this article, we will show how to dynamically fetch starting items from the database. Additionally, we will discuss how these items can be assigned with enchantments or sockets. This system allows server administrators to easily modify item lists and assign different items each time a character is created.

MySQL Database and Item Information

Firstly, we need a table that holds item information such as item ID, enchantment level, and socket IDs. For example, we could create a table named 'start_items':

- id
- item_vnum
- socket0
- socket1
- socket2
- attr_type1
- attr_value1

Sample entries for this table:

(1, 71030, 27001, 0, 0, 30, 2)
(2, 71031, 27002, 0, 0, 30, 3)

Dynamic Item Assignment Server-Side

On the game server side, a function runs when a character is created or a map is loaded. This function connects to MySQL and randomly selects an item from the 'start_items' table. The selected item is then given to the player along with its enchantment and socket attributes. A SQL query in C++ might look like:

'SELECT item_vnum, socket0, socket1, socket2, attr_type1, attr_value1 FROM start_items ORDER BY RAND() LIMIT 1'

Simplify Management with Python GUI

For a more user-friendly management approach, you can build a panel using Python GUI libraries like PyQT or Tkinter. This panel allows you to add or update items in the database easily.

Potential Errors and Security

Be cautious about security vulnerabilities like SQL injection. Use prepared statements to prevent such attacks. Also ensure that item IDs are correctly entered; otherwise, invalid items may be assigned to players.

Conclusion

With this setup, you can flexibly manage starting items in Metin2 private servers. By giving unique items to players, you can capture their attention and boost in-game motivation. The system responds instantly to changes made in the database, offering a dynamic structure.
 

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kaydol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Üye ol
Giriş Yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş Yap

Tema düzenleyici

Tema özelletirmeleri