Jump to content

Recommended Posts


Hi, when I create an item from the website or buy from item shop and then log in with a new character, I get these errors and the item received at login disappears:

SYSERR: Oct 12 15:52:38 :: CreateItem: ITEM_ID_DUP: 60000042 Pumnale del Rubino owner 0x41615000
SYSERR: Oct 12 15:52:38 :: ItemLoad: cannot create item by vnum 27112 (name DAN id 60000042)

Does anyone know how to fix this?

Link to comment
https://metin2.dev/topic/34040-problem-createitem-item_id_dup/
Share on other sites

  • Premium
20 hours ago, Achilles said:


Hi, when I create an item from the website or buy from item shop and then log in with a new character, I get these errors and the item received at login disappears:

SYSERR: Oct 12 15:52:38 :: CreateItem: ITEM_ID_DUP: 60000042 Pumnale del Rubino owner 0x41615000
SYSERR: Oct 12 15:52:38 :: ItemLoad: cannot create item by vnum 27112 (name DAN id 60000042)

Does anyone know how to fix this?

You have to use item_award ymir system

That ITEM_ID_DUP error means the server tried to create an item using an ID that already exists in memory. Basically, when CreateItem sees that the ID is already taken, it refuses to load the item and logs that message. That’s why the item disappears right after login — it never really gets created inside the core.

In most cases this happens because items are being inserted into the database with a fixed ID instead of letting the game generate one. The item IDs have to be unique across the whole server, and the core normally assigns them automatically. If something outside the game  puts its own value there, you’ll eventually get duplicates.

 

The issue is almost always caused by duplicate item IDs, either: inserted manually in the player.item table ( in your case the item shop), or generated by two cores using overlapping item ID ranges.

 

How item IDs are supposed to work?

When you create a new item, you should never assign a fixed id.

Let the server do it automatically:

bool bIsNewItem = (0 == id);
...
else {
    item->SetID(GetNewID());
}

If you pass id = 0, the core will call GetNewID() and assign a unique value within its configured ID range.

 

How to debug..

  • Check for duplicates in the database
SELECT id, COUNT(*) 
FROM item 
GROUP BY id 
HAVING COUNT(*) > 1;

SQL query to cehck for that specific id:

SELECT * FROM player.item WHERE id = 60000042;

Check also item_award for dup's

If you see the same ID more than once, that’s the problem.
Either delete those extra rows or set the id column to 0 so the server can reassign it.

  • Check how your item shop inserts items

Make sure your insert query looks like in case your website/itemshop automatically insert items into item.sql

INSERT INTO player.item (owner_id, window, pos, vnum, count, id)
VALUES (<owner>, 'MALL', 0, 72701, 1, 0);

or simply omit the id field.
Don’t ever set it manually to a static number.

 

In short:
The server’s item manager refuses to load any item whose ID already exists in memory.
Always let the game assign IDs (id=0), and make sure your DB and channels don’t overlap ID ranges.

 

If you can tell me how your itemshop work i can help you further, it's using item_award or insert manually in item.sql?

Edited by mmorse3399
  • Metin2 Dev 2
  • Active+ Member

if you switch the item id generation system to a time based approach like snowflake or uuidv7 and reserve an unused legacy id range for manually assigned ids (such as item shop entries), you can prevent id collisions and similar issues

you can check

This is the hidden content, please
use the ch id as the zone identifier and the core id as the shard

  • Metin2 Dev 13
  • Good 4
  • Love 2
On 10/15/2025 at 5:59 PM, Koray said:

if you switch the item id generation system to a time based approach like snowflake or uuidv7 and reserve an unused legacy id range for manually assigned ids (such as item shop entries), you can prevent id collisions and similar issues

you can check

This is the hidden content, please
use the ch id as the zone identifier and the core id as the shard

Can you explain me one more Time, please? But with more details 

  • Active+ Member
11 hours ago, Achilles said:

Can you explain me one more Time, please? But with more details 

remove legacy db based item id range generation methods, convert all item id data types in the whole source code to uint64_t, and implement snowflake for new id generation

Initilization:

- bool ITEM_MANAGER::Initialize()
+ bool ITEM_MANAGER::Initialize(const uint8_t channel, const uint8_t core)
{
#ifdef ITEM_UUID_SNOWFLAKE
    try
    {
        m_idGenerator.emplace(channel, core);
    }
    catch (const std::exception& ex)
    {
        SPDLOG_ERROR("ITEM_MANAGER: Snowflake init failed – {}", ex.what());
        m_idGenerator.reset();
        return false;
    }
#endif

    [...]

Declaration:

+    std::optional<snowflake::Generator<>> m_idGenerator;

-    bool Initialize();
+    bool Initialize(const uint8_t channel, const uint8_t core);

-    if (!m_itemManager.Initialize())
+    if (!m_itemManager.Initialize(gConfig.channel, gConfig.core))

Generation method:
 

ItemID ITEM_MANAGER::GenerateNewItemID()
{
#ifdef ITEM_UUID_SNOWFLAKE
    return m_idGenerator->next();
#else
    static UUIDv7Generator gen;
    for (;;) {
        if (auto id = gen.generate())
            return id->to_string();
    }
#endif
}

Call sample:
 

-        item->SetID(GetNewID());
+        item->SetID(this->GenerateNewItemID());

 

  • Smile Tear 1

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.