• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Urgent! Clone items TFS 1.2

chucky91

Advanced OT User
Joined
Apr 8, 2010
Messages
278
Solutions
9
Reaction score
152
Soucer Nostalrius 7.72 from https://otland.net/threads/nostalrius-7-7.262406/

I have a big problem on the Nostalrius TFS 1.2 7.72 server developed by Alejandro Mujica.
There is a player that is cloning items, i caught it in the act once and found out i don't know if it's the same bug. the guy throws the items he wants to clone on the ground, and buys a cup, and throws the cup on the ground, relogs the character and so the items he had thrown before come back to the player.

Could anyone help me, any idea what the error is?
 
Soucer Nostalrius 7.72 from https://otland.net/threads/nostalrius-7-7.262406/

I have a big problem on the Nostalrius TFS 1.2 7.72 server developed by Alejandro Mujica.
There is a player that is cloning items, i caught it in the act once and found out i don't know if it's the same bug. the guy throws the items he wants to clone on the ground, and buys a cup, and throws the cup on the ground, relogs the character and so the items he had thrown before come back to the player.

Could anyone help me, any idea what the error is?
Replace your behaviourdatabase.cpp with the original file from the repository or just compare and you will see the error
 
on my server the same thing happened, or they said it was in the same situation... using cup item id 2012


I was never able to reproduce the problem, I ended up discarding this possibility.
i'm using otx2 -> lord zedd
 
Last edited:
Fix is simple, it relies on behaviordatabase and subtype

C++:
case BEHAVIOUR_TYPE_CREATE: {
        int32_t itemId = evaluate(action->expression, player, message);
        const ItemType& it = Item::items[itemId];

        if (it.stackable) {
            do {
                int32_t count = std::min<int32_t>(100, amount);
                amount[player->getID()] -= count;

                Item* item = Item::CreateItem(itemId, count);
                if (!item) {
                    break;
                }
                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            } while (amount);
        } else {
            if (it.charges) {
                data = it.charges;
            }
            if(data < 0) {
                data = 0;
            }
            for (int32_t i = 0; i < std::max<int32_t>(1, amount); i++) {
                Item* item = Item::CreateItem(itemId, data);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            }
        }

        break;
    }
 
Fix is simple, it relies on behaviordatabase and subtype

C++:
case BEHAVIOUR_TYPE_CREATE: {
        int32_t itemId = evaluate(action->expression, player, message);
        const ItemType& it = Item::items[itemId];

        if (it.stackable) {
            do {
                int32_t count = std::min<int32_t>(100, amount);
                amount[player->getID()] -= count;

                Item* item = Item::CreateItem(itemId, count);
                if (!item) {
                    break;
                }
                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            } while (amount);
        } else {
            if (it.charges) {
                data = it.charges;
            }
            if(data < 0) {
                data = 0;
            }
            for (int32_t i = 0; i < std::max<int32_t>(1, amount); i++) {
                Item* item = Item::CreateItem(itemId, data);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            }
        }

        break;
    }
1669828435436.png1669828413635.png

But guys, i already discovered the problem, is that the "data=0" is missing in the sale items inside the npc.
1669828571002.png

1669829116037.png
So this gives an error to be sent to the db. and does not save the player.
 
Lua:
case BEHAVIOUR_TYPE_CREATE: {
        int32_t itemId = evaluate(action->expression, player, message);
        const ItemType& it = Item::items[itemId];

        if (it.stackable) {
            do {
                int32_t count = std::min<int32_t>(100, amount);
                amount -= count;

                Item* item = Item::CreateItem(itemId, count);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            } while (amount);
        } else {
            for (int32_t i = 0; i < std::max<int32_t>(1, amount); i++) {
                Item* item = Item::CreateItem(itemId, data == -1 ? 0 : data);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            }
        }

        break;
    }

repaired
 
Last edited:
Lua:
case BEHAVIOUR_TYPE_CREATE: {
        int32_t itemId = evaluate(action->expression, player, message);
        const ItemType& it = Item::items[itemId];

        if (it.stackable) {
            do {
                int32_t count = std::min<int32_t>(100, amount);
                amount -= count;

                Item* item = Item::CreateItem(itemId, count);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            } while (amount);
        } else {
            for (int32_t i = 0; i < std::max<int32_t>(1, amount); i++) {
                Item* item = Item::CreateItem(itemId, data == -1 ? 0 : data);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            }
        }

        break;
    }

repaired
You see a vase of .
It weighs 9.40 oz.
ItemID: [2876].
----------after login-----------
You see a vase of rock soil.
It weighs 9.40 oz.
ItemID: [2876].

Interesting, just remove this from the action, if there is any npc missing the Data="", it will not give the error, it will just bug the name, not bad, after using the item the name will return to normal.
Nice!

C++:
if (it.charges) {
data = it.charges;
 
Fix is simple, it relies on behaviordatabase and subtype

C++:
case BEHAVIOUR_TYPE_CREATE: {
        int32_t itemId = evaluate(action->expression, player, message);
        const ItemType& it = Item::items[itemId];

        if (it.stackable) {
            do {
                int32_t count = std::min<int32_t>(100, amount);
                amount[player->getID()] -= count;

                Item* item = Item::CreateItem(itemId, count);
                if (!item) {
                    break;
                }
                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            } while (amount);
        } else {
            if (it.charges) {
                data = it.charges;
            }
            if(data < 0) {
                data = 0;
            }
            for (int32_t i = 0; i < std::max<int32_t>(1, amount); i++) {
                Item* item = Item::CreateItem(itemId, data);
                if (!item) {
                    break;
                }

                ReturnValue ret = g_game.internalPlayerAddItem(player, item);
                if (ret != RETURNVALUE_NOERROR) {
                    delete item;
                    break;
                }
            }
        }

        break;
    }
Sorry man, i was not paying attention.
when looking for a solution, to not return an invalid value and return 0 so it looks empty, if there is no date.
not to miss the name of the item, in addition to having corrected all the npcs, but even so i wanted to resolve the final question of the value.
And yours worked!
 
You need to update all the NPCs that sell fluid containers, some are missing the data value.

You can also edit in sources to default to water or something, but they should be empty

On a side note, you also need to remove regex support for house doors, you can exploit this to crash the server completely and dupe items that way as wekll
 
It seems to me that this correction in the sources solved the problem, even without touching the npcs.

about the houses, I tried to crash with the aleta sio "****.." but it didn't bug
 
Back
Top