Files
overextended.github.io/assets/js/ed6cb704.eab287c2.js
T

1 line
5.1 KiB
JavaScript

"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[3412],{9613:function(e,n,t){t.d(n,{Zo:function(){return s},kt:function(){return m}});var r=t(9496);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function u(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var c=r.createContext({}),l=function(e){var n=r.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):a(a({},n),e)),t},s=function(e){var n=l(e.components);return r.createElement(c.Provider,{value:n},e.children)},p={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},d=r.forwardRef((function(e,n){var t=e.components,o=e.mdxType,i=e.originalType,c=e.parentName,s=u(e,["components","mdxType","originalType","parentName"]),d=l(t),m=o,f=d["".concat(c,".").concat(m)]||d[m]||p[m]||i;return t?r.createElement(f,a(a({ref:n},s),{},{components:t})):r.createElement(f,a({ref:n},s))}));function m(e,n){var t=arguments,o=n&&n.mdxType;if("string"==typeof e||o){var i=t.length,a=new Array(i);a[0]=d;var u={};for(var c in n)hasOwnProperty.call(n,c)&&(u[c]=n[c]);u.originalType=e,u.mdxType="string"==typeof e?e:o,a[1]=u;for(var l=2;l<i;l++)a[l]=t[l];return r.createElement.apply(null,a)}return r.createElement.apply(null,t)}d.displayName="MDXCreateElement"},9501:function(e,n,t){t.r(n),t.d(n,{assets:function(){return s},contentTitle:function(){return c},default:function(){return m},frontMatter:function(){return u},metadata:function(){return l},toc:function(){return p}});var r=t(5443),o=t(3010),i=(t(9496),t(9613)),a=["components"],u={},c=void 0,l={unversionedId:"ox_inventory/Functions/Server/Inventory/AddItem",id:"ox_inventory/Functions/Server/Inventory/AddItem",title:"AddItem",description:"Adds an item into the specified inventory.",source:"@site/docs/ox_inventory/Functions/Server/Inventory/AddItem.md",sourceDirName:"ox_inventory/Functions/Server/Inventory",slug:"/ox_inventory/Functions/Server/Inventory/AddItem",permalink:"/docs/ox_inventory/Functions/Server/Inventory/AddItem",draft:!1,editUrl:"https://github.com/overextended/overextended.github.io/tree/main/docs/ox_inventory/Functions/Server/Inventory/AddItem.md",tags:[],version:"current",frontMatter:{},sidebar:"docs",previous:{title:"useSlot",permalink:"/docs/ox_inventory/Functions/Client/useSlot"},next:{title:"CanCarryAmount",permalink:"/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount"}},s={},p=[],d={toc:p};function m(e){var n=e.components,t=(0,o.Z)(e,a);return(0,i.kt)("wrapper",(0,r.Z)({},d,t,{components:n,mdxType:"MDXLayout"}),(0,i.kt)("p",null,"Adds an item into the specified inventory."),(0,i.kt)("p",null,"Should be used alongside ",(0,i.kt)("a",{parentName:"p",href:"/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem"},"CanCarryItem")," otherwise, the maximum weight may be exceeded."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- inv: string or number\n-- item: table or string\n-- count: number\n-- metadata: table or string (optional)\n-- slot: number (optional)\n-- cb: function (optional)\nexports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)\n")),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Example:")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},'exports.ox_inventory:AddItem(1, \'bread\', 4, nil, nil, function(success, reason)\n if success then\n print(json.encode(reason, {indent=true}))\n --[[\n {\n "metadata": [],\n "label": "Bread",\n "slot": 1,\n "stack": true,\n "close": true,\n "name": "bread",\n "count": 1,\n "weight": 150\n }\n ]]\n else\n print(success)\n -- nil\n\n print(reason)\n -- for example if all slots are taken it will give us "inventory_full"\n end\nend)\n')),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},'Possible value of the "reason" argument for the callback function:')," "),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},'"invalid_item": the item doesn\'t exist'),(0,i.kt)("li",{parentName:"ul"},'"invalid_inventory": the inventory doesn\'t exist'),(0,i.kt)("li",{parentName:"ul"},'"inventory_full": no free slots')))}m.isMDXComponent=!0}}]);