Inventory:add - brianhang/nutscript2 GitHub Wiki

Description

... = Inventory:add(...)

This server function adds an item into the given inventory.

Parameters

Name Description
... The parameter(s) depend on the implementation.

Side Effects

  • The inventory is modified.

Returns

Name Description
... The return value(s) depend on the implementation.

Example

-- Creates a command that gives players an apple.
concommand.Add("giveapple", function(client, command, arguments)
    -- Get the player's loaded character.
    local character = client:getChar()

    -- Make sure the character exists.
    if (character) then
        character:getInv():add("apple")
    end
end)