I need the function that adds item to the player

Hello I'm trying to create a script(which is currently empty) which displays the message: found item name!
:MV3:
I tried finding the function which is called when player receives an item but no luck ;_;;_;😢

Can someone tell me how to do it?
Thanks in advance!!!!!!!!!! 😂
search the forum - there is a pinned topic listing all script equivalents of all event commands, that is where you'll find it.
It's in rpg_objects.js, starting with the Game_Interpreter at line 9597:
Code:
// Change Items
Game_Interpreter.prototype.command126 = function() {
    var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
    $gameParty.gainItem($dataItems[this._params[0]], value);
    return true;
};

You now know what code the event calls.
The function is defined at line 4991:
Code:
Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
    var container = this.itemContainer(item);
    if (container) {
        var lastNumber = this.numItems(item);
        var newNumber = lastNumber + amount;
        container[item.id] = newNumber.clamp(0, this.maxItems(item));
        if (container[item.id] === 0) {
            delete container[item.id];
        }
        if (includeEquip && newNumber < 0) {
            this.discardMembersEquip(item, -newNumber);
        }
        $gameMap.requestRefresh();
    }
};
Thanks!
:MV1:
Nice but can someone tell me how can I know the item id of the item added???
Actually, I put together a system that sets the variable of an item, then call the variable of the item and then goes to a common event that displays the value of the Item. Quite useful.
Nice but can someone tell me how can I know the item id of the item added???
you are the one who decides what item the player should get, so you set the ID of the item to be added and include that in the function call
Nice but can someone tell me how can I know the item id of the item added???
It's easier to help if we know what you're doing and what you're trying to do. For example, show us the code you're currently using and tell us what part isn't working.

Right now, I'm assuming you're writing a plugin that overrides Game_Party.prototype.gainItem(item, amount, includeEquip) and want to know the Id of the item that's been added.
In that case, simply use item.id

Original thread: https://forums.rpgmakerweb.com/threads/i-need-the-function-that-adds-item-to-the-player.97109/