From 0788eaacd72229ac85eab7158f00732840290fda Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 7 May 2022 20:52:29 +0000 Subject: [PATCH] deploy: fbb38c9873ae0bf54f600229a11bbd9619ff0720 --- 404.html | 4 ++-- assets/js/{d65f8ccc.6b822db2.js => d65f8ccc.b0e6c86c.js} | 2 +- .../{runtime~main.b04fbf8e.js => runtime~main.77f2a199.js} | 2 +- blog/archive/index.html | 4 ++-- docs/index.html | 4 ++-- .../Functions/Client/Inventory/Search/index.html | 4 ++-- docs/ox_inventory/Functions/Client/Items/index.html | 4 ++-- .../Functions/Client/Utils/weaponWheel/index.html | 4 ++-- .../Functions/Client/displayMetadata/index.html | 4 ++-- docs/ox_inventory/Functions/Client/openInventory/index.html | 4 ++-- .../Functions/Client/openNearbyInventory/index.html | 4 ++-- .../ox_inventory/Functions/Client/setStashTarget/index.html | 4 ++-- docs/ox_inventory/Functions/Client/useItem/index.html | 4 ++-- docs/ox_inventory/Functions/Client/useSlot/index.html | 4 ++-- .../Functions/Server/Inventory/AddItem/index.html | 4 ++-- .../Functions/Server/Inventory/CanCarryAmount/index.html | 4 ++-- .../Functions/Server/Inventory/CanCarryItem/index.html | 4 ++-- .../Functions/Server/Inventory/CanSwapItem/index.html | 4 ++-- .../Functions/Server/Inventory/ClearInventory/index.html | 4 ++-- .../Server/Inventory/ConfiscateInventory/index.html | 4 ++-- .../Functions/Server/Inventory/ConvertItems/index.html | 4 ++-- .../Functions/Server/Inventory/CustomDrop/index.html | 4 ++-- .../Functions/Server/Inventory/GetCurrentWeapon/index.html | 4 ++-- .../Functions/Server/Inventory/GetItem/index.html | 4 ++-- .../Functions/Server/Inventory/GetItemSlots/index.html | 4 ++-- .../Functions/Server/Inventory/GetSlot/index.html | 4 ++-- .../Functions/Server/Inventory/RegisterStash/index.html | 4 ++-- .../Functions/Server/Inventory/RemoveItem/index.html | 4 ++-- .../Functions/Server/Inventory/ReturnInventory/index.html | 4 ++-- .../Functions/Server/Inventory/Search/index.html | 4 ++-- .../Functions/Server/Inventory/SetDurability/index.html | 4 ++-- .../Functions/Server/Inventory/SetMetadata/index.html | 4 ++-- .../Functions/Server/Inventory/SwapSlots/index.html | 4 ++-- docs/ox_inventory/Functions/Server/Items/index.html | 4 ++-- .../Functions/Server/setPlayerInventory/index.html | 4 ++-- docs/ox_inventory/Guides/creatingItems/index.html | 6 +++--- docs/ox_inventory/Guides/customDrop/index.html | 4 ++-- docs/ox_inventory/Guides/index.html | 4 ++-- docs/ox_inventory/Guides/inventory_ui/index.html | 4 ++-- docs/ox_inventory/Guides/stashes/index.html | 4 ++-- docs/ox_inventory/config/index.html | 4 ++-- docs/ox_inventory/index.html | 4 ++-- docs/ox_lib/Client/Interface/context/index.html | 4 ++-- docs/ox_lib/Client/Interface/input/index.html | 4 ++-- docs/ox_lib/Client/Interface/notify/index.html | 4 ++-- docs/ox_lib/Client/Interface/progress/index.html | 4 ++-- docs/ox_lib/Client/Interface/textui/index.html | 4 ++-- docs/ox_lib/Client/cache/index.html | 4 ++-- docs/ox_lib/Client/callback/index.html | 4 ++-- docs/ox_lib/Client/disableControls/index.html | 4 ++-- docs/ox_lib/Client/misc/index.html | 4 ++-- docs/ox_lib/Client/points/index.html | 4 ++-- docs/ox_lib/Client/streaming/index.html | 4 ++-- docs/ox_lib/Client/vehicleProperties/index.html | 4 ++-- docs/ox_lib/Server/acl/index.html | 4 ++-- docs/ox_lib/Server/addCommand/index.html | 4 ++-- docs/ox_lib/Server/callback/index.html | 4 ++-- docs/ox_lib/Server/logger/index.html | 4 ++-- docs/ox_lib/Server/version/index.html | 4 ++-- docs/ox_lib/Shared/locale/index.html | 4 ++-- docs/ox_lib/Shared/version/index.html | 4 ++-- docs/ox_lib/index.html | 4 ++-- docs/oxmysql/Getting Started/benchmark/index.html | 4 ++-- docs/oxmysql/Getting Started/issues/index.html | 4 ++-- docs/oxmysql/Getting Started/placeholders/index.html | 4 ++-- docs/oxmysql/Usage/index.html | 4 ++-- docs/oxmysql/Usage/insert/index.html | 4 ++-- docs/oxmysql/Usage/prepare/index.html | 4 ++-- docs/oxmysql/Usage/query/index.html | 4 ++-- docs/oxmysql/Usage/scalar/index.html | 4 ++-- docs/oxmysql/Usage/single/index.html | 4 ++-- docs/oxmysql/Usage/transaction/index.html | 4 ++-- docs/oxmysql/Usage/update/index.html | 4 ++-- docs/oxmysql/index.html | 4 ++-- index.html | 4 ++-- markdown-page/index.html | 4 ++-- 76 files changed, 151 insertions(+), 151 deletions(-) rename assets/js/{d65f8ccc.6b822db2.js => d65f8ccc.b0e6c86c.js} (79%) rename assets/js/{runtime~main.b04fbf8e.js => runtime~main.77f2a199.js} (99%) diff --git a/404.html b/404.html index b4c74092..48cdf66a 100644 --- a/404.html +++ b/404.html @@ -5,13 +5,13 @@ Page Not Found | Overextended - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/d65f8ccc.6b822db2.js b/assets/js/d65f8ccc.b0e6c86c.js similarity index 79% rename from assets/js/d65f8ccc.6b822db2.js rename to assets/js/d65f8ccc.b0e6c86c.js index 04505a20..7f0205fa 100644 --- a/assets/js/d65f8ccc.6b822db2.js +++ b/assets/js/d65f8ccc.b0e6c86c.js @@ -1 +1 @@ -"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[992],{3905:function(e,t,n){n.d(t,{Zo:function(){return c},kt:function(){return d}});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var u=a.createContext({}),s=function(e){var t=a.useContext(u),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return a.createElement(u.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},p=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,u=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),p=s(n),d=r,b=p["".concat(u,".").concat(d)]||p[d]||m[d]||i;return n?a.createElement(b,o(o({ref:t},c),{},{components:n})):a.createElement(b,o({ref:t},c))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=p;var l={};for(var u in t)hasOwnProperty.call(t,u)&&(l[u]=t[u]);l.originalType=e,l.mdxType="string"==typeof e?e:r,o[1]=l;for(var s=2;s child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the component should be , and every should have a unique "value" prop.')})),f=null!=p?p:g.map((function(e){var t=e.props;return{value:t.value,label:t.label,attributes:t.attributes}})),h=(0,o.lx)(f,(function(e,t){return e.value===t.value}));if(h.length>0)throw new Error('Docusaurus error: Duplicate values "'+h.map((function(e){return e.value})).join(", ")+'" found in . Every value needs to be unique.');var v=null===m?m:null!=(t=null!=m?m:null==(n=g.find((function(e){return e.props.default})))?void 0:n.props.value)?t:null==(i=g[0])?void 0:i.props.value;if(null!==v&&!f.some((function(e){return e.value===v})))throw new Error('Docusaurus error: The has a defaultValue "'+v+'" but none of its children has the corresponding value. Available values are: '+f.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");var y=(0,o.UB)(),k=y.tabGroupChoices,x=y.setTabGroupChoices,w=(0,r.useState)(v),N=w[0],_=w[1],T=[],E=(0,o.o5)().blockElementScrollPositionUntilNextRender;if(null!=d){var I=k[d];null!=I&&I!==N&&f.some((function(e){return e.value===I}))&&_(I)}var O=function(e){var t=e.currentTarget,n=T.indexOf(t),a=f[n].value;a!==N&&(E(t),_(a),null!=d&&x(d,a))},C=function(e){var t,n=null;switch(e.key){case"ArrowRight":var a=T.indexOf(e.currentTarget)+1;n=T[a]||T[0];break;case"ArrowLeft":var r=T.indexOf(e.currentTarget)-1;n=T[r]||T[T.length-1]}null==(t=n)||t.focus()};return r.createElement("div",{className:"tabs-container"},r.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,l.Z)("tabs",{"tabs--block":c},b)},f.map((function(e){var t=e.value,n=e.label,i=e.attributes;return r.createElement("li",(0,a.Z)({role:"tab",tabIndex:N===t?0:-1,"aria-selected":N===t,key:t,ref:function(e){return T.push(e)},onKeyDown:C,onFocus:O,onClick:O},i,{className:(0,l.Z)("tabs__item",u,null==i?void 0:i.className,{"tabs__item--active":N===t})}),null!=n?n:t)}))),s?(0,r.cloneElement)(g.filter((function(e){return e.props.value===N}))[0],{className:"margin-vert--md"}):r.createElement("div",{className:"margin-vert--md"},g.map((function(e,t){return(0,r.cloneElement)(e,{key:t,hidden:e.props.value!==N})}))))}function c(e){var t=(0,i.Z)();return r.createElement(s,(0,a.Z)({key:String(t)},e))}},4715:function(e,t,n){n.r(t),n.d(t,{frontMatter:function(){return s},contentTitle:function(){return c},metadata:function(){return m},assets:function(){return p},toc:function(){return d},default:function(){return g}});var a=n(7462),r=n(3366),i=(n(7294),n(3905)),o=n(9877),l=n(8215),u=["components"],s={title:"Creating items"},c=void 0,m={unversionedId:"ox_inventory/Guides/creatingItems",id:"ox_inventory/Guides/creatingItems",title:"Creating items",description:"Defining item data",source:"@site/docs/ox_inventory/Guides/creatingItems.md",sourceDirName:"ox_inventory/Guides",slug:"/ox_inventory/Guides/creatingItems",permalink:"/docs/ox_inventory/Guides/creatingItems",editUrl:"https://github.com/overextended/overextended.github.io/tree/main/docs/ox_inventory/Guides/creatingItems.md",tags:[],version:"current",frontMatter:{title:"Creating items"},sidebar:"docs",previous:{title:"Overview",permalink:"/docs/ox_inventory/Guides/"},next:{title:"Creating custom drops",permalink:"/docs/ox_inventory/Guides/customDrop"}},p={},d=[{value:"Defining item data",id:"defining-item-data",level:2},{value:"Making the item usable",id:"making-the-item-usable",level:2},{value:"Item events",id:"item-events",level:2},{value:"Creating container items",id:"creating-container-items",level:2}],b={toc:d};function g(e){var t=e.components,n=(0,r.Z)(e,u);return(0,i.kt)("wrapper",(0,a.Z)({},b,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h2",{id:"defining-item-data"},"Defining item data"),(0,i.kt)("p",null,"Before being able to see or use an item in game it ",(0,i.kt)("strong",{parentName:"p"},"must")," first be defined."),(0,i.kt)("p",null,"All of the items are defined in the ",(0,i.kt)("inlineCode",{parentName:"p"},"/data/items.lua")," file with key, value pairs.",(0,i.kt)("br",{parentName:"p"}),"\n","Key is the name (not the label) of an item and the value is a table containing the\noptions for the item."),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Item options:")),(0,i.kt)(o.Z,{mdxType:"Tabs"},(0,i.kt)(l.Z,{value:"shared",label:"Shared",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- label: string\n-- weight: number (optional)\n-- stack: boolean (optional) -- If set to false will not allow the item to be stacked\n-- degrade: number (optional) -- The amount of time in minutes an item will degrade after\n-- close: boolean (optional) -- If set to false will not close the inventory on item use\n-- description: string (optional)\n-- consume: number (optional) -- Number of an item needed to use it, and removed after use (Default: 1)\n-- allowArmed: boolean (optional) -- If set to true will allow use of item while armed with a weapon\n-- client: table (optional)\n-- buttons: table (optional) -- Allows you to define custom context menu functions for the item\n"))),(0,i.kt)(l.Z,{value:"client",label:"Client",mdxType:"TabItem"},(0,i.kt)("p",null,"All values are optional."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- event: string -- Event to trigger after item use\n-- status: table -- Adjust esx_status values after use\n-- anim: table -- Animation during progress bar\n -- dict: string\n -- clip: string\n-- prop: table -- Attached prop during progress bar\n -- model: string or hash\n -- pos: table (x, y, z)\n -- rot: table (x, y, z)\n-- disable: boolean -- Disables actions during progress bar\n-- usetime: number\n-- cancel: boolean -- If set to true the player can cancel item use\n-- add: function(total) -- Function that triggers when recieving an item (Returns total item count as `total`)\n-- remove: function(total) -- Function that triggers when removing an item (Returns total item count as `total`)\n"))),(0,i.kt)(l.Z,{value:"buttons",label:"Buttons",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- label: string,\n-- action: function(slot) -- Callback function when button is clicked in context menu, returns item slot\n")))),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Examples:")),(0,i.kt)(o.Z,{mdxType:"Tabs"},(0,i.kt)(l.Z,{value:"burger",label:"Burger",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n weight = 220,\n stack = true,\n close = true,\n client = {\n status = { hunger = 200000 },\n anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },\n prop = { \n model = 'prop_cs_burger_01',\n pos = { x = 0.02, y = 0.02, y = -0.02},\n rot = { x = 0.0, y = 0.0, y = 0.0}\n },\n usetime = 2500,\n }\n}\n"))),(0,i.kt)(l.Z,{value:"custom_burger",label:"Custom burger",mdxType:"TabItem"},(0,i.kt)("p",null,"A modified burger item, with a description and custom crafting table."),(0,i.kt)("p",null,"Combined with several new functions and events you could easily create your own crafting system."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n description = 'Just what is the secret formula?'\n weight = 220,\n stack = true,\n close = true,\n client = {\n status = { hunger = 200000 },\n anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },\n prop = {\n model = 'prop_cs_burger_01', \n pos = { x = 0.02, y = 0.02, y = -0.02}, \n rot = { x = 0.0, y = 0.0, y = 0.0}\n },\n usetime = 2500,\n }\n crafting = {\n ['bun'] = 2,\n ['ketchup'] = 1,\n ['mustard'] = 1,\n ['cheese'] = 1,\n ['pickles'] = 1,\n ['lettuce'] = 1,\n ['tomato'] = 1,\n ['onion'] = 1, \n }\n}\n"))),(0,i.kt)(l.Z,{value:"notify_burger",label:"Notify burger",mdxType:"TabItem"},(0,i.kt)("p",null,"A modified burger item, which gives you notifications on add and remove arguments."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n weight = 220,\n stack = true,\n consume = 0,\n client = {\n add = function(total)\n if total > 0 then\n exports.ox_inventory:notify({text = 'Nice burger you got there!'})\n end\n end,\n\n remove = function(total)\n if total < 1 then\n exports.ox_inventory:notify({text = 'You lost all of your burgers!'})\n end\n end\n }\n}\n")))),(0,i.kt)("h2",{id:"making-the-item-usable"},"Making the item usable"),(0,i.kt)("p",null,"If you are using ESX you can continue using ",(0,i.kt)("inlineCode",{parentName:"p"},"ESX.RegisterUsableItem")," if desired.",(0,i.kt)("br",{parentName:"p"}),"\n","Using the built-in system is more secure and provides simple progressbar support. "),(0,i.kt)("p",null,"An item will be usable when client variables are added to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/data/items.lua"},"data/items.lua"),", or has a registered item callback. Item callbacks can be added by defining an export (recommended), or by adding it to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/modules/items/client.lua#L33"},"items/client.lua"),". "),(0,i.kt)("p",null,"When defining ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/data/items.lua"},"item data"),", adding client.export will trigger an event on item use.",(0,i.kt)("br",{parentName:"p"}),"\n","The correct formatting is ",(0,i.kt)("inlineCode",{parentName:"p"},"export = resourceName.exportName"),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"exports('bandage', function(data, slot)\n local playerPed = PlayerPedId()\n local maxHealth = GetEntityMaxHealth(playerPed)\n local health = GetEntityHealth(playerPed)\n\n -- Does the ped need to heal?\n if health < maxHealth then\n -- Use the bandage\n exports.ox_inventory:useItem(data, function(data)\n -- The item has been used, so trigger the effects\n if data then\n SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))\n exports.ox_inventory:notify({text = 'You feel better already'})\n end\n end)\n else\n -- Don't use the item\n exports.ox_inventory:notify({type = 'error', text = 'You don\\'t need a bandage right now'})\n end\nend)\n")),(0,i.kt)("h2",{id:"item-events"},"Item events"),(0,i.kt)("p",null,"Similarly to the client, a callback function can be defined on the server to handle several events (usingItem, usedItem, buyItem).",(0,i.kt)("br",{parentName:"p"}),"\n","This can either be an export (recommended), or added to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/modules/items/server.lua#L287"},"items/server.lua"),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"exports('bandage', function(event, item, inventory, slot, data)\n if event == 'usingItem' then\n local playerPed = GetPlayerPed(inventory.source)\n local maxHealth = GetEntityMaxHealth(playerPed)\n local health = GetEntityHealth(playerPed)\n\n if health >= maxHealth then\n TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\\'t need a bandage right now'})\n\n -- Returning 'false' will prevent the item from being used\n return false\n end\n\n return\n elseif event == 'usedItem' then\n return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'})\n\n elseif event == 'buying' then\n return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'})\n end\nend)\n")),(0,i.kt)("h2",{id:"creating-container-items"},"Creating container items"),(0,i.kt)("p",null,"Like with other items the item must first be registered. "),(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"},"['paperbag'] = {\n label = 'Paper Bag',\n weight = 1,\n stack = false,\n close = false,\n consume = 0\n},\n")),(0,i.kt)("p",null,"When registered you can define the item as a container under the ",(0,i.kt)("inlineCode",{parentName:"p"},"Items.containers")," table in ",(0,i.kt)("inlineCode",{parentName:"p"},"/modules/items/sever.lua"),(0,i.kt)("br",{parentName:"p"}),"\n","The key for the container is the ",(0,i.kt)("inlineCode",{parentName:"p"},"name")," you gave it when registering the item.",(0,i.kt)("br",{parentName:"p"}),"\n","You can also define the number of slots, the maximum weight, blacklist and whitelist items."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['name'] = {\n -- size: {slots, maxWeight}\n -- slots: number\n -- maxWeight: number\n -- blacklist: table (optional)\n -- ['itemName'] = true\n -- whitelist: table (optional)\n -- ['itemName'] = true\n}\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"},"['paperbag'] = {\n size = {5, 1000},\n blacklist = {\n ['testburger'] = true -- No burgers!\n }\n},\n")))}g.isMDXComponent=!0}}]); \ No newline at end of file +"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[992],{3905:function(e,t,n){n.d(t,{Zo:function(){return m},kt:function(){return d}});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var u=a.createContext({}),s=function(e){var t=a.useContext(u),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},m=function(e){var t=s(e.components);return a.createElement(u.Provider,{value:t},e.children)},c={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},p=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,u=e.parentName,m=l(e,["components","mdxType","originalType","parentName"]),p=s(n),d=r,b=p["".concat(u,".").concat(d)]||p[d]||c[d]||i;return n?a.createElement(b,o(o({ref:t},m),{},{components:n})):a.createElement(b,o({ref:t},m))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=p;var l={};for(var u in t)hasOwnProperty.call(t,u)&&(l[u]=t[u]);l.originalType=e,l.mdxType="string"==typeof e?e:r,o[1]=l;for(var s=2;s child <"+("string"==typeof e.type?e.type:e.type.name)+'>: all children of the component should be , and every should have a unique "value" prop.')})),f=null!=p?p:g.map((function(e){var t=e.props;return{value:t.value,label:t.label,attributes:t.attributes}})),h=(0,o.lx)(f,(function(e,t){return e.value===t.value}));if(h.length>0)throw new Error('Docusaurus error: Duplicate values "'+h.map((function(e){return e.value})).join(", ")+'" found in . Every value needs to be unique.');var v=null===c?c:null!=(t=null!=c?c:null==(n=g.find((function(e){return e.props.default})))?void 0:n.props.value)?t:null==(i=g[0])?void 0:i.props.value;if(null!==v&&!f.some((function(e){return e.value===v})))throw new Error('Docusaurus error: The has a defaultValue "'+v+'" but none of its children has the corresponding value. Available values are: '+f.map((function(e){return e.value})).join(", ")+". If you intend to show no default tab, use defaultValue={null} instead.");var y=(0,o.UB)(),k=y.tabGroupChoices,x=y.setTabGroupChoices,w=(0,r.useState)(v),N=w[0],_=w[1],T=[],E=(0,o.o5)().blockElementScrollPositionUntilNextRender;if(null!=d){var I=k[d];null!=I&&I!==N&&f.some((function(e){return e.value===I}))&&_(I)}var O=function(e){var t=e.currentTarget,n=T.indexOf(t),a=f[n].value;a!==N&&(E(t),_(a),null!=d&&x(d,a))},C=function(e){var t,n=null;switch(e.key){case"ArrowRight":var a=T.indexOf(e.currentTarget)+1;n=T[a]||T[0];break;case"ArrowLeft":var r=T.indexOf(e.currentTarget)-1;n=T[r]||T[T.length-1]}null==(t=n)||t.focus()};return r.createElement("div",{className:"tabs-container"},r.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,l.Z)("tabs",{"tabs--block":m},b)},f.map((function(e){var t=e.value,n=e.label,i=e.attributes;return r.createElement("li",(0,a.Z)({role:"tab",tabIndex:N===t?0:-1,"aria-selected":N===t,key:t,ref:function(e){return T.push(e)},onKeyDown:C,onFocus:O,onClick:O},i,{className:(0,l.Z)("tabs__item",u,null==i?void 0:i.className,{"tabs__item--active":N===t})}),null!=n?n:t)}))),s?(0,r.cloneElement)(g.filter((function(e){return e.props.value===N}))[0],{className:"margin-vert--md"}):r.createElement("div",{className:"margin-vert--md"},g.map((function(e,t){return(0,r.cloneElement)(e,{key:t,hidden:e.props.value!==N})}))))}function m(e){var t=(0,i.Z)();return r.createElement(s,(0,a.Z)({key:String(t)},e))}},4715:function(e,t,n){n.r(t),n.d(t,{frontMatter:function(){return s},contentTitle:function(){return m},metadata:function(){return c},assets:function(){return p},toc:function(){return d},default:function(){return g}});var a=n(7462),r=n(3366),i=(n(7294),n(3905)),o=n(9877),l=n(8215),u=["components"],s={title:"Creating items"},m=void 0,c={unversionedId:"ox_inventory/Guides/creatingItems",id:"ox_inventory/Guides/creatingItems",title:"Creating items",description:"Defining item data",source:"@site/docs/ox_inventory/Guides/creatingItems.md",sourceDirName:"ox_inventory/Guides",slug:"/ox_inventory/Guides/creatingItems",permalink:"/docs/ox_inventory/Guides/creatingItems",editUrl:"https://github.com/overextended/overextended.github.io/tree/main/docs/ox_inventory/Guides/creatingItems.md",tags:[],version:"current",frontMatter:{title:"Creating items"},sidebar:"docs",previous:{title:"Overview",permalink:"/docs/ox_inventory/Guides/"},next:{title:"Creating custom drops",permalink:"/docs/ox_inventory/Guides/customDrop"}},p={},d=[{value:"Defining item data",id:"defining-item-data",level:2},{value:"Making the item usable",id:"making-the-item-usable",level:2},{value:"Item events",id:"item-events",level:2},{value:"Creating container items",id:"creating-container-items",level:2}],b={toc:d};function g(e){var t=e.components,n=(0,r.Z)(e,u);return(0,i.kt)("wrapper",(0,a.Z)({},b,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h2",{id:"defining-item-data"},"Defining item data"),(0,i.kt)("p",null,"Before being able to see or use an item in game it ",(0,i.kt)("strong",{parentName:"p"},"must")," first be defined."),(0,i.kt)("p",null,"All of the items are defined in the ",(0,i.kt)("inlineCode",{parentName:"p"},"/data/items.lua")," file with key, value pairs.",(0,i.kt)("br",{parentName:"p"}),"\n","Key is the name (not the label) of an item and the value is a table containing the\noptions for the item."),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Item options:")),(0,i.kt)(o.Z,{mdxType:"Tabs"},(0,i.kt)(l.Z,{value:"shared",label:"Shared",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- label: string\n-- weight: number (optional)\n-- stack: boolean (optional) -- If set to false will not allow the item to be stacked\n-- degrade: number (optional) -- The amount of time in minutes an item will degrade after\n-- close: boolean (optional) -- If set to false will not close the inventory on item use\n-- description: string (optional)\n-- consume: number (optional) -- Number of an item needed to use it, and removed after use (Default: 1)\n-- allowArmed: boolean (optional) -- If set to true will allow use of item while armed with a weapon\n-- client: table (optional)\n-- buttons: table (optional) -- Allows you to define custom context menu functions for the item\n"))),(0,i.kt)(l.Z,{value:"client",label:"Client",mdxType:"TabItem"},(0,i.kt)("p",null,"All values are optional."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- event: string -- Event to trigger after item use\n-- status: table -- Adjust esx_status values after use\n-- anim: table -- Animation during progress bar\n -- dict: string\n -- clip: string\n-- prop: table -- Attached prop during progress bar\n -- model: string or hash\n -- pos: table (x, y, z)\n -- rot: table (x, y, z)\n-- disable: boolean -- Disables actions during progress bar\n-- usetime: number\n-- cancel: boolean -- If set to true the player can cancel item use\n-- add: function(total) -- Function that triggers when recieving an item (Returns total item count as `total`)\n-- remove: function(total) -- Function that triggers when removing an item (Returns total item count as `total`)\n"))),(0,i.kt)(l.Z,{value:"buttons",label:"Buttons",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"-- label: string,\n-- action: function(slot) -- Callback function when button is clicked in context menu, returns item slot\n")))),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Examples:")),(0,i.kt)(o.Z,{mdxType:"Tabs"},(0,i.kt)(l.Z,{value:"burger",label:"Burger",mdxType:"TabItem"},(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n weight = 220,\n stack = true,\n close = true,\n client = {\n status = { hunger = 200000 },\n anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },\n prop = { \n model = 'prop_cs_burger_01',\n pos = { x = 0.02, y = 0.02, y = -0.02},\n rot = { x = 0.0, y = 0.0, y = 0.0}\n },\n usetime = 2500,\n }\n}\n"))),(0,i.kt)(l.Z,{value:"custom_burger",label:"Custom burger",mdxType:"TabItem"},(0,i.kt)("p",null,"A modified burger item, with a description and custom crafting table."),(0,i.kt)("p",null,"Combined with several new functions and events you could easily create your own crafting system."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n description = 'Just what is the secret formula?'\n weight = 220,\n stack = true,\n close = true,\n client = {\n status = { hunger = 200000 },\n anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },\n prop = {\n model = 'prop_cs_burger_01', \n pos = { x = 0.02, y = 0.02, y = -0.02}, \n rot = { x = 0.0, y = 0.0, y = 0.0}\n },\n usetime = 2500,\n }\n crafting = {\n ['bun'] = 2,\n ['ketchup'] = 1,\n ['mustard'] = 1,\n ['cheese'] = 1,\n ['pickles'] = 1,\n ['lettuce'] = 1,\n ['tomato'] = 1,\n ['onion'] = 1, \n }\n}\n"))),(0,i.kt)(l.Z,{value:"notify_burger",label:"Notify burger",mdxType:"TabItem"},(0,i.kt)("p",null,"A modified burger item, which gives you notifications on add and remove arguments."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['burger'] = {\n label = 'Burger',\n weight = 220,\n stack = true,\n consume = 0,\n client = {\n add = function(total)\n if total > 0 then\n exports.ox_inventory:notify({text = 'Nice burger you got there!'})\n end\n end,\n\n remove = function(total)\n if total < 1 then\n exports.ox_inventory:notify({text = 'You lost all of your burgers!'})\n end\n end\n }\n}\n")))),(0,i.kt)("h2",{id:"making-the-item-usable"},"Making the item usable"),(0,i.kt)("p",null,"If you are using ESX you can continue using ",(0,i.kt)("inlineCode",{parentName:"p"},"ESX.RegisterUsableItem")," if desired.",(0,i.kt)("br",{parentName:"p"}),"\n","Using the built-in system is more secure and provides simple progressbar support. "),(0,i.kt)("p",null,"An item will be usable when client variables are added to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/data/items.lua"},"data/items.lua"),", or has a registered item callback. Item callbacks can be added by defining an export (recommended), or by adding it to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/modules/items/client.lua#L33"},"items/client.lua"),". "),(0,i.kt)("p",null,"When defining ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/data/items.lua"},"item data"),", adding client.export will trigger an event on item use.",(0,i.kt)("br",{parentName:"p"}),"\n","The correct formatting is ",(0,i.kt)("inlineCode",{parentName:"p"},"export = resourceName.exportName"),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"exports('bandage', function(data, slot)\n local playerPed = PlayerPedId()\n local maxHealth = GetEntityMaxHealth(playerPed)\n local health = GetEntityHealth(playerPed)\n\n -- Does the ped need to heal?\n if health < maxHealth then\n -- Use the bandage\n exports.ox_inventory:useItem(data, function(data)\n -- The item has been used, so trigger the effects\n if data then\n SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))\n exports.ox_inventory:notify({text = 'You feel better already'})\n end\n end)\n else\n -- Don't use the item\n exports.ox_inventory:notify({type = 'error', text = 'You don\\'t need a bandage right now'})\n end\nend)\n")),(0,i.kt)("h2",{id:"item-events"},"Item events"),(0,i.kt)("p",null,"Similarly to the client, a callback function can be defined on the server to handle several events (usingItem, usedItem, buyItem).",(0,i.kt)("br",{parentName:"p"}),"\n","This can either be an export (recommended), or added to ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/overextended/ox_inventory/blob/main/modules/items/server.lua#L287"},"items/server.lua"),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"exports('bandage', function(event, item, inventory, slot, data)\n if event == 'usingItem' then\n local playerPed = GetPlayerPed(inventory.id)\n local maxHealth = GetEntityMaxHealth(playerPed)\n local health = GetEntityHealth(playerPed)\n\n if health >= maxHealth then\n TriggerClientEvent('ox_inventory:notify', inventory.id, {type = 'error', text = 'You don\\'t need a bandage right now'})\n\n -- Returning 'false' will prevent the item from being used\n return false\n end\n\n return\n elseif event == 'usedItem' then\n return TriggerClientEvent('ox_inventory:notify', inventory.id, {text = 'You feel better already'})\n\n elseif event == 'buying' then\n return TriggerClientEvent('ox_inventory:notify', inventory.id, {type = 'success', text = 'You bought a bandage'})\n end\nend)\n")),(0,i.kt)("h2",{id:"creating-container-items"},"Creating container items"),(0,i.kt)("p",null,"Like with other items the item must first be registered. "),(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"},"['paperbag'] = {\n label = 'Paper Bag',\n weight = 1,\n stack = false,\n close = false,\n consume = 0\n},\n")),(0,i.kt)("p",null,"When registered you can define the item as a container under the ",(0,i.kt)("inlineCode",{parentName:"p"},"Items.containers")," table in ",(0,i.kt)("inlineCode",{parentName:"p"},"/modules/items/sever.lua"),(0,i.kt)("br",{parentName:"p"}),"\n","The key for the container is the ",(0,i.kt)("inlineCode",{parentName:"p"},"name")," you gave it when registering the item.",(0,i.kt)("br",{parentName:"p"}),"\n","You can also define the number of slots, the maximum weight, blacklist and whitelist items."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-lua"},"['name'] = {\n -- size: {slots, maxWeight}\n -- slots: number\n -- maxWeight: number\n -- blacklist: table (optional)\n -- ['itemName'] = true\n -- whitelist: table (optional)\n -- ['itemName'] = true\n}\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"},"['paperbag'] = {\n size = {5, 1000},\n blacklist = {\n ['testburger'] = true -- No burgers!\n }\n},\n")))}g.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.b04fbf8e.js b/assets/js/runtime~main.77f2a199.js similarity index 99% rename from assets/js/runtime~main.b04fbf8e.js rename to assets/js/runtime~main.77f2a199.js index 0a767e9c..f658a8b1 100644 --- a/assets/js/runtime~main.b04fbf8e.js +++ b/assets/js/runtime~main.77f2a199.js @@ -1 +1 @@ -!function(){"use strict";var e,a,f,c,t,d={},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var f=n[e]={exports:{}};return d[e].call(f.exports,f,f.exports,r),f.exports}r.m=d,e=[],r.O=function(a,f,c,t){if(!f){var d=1/0;for(u=0;u=t)&&Object.keys(r.O).every((function(e){return r.O[e](f[b])}))?f.splice(b--,1):(n=!1,t0&&e[u-1][2]>t;u--)e[u]=e[u-1];e[u]=[f,c,t]},r.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(a,{a:a}),a},f=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},r.t=function(e,c){if(1&c&&(e=this(e)),8&c)return e;if("object"==typeof e&&e){if(4&c&&e.__esModule)return e;if(16&c&&"function"==typeof e.then)return e}var t=Object.create(null);r.r(t);var d={};a=a||[null,f({}),f([]),f(f)];for(var n=2&c&&e;"object"==typeof n&&!~a.indexOf(n);n=f(n))Object.getOwnPropertyNames(n).forEach((function(a){d[a]=function(){return e[a]}}));return d.default=function(){return e},r.d(t,d),t},r.d=function(e,a){for(var f in a)r.o(a,f)&&!r.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:a[f]})},r.f={},r.e=function(e){return Promise.all(Object.keys(r.f).reduce((function(a,f){return r.f[f](e,a),a}),[]))},r.u=function(e){return"assets/js/"+({53:"935f2afb",219:"461f728c",336:"e836e7f0",361:"7d2d738e",763:"8c52c42d",992:"d65f8ccc",1339:"5d76cae1",1358:"afe7e8e5",1477:"b2f554cd",1521:"0f06fd08",1623:"0a2b764e",1800:"cfe61e10",1884:"c8b7a7b8",2017:"081aa3d8",2031:"dadefd20",2115:"99ade4d8",2202:"34a267b8",2446:"831ab327",2597:"384e58e1",3085:"1f391b9e",3120:"2c127759",3128:"2ff920a5",3149:"9a9bc35c",3218:"01e0aabd",3237:"1df93b7f",3287:"5fabe7ef",3412:"ed6cb704",3515:"3e27f708",3537:"ec013d60",3608:"9e4087bc",3656:"1efa5838",3792:"fb92962e",4270:"3a94ab6a",4434:"c2e48a87",4467:"a301658a",4571:"ddb2ec41",4677:"fe5eec09",4772:"871b43d2",4960:"a0cc59ae",5102:"bd024966",5199:"3517af41",5990:"c864612b",6090:"436dd28b",6169:"03b72f95",6193:"d4a6286b",6508:"7bd87f6f",6533:"0419c24a",6635:"b3a43e68",6661:"8c5ee32e",6901:"ecb88550",6971:"c377a04b",6995:"56163916",7008:"fd4717da",7150:"a484ef80",7309:"f402e59b",7330:"011f4266",7414:"393be207",7438:"036a6f83",7653:"27ba855c",7835:"23a5733a",7918:"17896441",8087:"24c8c7e5",8431:"2e6924e9",8458:"ad8eebed",8552:"c038339d",8592:"3e61bb29",9008:"ea722c4f",9081:"475acb0d",9155:"d6b25613",9278:"75f8f779",9414:"5d7eb90d",9491:"adbed512",9514:"1be78505",9586:"85ef8f6b",9730:"daa8642d",9791:"1d131567",9874:"e381a92a",9945:"e36123ca"}[e]||e)+"."+{53:"7ef753da",138:"8c2f12a0",219:"b820160a",336:"a0b1c040",361:"c4df82e9",763:"58fbf050",992:"6b822db2",1339:"50f474bf",1358:"e548efc7",1477:"ef5c39b9",1521:"d4ebac72",1623:"a5c99de4",1800:"ac8edef7",1884:"1244de6b",2017:"80c6d4c5",2031:"c4f33690",2115:"bf7ac38c",2202:"7c4bf082",2446:"ad1adc8e",2597:"dd2f2a42",3085:"285892b7",3120:"9472d382",3128:"17103e82",3149:"a8da96bc",3218:"9a2e3610",3237:"1c5fe22a",3287:"e6dde9c7",3412:"d5a80d57",3515:"0d3a6fcb",3537:"b2c608c1",3608:"c4301948",3656:"744d862a",3792:"f659f77d",4270:"64c55818",4434:"f11c6f96",4467:"ab655b70",4571:"d45737bb",4608:"622b8e38",4677:"964da253",4772:"e785d0e5",4960:"c112455b",5102:"493b5518",5199:"529a51a0",5897:"cc508d32",5990:"ed1ec728",6090:"c3dc6977",6169:"1a2d33bf",6193:"082dce9f",6385:"4701e2d8",6508:"f641f65a",6533:"def12f56",6635:"deaba65f",6661:"432dafc1",6901:"c047338d",6971:"43108ef0",6995:"09d0d563",7008:"31a8476e",7150:"917e3313",7309:"d5492e0e",7330:"f863e9e9",7414:"7d8576b6",7438:"1389c135",7653:"7d791384",7835:"df1e6b5a",7918:"8bdb7612",8087:"17be3cba",8431:"11e8bd4a",8458:"ce183519",8552:"f996f09e",8592:"d33acda3",9008:"cc834782",9081:"deb057d8",9155:"bde68bfc",9278:"d53a26a2",9414:"b25c8892",9491:"f84c0c4b",9514:"437ca93b",9586:"b2584bc5",9730:"d00cf7a5",9791:"d6e4c2f7",9874:"0a4240c1",9945:"19621d8e"}[e]+".js"},r.miniCssF=function(e){},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},c={},t="website:",r.l=function(e,a,f,d){if(c[e])c[e].push(a);else{var n,b;if(void 0!==f)for(var o=document.getElementsByTagName("script"),u=0;u=t)&&Object.keys(r.O).every((function(e){return r.O[e](f[b])}))?f.splice(b--,1):(n=!1,t0&&e[u-1][2]>t;u--)e[u]=e[u-1];e[u]=[f,c,t]},r.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(a,{a:a}),a},f=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},r.t=function(e,c){if(1&c&&(e=this(e)),8&c)return e;if("object"==typeof e&&e){if(4&c&&e.__esModule)return e;if(16&c&&"function"==typeof e.then)return e}var t=Object.create(null);r.r(t);var d={};a=a||[null,f({}),f([]),f(f)];for(var n=2&c&&e;"object"==typeof n&&!~a.indexOf(n);n=f(n))Object.getOwnPropertyNames(n).forEach((function(a){d[a]=function(){return e[a]}}));return d.default=function(){return e},r.d(t,d),t},r.d=function(e,a){for(var f in a)r.o(a,f)&&!r.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:a[f]})},r.f={},r.e=function(e){return Promise.all(Object.keys(r.f).reduce((function(a,f){return r.f[f](e,a),a}),[]))},r.u=function(e){return"assets/js/"+({53:"935f2afb",219:"461f728c",336:"e836e7f0",361:"7d2d738e",763:"8c52c42d",992:"d65f8ccc",1339:"5d76cae1",1358:"afe7e8e5",1477:"b2f554cd",1521:"0f06fd08",1623:"0a2b764e",1800:"cfe61e10",1884:"c8b7a7b8",2017:"081aa3d8",2031:"dadefd20",2115:"99ade4d8",2202:"34a267b8",2446:"831ab327",2597:"384e58e1",3085:"1f391b9e",3120:"2c127759",3128:"2ff920a5",3149:"9a9bc35c",3218:"01e0aabd",3237:"1df93b7f",3287:"5fabe7ef",3412:"ed6cb704",3515:"3e27f708",3537:"ec013d60",3608:"9e4087bc",3656:"1efa5838",3792:"fb92962e",4270:"3a94ab6a",4434:"c2e48a87",4467:"a301658a",4571:"ddb2ec41",4677:"fe5eec09",4772:"871b43d2",4960:"a0cc59ae",5102:"bd024966",5199:"3517af41",5990:"c864612b",6090:"436dd28b",6169:"03b72f95",6193:"d4a6286b",6508:"7bd87f6f",6533:"0419c24a",6635:"b3a43e68",6661:"8c5ee32e",6901:"ecb88550",6971:"c377a04b",6995:"56163916",7008:"fd4717da",7150:"a484ef80",7309:"f402e59b",7330:"011f4266",7414:"393be207",7438:"036a6f83",7653:"27ba855c",7835:"23a5733a",7918:"17896441",8087:"24c8c7e5",8431:"2e6924e9",8458:"ad8eebed",8552:"c038339d",8592:"3e61bb29",9008:"ea722c4f",9081:"475acb0d",9155:"d6b25613",9278:"75f8f779",9414:"5d7eb90d",9491:"adbed512",9514:"1be78505",9586:"85ef8f6b",9730:"daa8642d",9791:"1d131567",9874:"e381a92a",9945:"e36123ca"}[e]||e)+"."+{53:"7ef753da",138:"8c2f12a0",219:"b820160a",336:"a0b1c040",361:"c4df82e9",763:"58fbf050",992:"b0e6c86c",1339:"50f474bf",1358:"e548efc7",1477:"ef5c39b9",1521:"d4ebac72",1623:"a5c99de4",1800:"ac8edef7",1884:"1244de6b",2017:"80c6d4c5",2031:"c4f33690",2115:"bf7ac38c",2202:"7c4bf082",2446:"ad1adc8e",2597:"dd2f2a42",3085:"285892b7",3120:"9472d382",3128:"17103e82",3149:"a8da96bc",3218:"9a2e3610",3237:"1c5fe22a",3287:"e6dde9c7",3412:"d5a80d57",3515:"0d3a6fcb",3537:"b2c608c1",3608:"c4301948",3656:"744d862a",3792:"f659f77d",4270:"64c55818",4434:"f11c6f96",4467:"ab655b70",4571:"d45737bb",4608:"622b8e38",4677:"964da253",4772:"e785d0e5",4960:"c112455b",5102:"493b5518",5199:"529a51a0",5897:"cc508d32",5990:"ed1ec728",6090:"c3dc6977",6169:"1a2d33bf",6193:"082dce9f",6385:"4701e2d8",6508:"f641f65a",6533:"def12f56",6635:"deaba65f",6661:"432dafc1",6901:"c047338d",6971:"43108ef0",6995:"09d0d563",7008:"31a8476e",7150:"917e3313",7309:"d5492e0e",7330:"f863e9e9",7414:"7d8576b6",7438:"1389c135",7653:"7d791384",7835:"df1e6b5a",7918:"8bdb7612",8087:"17be3cba",8431:"11e8bd4a",8458:"ce183519",8552:"f996f09e",8592:"d33acda3",9008:"cc834782",9081:"deb057d8",9155:"bde68bfc",9278:"d53a26a2",9414:"b25c8892",9491:"f84c0c4b",9514:"437ca93b",9586:"b2584bc5",9730:"d00cf7a5",9791:"d6e4c2f7",9874:"0a4240c1",9945:"19621d8e"}[e]+".js"},r.miniCssF=function(e){},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},c={},t="website:",r.l=function(e,a,f,d){if(c[e])c[e].push(a);else{var n,b;if(void 0!==f)for(var o=document.getElementsByTagName("script"),u=0;u Archive | Overextended - +

Archive

Archive

- + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 05c94b31..aa74f9e1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,14 +5,14 @@ Documentation | Overextended - +

Documentation

Here you can find all of the official documentation for resoruces developed by the Overextended team

If you feel like the documentation is lacking in some department then feel free to go onto that page and click the "Edit this page" at the bottom and submit a Pull Request.

- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/Inventory/Search/index.html b/docs/ox_inventory/Functions/Client/Inventory/Search/index.html index 80e08a59..7355ed06 100644 --- a/docs/ox_inventory/Functions/Client/Inventory/Search/index.html +++ b/docs/ox_inventory/Functions/Client/Inventory/Search/index.html @@ -5,7 +5,7 @@ Search | Overextended - + @@ -13,7 +13,7 @@

Search

Searches the inventory for an item, or list of items, with the result varying based on the first argument.

-- search: string
-- item: table or string
-- metadata: table or string (optional)
exports.ox_inventory:Search(search, item, metadata)

If the search argument is defined as 'slots' the return will be a table of slots where the item was found at.

Otherwise if the search argument is defined as 'count' the return value will be the amount of the specified item in player's inventory.

Count​

local count = exports.ox_inventory:Search('count', 'water')
print('You have '..count.. ' water')

Slots​

local water = exports.ox_inventory:Search('slots', 'water')
local count = 0
for _, v in pairs(water) do
print(v.slot..' contains '..v.count..' water '..json.encode(v.metadata))
count = count + v.count
end
print('You have '..count..' water')
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/Items/index.html b/docs/ox_inventory/Functions/Client/Items/index.html index 3d2d7b3f..ddbc6d65 100644 --- a/docs/ox_inventory/Functions/Client/Items/index.html +++ b/docs/ox_inventory/Functions/Client/Items/index.html @@ -5,13 +5,13 @@ Items | Overextended - +

Items

Returns a table of all registered items. The format is as defined in data/items.lua.

exports.ox_inventory:Items()

The following snippet can be used in crafting resources such as okokCrafting or core_crafting, rather than retrieving information from the server.

local itemNames = {}

for item, data in pairs(exports.ox_inventory:Items()) do
itemNames[item] = data.label
end
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/Utils/weaponWheel/index.html b/docs/ox_inventory/Functions/Client/Utils/weaponWheel/index.html index fed87e47..670a8442 100644 --- a/docs/ox_inventory/Functions/Client/Utils/weaponWheel/index.html +++ b/docs/ox_inventory/Functions/Client/Utils/weaponWheel/index.html @@ -5,13 +5,13 @@ weaponWheel | Overextended - +

weaponWheel

Enables the weapon wheel, but disables the use of inventory items.

Mostly used for weaponised vehicles, though could be called for "minigames"

-- state: boolean
local exports.ox_inventory:weaponWheel(state)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/displayMetadata/index.html b/docs/ox_inventory/Functions/Client/displayMetadata/index.html index bb5d434e..13e8eb3e 100644 --- a/docs/ox_inventory/Functions/Client/displayMetadata/index.html +++ b/docs/ox_inventory/Functions/Client/displayMetadata/index.html @@ -5,7 +5,7 @@ displayMetadata | Overextended - + @@ -13,7 +13,7 @@

displayMetadata

Sets a metadata property to display in the tooltip.

-- metadata: table or string
-- value: string (optional)
exports.ox_inventory:displayMetadata(metadata, value)

metadata can either be table or string, if it's a string it's the metadata property that you want to display, value is not optional then.

value represents the label for the property you want to display.

Otherwise metadata can be a table of key value pairs, key being the metadata property and value being the label for that metadata.

Example:

exports.ox_inventory:displayMetadata('mustard', 'Mustard')
exports.ox_inventory:displayMetadata({
mustard = 'Mustard',
ketchup = 'Ketchup'
})
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/openInventory/index.html b/docs/ox_inventory/Functions/Client/openInventory/index.html index cd63d18a..7149b34a 100644 --- a/docs/ox_inventory/Functions/Client/openInventory/index.html +++ b/docs/ox_inventory/Functions/Client/openInventory/index.html @@ -5,13 +5,13 @@ openInventory | Overextended - +

openInventory

Opens an inventory using on the passed data.

-- invType: string
-- data: number | string | table
exports.ox_inventory:openInventory(invType, data)

Open the target player's inventory.

exports.ox_inventory:openInventory('player', 3)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/openNearbyInventory/index.html b/docs/ox_inventory/Functions/Client/openNearbyInventory/index.html index b0034a89..ef2513b9 100644 --- a/docs/ox_inventory/Functions/Client/openNearbyInventory/index.html +++ b/docs/ox_inventory/Functions/Client/openNearbyInventory/index.html @@ -5,7 +5,7 @@ openNearbyInventory | Overextended - + @@ -13,7 +13,7 @@

openNearbyInventory

If possible opens the nearby player's inventory.

The player trying to open the invenotry must be able to open their own and if the player does not have a police job, the target player must be fatally injured or playing one of the death anims.

exports.ox_inventory:openNearbyInventory()
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/setStashTarget/index.html b/docs/ox_inventory/Functions/Client/setStashTarget/index.html index b8fcae52..b0728e9d 100644 --- a/docs/ox_inventory/Functions/Client/setStashTarget/index.html +++ b/docs/ox_inventory/Functions/Client/setStashTarget/index.html @@ -5,13 +5,13 @@ setStashTarget | Overextended - +

setStashTarget

Forces the secondary-inventory key to open the passed inventory. Can be useful to enable inventory access while standing inside a marker.

-- id: string or number
-- owner: string or number (optional)
exports.ox_inventory:setStashTarget(id, owner)

exports.ox_inventory:setStashTarget('motel5', 'bobsmith')
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/useItem/index.html b/docs/ox_inventory/Functions/Client/useItem/index.html index 00dd8a5b..3295a49e 100644 --- a/docs/ox_inventory/Functions/Client/useItem/index.html +++ b/docs/ox_inventory/Functions/Client/useItem/index.html @@ -5,13 +5,13 @@ useItem | Overextended - +

useItem

Uses the passed item, then triggers the callback function.

-- data: table
-- cb: function (optional)
exports.ox_inventory:useItem(data, cb)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Client/useSlot/index.html b/docs/ox_inventory/Functions/Client/useSlot/index.html index c33345a4..6a9da62e 100644 --- a/docs/ox_inventory/Functions/Client/useSlot/index.html +++ b/docs/ox_inventory/Functions/Client/useSlot/index.html @@ -5,13 +5,13 @@ useSlot | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/AddItem/index.html b/docs/ox_inventory/Functions/Server/Inventory/AddItem/index.html index 6d16f50b..b4f9a2bd 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/AddItem/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/AddItem/index.html @@ -5,13 +5,13 @@ AddItem | Overextended - +

AddItem

Adds an item into the specified inventory.

Should be used alongside CanCarryItem otherwise, the maximum weight may be exceeded.

-- inv: string or number
-- item: table or string
-- count: number
-- metadata: table or string (optional)
-- slot: number (optional)
-- cb: function (optional)
exports.ox_inventory:AddItem(inv, item, count, metadata, slot, cb)

Example:

exports.ox_inventory:AddItem(1, 'bread', 4, nil, nil, function(success, reason)
if success then
print(json.encode(reason, {indent=true}))
--[[
{
"metadata": [],
"label": "Bread",
"slot": 1,
"stack": true,
"close": true,
"name": "bread",
"count": 1,
"weight": 150
}
]]
else
print(success)
-- nil

print(reason)
-- for example if all slots are taken it will give us "inventory_full"
end
end)

Possible value of the "reason" argument for the callback function:

  • "invalid_item": the item doesn't exist
  • "invalid_inventory": the inventory doesn't exist
  • "inventory_full": no free slots
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount/index.html b/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount/index.html index 831f209d..a340674b 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryAmount/index.html @@ -5,13 +5,13 @@ CanCarryAmount | Overextended - +

CanCarryAmount

Returns the amount a player can hold based on available weight.

---@param inv string | number
---@param item table | string
exports.ox_inventory:CanCarryAmount(inv, item)

Example:

-- Checks how much you can carry
amountToAdd = exports.ox_inventory:CanCarryAmount(inv, 'stone')
-- Adds the amount
exports.ox_inventory:AddItem(inv, 'stone', amountToAdd)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem/index.html b/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem/index.html index bcdc8a89..a8398db1 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/CanCarryItem/index.html @@ -5,13 +5,13 @@ CanCarryItem | Overextended - +

CanCarryItem

Returns true or false depending if the inventory can carry the specified item.

The function checks for inventory weight and available slots.

-- inv: string or number
-- item: table or string
-- count: number
-- metadata: table or string (optional)
exports.ox_inventory:CanCarryItem(inv, item, count, metadata)

Example:

-- Checks if the player calling the event can carry 3 water items
if exports.ox_inventory:CanCarryItem(source, 'water', 3) then
-- Do stuff if can carry
else
-- Do stuff if can't carry
end
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem/index.html b/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem/index.html index 4a096e16..7412eb73 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/CanSwapItem/index.html @@ -5,13 +5,13 @@ CanSwapItem | Overextended - +

CanSwapItem

Returns true if the item swap is possible based on inventory weight.

-- inv: string or number
-- firstItem: string
-- firstItemCount: number
-- testItem: string
-- testItemCount: number
exports.ox_inventory:CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory/index.html b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory/index.html index efc9eccf..fe95d91e 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ClearInventory/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/ClearInventory/index.html @@ -5,13 +5,13 @@ ClearInventory | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory/index.html b/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory/index.html index ef58db3c..db812663 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/ConfiscateInventory/index.html @@ -5,14 +5,14 @@ ConfiscateInventory | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/ConvertItems/index.html b/docs/ox_inventory/Functions/Server/Inventory/ConvertItems/index.html index 14173d8b..d966c7a1 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ConvertItems/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/ConvertItems/index.html @@ -5,13 +5,13 @@ ConvertItems | Overextended - +

ConvertItems

Takes traditional item data and updates it to support ox_inventory.

-- playerId: number
-- items: table
exports.ox_inventory:ConvertItems(playerId, items)

Data conversion example:

Old: [{"cola":1, "bread":3}]
New: [{"slot":1,"name":"cola","count":1}, {"slot":2,"name":"bread","count":3}]
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/CustomDrop/index.html b/docs/ox_inventory/Functions/Server/Inventory/CustomDrop/index.html index 10012973..bd7269b9 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/CustomDrop/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/CustomDrop/index.html @@ -5,14 +5,14 @@ CustomDrop | Overextended - +

CustomDrop

Creates an inventory drop at the specified coords.

-- prefix: string
-- items: table
-- coords: vector3
-- slots: number
-- maxWeight: number
-- instance: ? (optional)
exports.ox_inventory:CustomDrop(prefix, item, coords, slots, maxWeight, instance)

Example: You can find and example showcasing this function into furher detail here.

- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon/index.html b/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon/index.html index f7759f9b..3c1cee69 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/GetCurrentWeapon/index.html @@ -5,13 +5,13 @@ GetCurrentWeapon | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetItem/index.html b/docs/ox_inventory/Functions/Server/Inventory/GetItem/index.html index b720d8a2..745c18bc 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetItem/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/GetItem/index.html @@ -5,14 +5,14 @@ GetItem | Overextended - +

GetItem

Returns the item from the specified inventory.

-- inv: string or number
-- item: table or string
-- metadata: any (optional)
-- returnsCount: boolean (optional)
exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)

If returnsCount is set to true, the returned value will be the count based on how many times the item was found.

Otherwise returns the data related to the item and it's total count found in the inventory.

Example:

local item = ox_inventory:GetItem(source, 'water', nil, false)

print(json.encode(item, {indent=true}))
--[[
{
"consume": 1,
"count": 15,
"stack": true,
"name": "water",
"weight": 500,
"label": "Water",
"close": true
}
]]
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots/index.html b/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots/index.html index e7bcfaec..ef7a0568 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/GetItemSlots/index.html @@ -5,13 +5,13 @@ GetItemSlots | Overextended - +

GetItemSlots

Returns the number of slots the specified item is in, the item's total count and the remaining empty slots.

-- inv: string or number
-- item: table or string
-- metadata: table (optional)
exports.ox_inventory:GetItemSlots(inv, item, metadata)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/GetSlot/index.html b/docs/ox_inventory/Functions/Server/Inventory/GetSlot/index.html index 2e5ef7fe..297182bf 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/GetSlot/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/GetSlot/index.html @@ -5,13 +5,13 @@ GetSlot | Overextended - +

GetSlot

Returns the specified slot data as a table.

-- inv: string or number
-- slot: number
exports.ox_inventory:GetSlot(inv, slot)

Example:

local slot = exports.ox_inventory:GetSlot(source, 1)

print(json.encode(slot, {indent=true}))
--[[
{
"weight": 2000,
"name": "water",
"metadata": [],
"slot": 1,
"label": "Water",
"close": true,
"stack": true,
"count: 4
}
]]
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/RegisterStash/index.html b/docs/ox_inventory/Functions/Server/Inventory/RegisterStash/index.html index 8b27e3e8..4341f7b6 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/RegisterStash/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/RegisterStash/index.html @@ -5,13 +5,13 @@ RegisterStash | Overextended - +

RegisterStash

Creates a new custom stash.

-- id: string or number
-- label: string
-- slots: number
-- maxWeight: number
-- owner: string or boolean or nil
-- groups: table
-- coords: vector3
exports.ox_inventory:RegisterStash(id, label, slots, maxWeight, owner, groups, coords)
  • id - Stash identifier when loading from the database.
  • label - Display name when inventory is open.
  • owner - Defines stash permissions.
    • string: Can only access the stash linked to the owner.
    • true: Each player has a unique stash but can request other player's stashes.
    • nil: Always shared.
  • groups - Player groups (jobs) able to access the stash.
    • Table of group names where the numeric value is the minimum grade required.
    • {['police'] = 0, ['ambulance'] = 2}
caution

This function needs to be triggered before a player can open the stash.

Example:

For a use case example on this function check out the written Guide for it.

- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/RemoveItem/index.html b/docs/ox_inventory/Functions/Server/Inventory/RemoveItem/index.html index d86b7299..465d1653 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/RemoveItem/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/RemoveItem/index.html @@ -5,13 +5,13 @@ RemoveItem | Overextended - +

RemoveItem

Removes the specified item from the specified inventory.

-- inv: string or table
-- item: table or string
-- count: number
-- metadata: table or string (optional)
-- slot: number (optional)
exports.ox_inventory:RemoveItem(inv, item, count, metadata, slot)

Example:

-- Removes 1 water from the inventory
exports.ox_inventory:RemoveItem(source, 'water', 1)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory/index.html b/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory/index.html index bbe55a42..2652262a 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/ReturnInventory/index.html @@ -5,13 +5,13 @@ ReturnInventory | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/Search/index.html b/docs/ox_inventory/Functions/Server/Inventory/Search/index.html index 2c220398..c4410b96 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/Search/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/Search/index.html @@ -5,14 +5,14 @@ Search | Overextended - +

Search

Searches an inventory for a specified item.

-- inv: string or number
-- search: string
-- item: table or string
-- metadata: table or string (optional)
exports.ox_inventory:Search(inv, search, item, metadata)

search can be either 'slots' or 'count', where slots will return a table of data and count will return the found amount of the specified item.

- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/SetDurability/index.html b/docs/ox_inventory/Functions/Server/Inventory/SetDurability/index.html index e7876137..e532c7ef 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SetDurability/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/SetDurability/index.html @@ -5,13 +5,13 @@ SetDurability | Overextended - +

SetDurability

Sets durability onto the specified slot.

Can be used for repairing weapons.

-- inv: string or number
-- slot: number
-- durability: number
exports.ox_inventory:SetDurability(inv, slot, durability)

Example:

local ox_inventory = exports.ox_inventory

-- Set the durability of the item in slot 3 of source player's inventory to 100
ox_inventory:SetDurability(source, 3, 100)

-- Set the durability of the source player's current weapon to 100
local weapon = ox_inventory:GetCurrentWeapon(source)

if weapon then
ox_inventory:SetDurability(source, weapon.slot, 100)
end
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/SetMetadata/index.html b/docs/ox_inventory/Functions/Server/Inventory/SetMetadata/index.html index b3648263..f7bd5397 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SetMetadata/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/SetMetadata/index.html @@ -5,13 +5,13 @@ SetMetadata | Overextended - +

SetMetadata

Sets metadata on the specified slot.

-- inv: string or number
-- slot: number
-- metadata: table
ox_inventory:SetMetadata(inv, slot, metadata)

Example:

local ox_inventory = exports.ox_inventory

local water = ox_inventory:Search(source, 1, 'water')
for k, v in pairs(water) do
print('\n______________'..'\n- index '..k)
print(v.name, 'slot: '..v.slot, 'metadata: '..json.encode(v.metadata))
water = v
end
water.metadata.type = 'clean'
ox_inventory:SetMetadata(source, water.slot, water.metadata)
print(('modified %sx water in slot %s with new metadata'):format(water.count, water.slot))
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Inventory/SwapSlots/index.html b/docs/ox_inventory/Functions/Server/Inventory/SwapSlots/index.html index abc0eecd..10f203fb 100644 --- a/docs/ox_inventory/Functions/Server/Inventory/SwapSlots/index.html +++ b/docs/ox_inventory/Functions/Server/Inventory/SwapSlots/index.html @@ -5,13 +5,13 @@ SwapSlots | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/Items/index.html b/docs/ox_inventory/Functions/Server/Items/index.html index f0949780..cc243f1e 100644 --- a/docs/ox_inventory/Functions/Server/Items/index.html +++ b/docs/ox_inventory/Functions/Server/Items/index.html @@ -5,13 +5,13 @@ Items | Overextended - +

Items

Returns a table of all registered items. The format is as defined in data/items.lua.

exports.ox_inventory:Items()

The following snippet can be used in crafting resources such as okokCrafting or core_crafting, rather than querying the database.

local itemNames
ESX.RegisterServerCallback('crafting:itemNames', function(source, cb)
if not itemNames then
itemNames = {}
for item, data in pairs(exports.ox_inventory:Items()) do
itemNames[item] = data.label
end
end
cb(itemNames)
end)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Functions/Server/setPlayerInventory/index.html b/docs/ox_inventory/Functions/Server/setPlayerInventory/index.html index c88f353f..0405062c 100644 --- a/docs/ox_inventory/Functions/Server/setPlayerInventory/index.html +++ b/docs/ox_inventory/Functions/Server/setPlayerInventory/index.html @@ -5,13 +5,13 @@ setPlayerInventory | Overextended - +

setPlayerInventory

Creates and sets the player's inventory.

-- player: table
-- source: number
-- identifier: string
-- name: string
-- groups: table (optional)
-- sex: string (optional)
-- dateofbirth: string (optional)
-- data: table
exports.ox_inventory:setPlayerInventory(player, data)
- + \ No newline at end of file diff --git a/docs/ox_inventory/Guides/creatingItems/index.html b/docs/ox_inventory/Guides/creatingItems/index.html index c410cb92..9eed21dd 100644 --- a/docs/ox_inventory/Guides/creatingItems/index.html +++ b/docs/ox_inventory/Guides/creatingItems/index.html @@ -5,7 +5,7 @@ Creating items | Overextended - + @@ -15,10 +15,10 @@ options for the item.

Item options:

-- label: string
-- weight: number (optional)
-- stack: boolean (optional) -- If set to false will not allow the item to be stacked
-- degrade: number (optional) -- The amount of time in minutes an item will degrade after
-- close: boolean (optional) -- If set to false will not close the inventory on item use
-- description: string (optional)
-- consume: number (optional) -- Number of an item needed to use it, and removed after use (Default: 1)
-- allowArmed: boolean (optional) -- If set to true will allow use of item while armed with a weapon
-- client: table (optional)
-- buttons: table (optional) -- Allows you to define custom context menu functions for the item

Examples:

['burger'] = {
label = 'Burger',
weight = 220,
stack = true,
close = true,
client = {
status = { hunger = 200000 },
anim = { dict = 'mp_player_inteat@burger', clip = 'mp_player_int_eat_burger_fp' },
prop = {
model = 'prop_cs_burger_01',
pos = { x = 0.02, y = 0.02, y = -0.02},
rot = { x = 0.0, y = 0.0, y = 0.0}
},
usetime = 2500,
}
}

Making the item usable​

If you are using ESX you can continue using ESX.RegisterUsableItem if desired.
Using the built-in system is more secure and provides simple progressbar support.

An item will be usable when client variables are added to data/items.lua, or has a registered item callback. Item callbacks can be added by defining an export (recommended), or by adding it to items/client.lua.

When defining item data, adding client.export will trigger an event on item use.
The correct formatting is export = resourceName.exportName.

exports('bandage', function(data, slot)
local playerPed = PlayerPedId()
local maxHealth = GetEntityMaxHealth(playerPed)
local health = GetEntityHealth(playerPed)

-- Does the ped need to heal?
if health < maxHealth then
-- Use the bandage
exports.ox_inventory:useItem(data, function(data)
-- The item has been used, so trigger the effects
if data then
SetEntityHealth(playerPed, math.min(maxHealth, math.floor(health + maxHealth / 16)))
exports.ox_inventory:notify({text = 'You feel better already'})
end
end)
else
-- Don't use the item
exports.ox_inventory:notify({type = 'error', text = 'You don\'t need a bandage right now'})
end
end)

Item events​

Similarly to the client, a callback function can be defined on the server to handle several events (usingItem, usedItem, buyItem).
-This can either be an export (recommended), or added to items/server.lua.

exports('bandage', function(event, item, inventory, slot, data)
if event == 'usingItem' then
local playerPed = GetPlayerPed(inventory.source)
local maxHealth = GetEntityMaxHealth(playerPed)
local health = GetEntityHealth(playerPed)

if health >= maxHealth then
TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'error', text = 'You don\'t need a bandage right now'})

-- Returning 'false' will prevent the item from being used
return false
end

return
elseif event == 'usedItem' then
return TriggerClientEvent('ox_inventory:notify', inventory.source, {text = 'You feel better already'})

elseif event == 'buying' then
return TriggerClientEvent('ox_inventory:notify', inventory.source, {type = 'success', text = 'You bought a bandage'})
end
end)

Creating container items​

Like with other items the item must first be registered.

Example:

['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},

When registered you can define the item as a container under the Items.containers table in /modules/items/sever.lua
+This can either be an export (recommended), or added to items/server.lua.

exports('bandage', function(event, item, inventory, slot, data)
if event == 'usingItem' then
local playerPed = GetPlayerPed(inventory.id)
local maxHealth = GetEntityMaxHealth(playerPed)
local health = GetEntityHealth(playerPed)

if health >= maxHealth then
TriggerClientEvent('ox_inventory:notify', inventory.id, {type = 'error', text = 'You don\'t need a bandage right now'})

-- Returning 'false' will prevent the item from being used
return false
end

return
elseif event == 'usedItem' then
return TriggerClientEvent('ox_inventory:notify', inventory.id, {text = 'You feel better already'})

elseif event == 'buying' then
return TriggerClientEvent('ox_inventory:notify', inventory.id, {type = 'success', text = 'You bought a bandage'})
end
end)

Creating container items​

Like with other items the item must first be registered.

Example:

['paperbag'] = {
label = 'Paper Bag',
weight = 1,
stack = false,
close = false,
consume = 0
},

When registered you can define the item as a container under the Items.containers table in /modules/items/sever.lua
The key for the container is the name you gave it when registering the item.
You can also define the number of slots, the maximum weight, blacklist and whitelist items.

['name'] = {
-- size: {slots, maxWeight}
-- slots: number
-- maxWeight: number
-- blacklist: table (optional)
-- ['itemName'] = true
-- whitelist: table (optional)
-- ['itemName'] = true
}

Example:

['paperbag'] = {
size = {5, 1000},
blacklist = {
['testburger'] = true -- No burgers!
}
},
- + \ No newline at end of file diff --git a/docs/ox_inventory/Guides/customDrop/index.html b/docs/ox_inventory/Guides/customDrop/index.html index 1b9d74e1..38539ca9 100644 --- a/docs/ox_inventory/Guides/customDrop/index.html +++ b/docs/ox_inventory/Guides/customDrop/index.html @@ -5,13 +5,13 @@ Creating custom drops | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Guides/index.html b/docs/ox_inventory/Guides/index.html index a022a4e9..7eaa10f7 100644 --- a/docs/ox_inventory/Guides/index.html +++ b/docs/ox_inventory/Guides/index.html @@ -5,13 +5,13 @@ Overview | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_inventory/Guides/inventory_ui/index.html b/docs/ox_inventory/Guides/inventory_ui/index.html index 682f16a8..96a58868 100644 --- a/docs/ox_inventory/Guides/inventory_ui/index.html +++ b/docs/ox_inventory/Guides/inventory_ui/index.html @@ -5,7 +5,7 @@ Building inventory UI | Overextended - + @@ -13,7 +13,7 @@

Building inventory UI

Requirements to build:​

  • Node.js
  • Yarn

Installing Node.js:​

  • Download the LTS version of Node.js.
  • Go through the install and make sure you install all of the features.
  • Run node --version in cmd and make sure that it gives you the version number. If it doesn't then you didn't install it correctly.

Installing Yarn:​

  • Now that you've installed Node.js you can install Yarn by running npm install --global yarn in cmd.

Building the UI:​

  • cd into the web directory of ox_inventory
  • In your cmd type yarn and in will start downloading the node modules.
  • After it's done downloading node modules you can run yarn build to build the UI.
Hot reloads

When working in the browser you can run yarn start, which supports hot reloads meaning that you will see your changes after saving your file.

If you want to work in game you can run yarn start:game which writes changes to disk, so the only thing you have to do is restart the resource for it take affect.

- + \ No newline at end of file diff --git a/docs/ox_inventory/Guides/stashes/index.html b/docs/ox_inventory/Guides/stashes/index.html index ba1f2486..a6512993 100644 --- a/docs/ox_inventory/Guides/stashes/index.html +++ b/docs/ox_inventory/Guides/stashes/index.html @@ -5,13 +5,13 @@ Creating custom stashes | Overextended - +

Creating custom stashes

We can set up custom stashes from outside the resource utilising the exported RegisterStash function. Firstly, we need to define the stashes properties.

-- id: string
-- label: string
-- slots: number
-- weight: number
-- owner: string or boolean (optional)
-- groups: table (optional)
-- name: string
-- grade: number
-- coords: vector or table (optional)
  • id - A unique name to identify the stash in the database
  • label - Display name when viewing the stash
  • slots - Number of slots that the stash will have
  • weight - Maximum stash weight
  • owner - See below
  • groups - Key-value pairs of job name and minimum grade to access
  • coords - Vector or table containing coordinates

The owner field will set permissions for stash access, with stashes registering to specific identifiers.

  • true: Each player has their own unique stash, but can request to open the stash of another player
  • false: Only a single stash exists and is shared between all players
  • string: The stash explicitly belongs to the given owner, usually a player identifier

You can set the stash coordinates to prevent the stash from being opened if the player isn't close enough.

Example​

Below the value is hardset, but it could be loaded from the database (especially if there are unknown fields, i.e. owner)

-- Server
local stash = {
id = '42wallabyway',
label = '42 Wallaby Way',
slots = 50,
weight = 100000,
owner = 'char1:license'
}

AddEventHandler('onServerResourceStart', function(resourceName)
if resourceName == 'ox_inventory' or resourceName == GetCurrentResourceName() then
exports.ox_inventory:RegisterStash(stash.id, stash.label, stash.slots, stash.weight, stash.owner)
end
end)

-- Client
exports.ox_inventory:openInventory('stash', {id='42wallabyway', owner=property.owner})

The following sample is based on esx_property's db data.

-- Server
local properties

MySQL.query('SELECT * FROM `properties`', {}, function(result)
properties = result
end

RegisterNetEvent('ox:loadStashes', function(id)
local stash = properties[id]
if stash then
-- id: 1, name: WhispymoundDrive, label: 2677 Whispymound Drive, coords: {"x":118.748,"y":566.573,"z":175.697}
ox_inventory:RegisterStash(stash.name, stash.label, 50, 100000, true, false, json.encode(stash.room_menu))
end
end)

-- Client
local ox_inventory = exports.ox_inventory

if ox_inventory:openInventory('stash', property.id) == false then
TriggerServerEvent('ox:loadStashes')
ox_inventory:openInventory('stash', property.id)
end

Example resource​

We put together an example resource showcasing how to properly utilise the stash API:

- + \ No newline at end of file diff --git a/docs/ox_inventory/config/index.html b/docs/ox_inventory/config/index.html index 52b80649..a06e79a3 100644 --- a/docs/ox_inventory/config/index.html +++ b/docs/ox_inventory/config/index.html @@ -5,13 +5,13 @@ Configuration | Overextended - +

Configuration

You can add these settings directly to your 'server.cfg', or add them to a separate file (i.e. inventory.cfg) and call it with exec.

caution

Convars must be set before starting ox_inventory.

The values below are defaults and should not be explicitly set unless changing the value.

# Activate specific event handlers and functions (supported: ox, esx)
setr inventory:framework "esx"

# Load specific language file from data/locales
setr inventory:locale "en"

# Number of slots for player inventories
setr inventory:slots 50

# Maximum carry capacity for players, in kilograms
setr inventory:weight 30000

# Weapons will reload after reaching 0 ammo
setr inventory:autoreload false

# Weapons must be aimed before shooting
setr aimedfiring false

# Blur the screen while accessing the inventory
setr inventory:screenblur true

# Trim whitespace from vehicle plates when checking owned vehicles
setr inventory:trimplate true

# Integrated support for qtarget stashes, shops, etc
setr inventory:qtarget false

# Default hotkeys to access primary and secondary inventories, and hotbar
setr inventory:keys ["F2", "K", "TAB"]

# Enable control action when inventory is open
setr inventory:enablekeys [249]

# Jobs with access to police armoury, evidence lockers, etc
setr inventory:police ["police", "sheriff"]

# Item prices fluctuate in shops
set inventory:randomprices true

# Compare current version to latest release on GitHub
set inventory:versioncheck true

# Loot will randomly generate inside unowned vehicles and dumpsters
set inventory:randomloot true

# Minimum job grade to remove items from evidence lockers
set inventory:evidencegrade 2

# Stashes will be wiped after remaining unchanged for the given time
set inventory:clearstashes "6 MONTH"

# Set the contents of randomly generated inventories
# [item name, minimum, maximum, loot chance]
set inventory:vehicleloot [
["cola", 1, 1],
["water", 1, 1],
["garbage", 1, 2, 50],
["panties", 1, 1, 5],
["money", 1, 50],
["money", 200, 400, 5],
["bandage", 1, 1]
]

set inventory:dumpsterloot [
["mustard", 1, 1],
["garbage", 1, 3],
["money", 1, 10],
["burger", 1, 1]
]

# Set datadog API key for inventory logging (https://app.datadoghq.com/organization-settings/api-keys)
set datadog:key ""

# Set server intake (https://docs.datadoghq.com/api/latest/logs/#send-logs)
set datadog:site "datadoghq.com"

# Set server hostname
set datadog:hostname "FXServer"
- + \ No newline at end of file diff --git a/docs/ox_inventory/index.html b/docs/ox_inventory/index.html index 9a557311..7ef05912 100644 --- a/docs/ox_inventory/index.html +++ b/docs/ox_inventory/index.html @@ -5,7 +5,7 @@ Getting Started | Overextended - + @@ -32,7 +32,7 @@ and
caution

You should restart your server after the first startup to ensure everything has been correctly setup

Upgrading ESX​

Ox Inventory provides a complete suite of tools to replace the built-in items and inventory system from ESX, and is not intended to be used with resources designed around it.

  • ESX loadouts do not exist - resources that use them need to remove references or be modified to look for the weapon as an item
  • Stashes from resources such as esx_policejob, esx_ambulancejob, etc. should be removed
  • Shops from esx_shops or the armoury from esx_policejob should be removed
  • Resources like esx_inventoryhud, esx_trunkinventory, esx_addoninventory, etc. should be removed

Optional optimisation​

All item related functions from xPlayer, such as xPlayer.getInventoryItem, have been modified for compatibility purposes; however they are considered deprecated.

The reasoning is fairly simple - there's now additional function references and overhead to consider. Fortunately, the new Inventory functions can be used directly and offer a great deal of improvements over the old ones.

You should read through the functions section for further information, but the following should give you a decent idea.

if xPlayer.getInventoryItem('acetone').count > 2 and xPlayer.getInventoryItem('antifreeze').count > 4 and xPlayer.getInventoryItem('sudo').count > 9 then
xPlayer.removeInventoryItem("acetone", 3)
xPlayer.removeInventoryItem("antifreeze", 5)
xPlayer.removeInventoryItem("sudo", 10)
end

Common Issues​

UI has not been built​

Because the UI for inventory is written in React it can't run natively under FiveM so it must first be bundled into html/css/js.

We provide an easy way for you to do this by downloading a pre-bundled release, which you can get from here.
Make sure you download the ox_inventory.zip file as that one contains the bundled files and others are raw source code.

If in case you wanted to edit the inventory UI you would have to build these files yourself.
To do so please read our Building inventory UI guide.

- + \ No newline at end of file diff --git a/docs/ox_lib/Client/Interface/context/index.html b/docs/ox_lib/Client/Interface/context/index.html index 57a9862e..92350c0f 100644 --- a/docs/ox_lib/Client/Interface/context/index.html +++ b/docs/ox_lib/Client/Interface/context/index.html @@ -5,7 +5,7 @@ Context Menu | Overextended - + @@ -35,7 +35,7 @@ the button will do nothing upon being clicked.

Of course just registering with the lib.showContext function, passing in the menu's id.

As of the time writing this the buttons are sorted alphabetically.

menu_example
metadata
event_menu

- + \ No newline at end of file diff --git a/docs/ox_lib/Client/Interface/input/index.html b/docs/ox_lib/Client/Interface/input/index.html index bb7ee79d..83af40d1 100644 --- a/docs/ox_lib/Client/Interface/input/index.html +++ b/docs/ox_lib/Client/Interface/input/index.html @@ -5,7 +5,7 @@ Input Dialog | Overextended - + @@ -23,7 +23,7 @@ a number instead.

If a user left an input field empty it will return options ONLY with type "select".

Doing so otherwise will result in errors.

Example:

local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'})

if input then
local lockerNumber = tonumber(input[1])
local lockerPasscode = input[2]

print(lockerNumber, lockerPasscode)
end

Example image

- + \ No newline at end of file diff --git a/docs/ox_lib/Client/Interface/notify/index.html b/docs/ox_lib/Client/Interface/notify/index.html index 6af086b4..2423b113 100644 --- a/docs/ox_lib/Client/Interface/notify/index.html +++ b/docs/ox_lib/Client/Interface/notify/index.html @@ -5,7 +5,7 @@ Notifications | Overextended - + @@ -18,7 +18,7 @@ style - React CSS styling, works the same as in TextUI
icon - Font Awesome 6 icon, works the same as in TextUI
iconColor - Set a different color for the provided icon

Example:

lib.notify({
title = 'Notification title',
description = 'Notification description',
type = 'success'
})

notification

lib.defaultNotify​

Default notifications provided by Chakra UI.

-- title: string (if description then optional)
-- description: string (if title then optional)
-- duration: number (optional)
-- position: ToastPositionWithLogical (optional)
-- status: "info" | "warning" | "success" | "error" (optional)
-- id: number (optional)

lib.defaultNotify(data)

Example:

lib.defaultNotify({
title = 'Notification title',
description = 'Notification description',
status = 'success'
})

default_notification

- + \ No newline at end of file diff --git a/docs/ox_lib/Client/Interface/progress/index.html b/docs/ox_lib/Client/Interface/progress/index.html index 3e4285db..d0ee4ad7 100644 --- a/docs/ox_lib/Client/Interface/progress/index.html +++ b/docs/ox_lib/Client/Interface/progress/index.html @@ -5,7 +5,7 @@ Progress | Overextended - + @@ -14,7 +14,7 @@ as individual tables in the prop table.

Example:

if lib.progressBar({
duration = 2000,
label = 'Drinking water',
useWhileDead = false,
canCancel = true,
disable = {
car = true,
},
anim = {
dict = 'mp_player_intdrink',
clip = 'loop_bottle'
},
prop = {
model = `prop_ld_flow_bottle`,
pos = vec3(0.03, 0.03, 0.02),
rot = vec3(0.0, 0.0, -1.5)
},
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end

progress_bar

lib.progressCircle​

Similar to lib.progressBar except it displays a circle and has no label and you can define a position.

-- duration: number
-- position: "middle" or "bottom" (optional - default is "middle")
-- useWhileDead: boolean (optional)
-- canCancel: boolean (optional)
-- anim: table (optional)
-- dict: string (optional - either scenario or dict)
-- clip: string
-- flag: number (optional - default is 49)
-- blendIn: float (optional - default is 3.0)
-- blendOut: float (optional - default is 1.0)
-- duration: number (optional - default is -1)
-- flag: number (optional - default is 49)
-- playbackRate: number (optional - default is 0)
-- lockX: boolean (optional)
-- lockY: boolean (optional)
-- lockZ: boolean (optional)

-- scenario: string (optional - either scenario or dict)
-- playEnter: boolean (optional - default is true)
-- prop: table (optional)
-- model: hash
-- x: number
-- y: number
-- z: number
-- bone: number (optional - default is 60309)
-- pos: table
-- x: number
-- y: number
-- z: number
-- rot: table
-- x: number
-- y: number
-- z: number
-- disable: table (optional)
-- move: boolean (optional)
-- car: boolean (optional)
-- comabt: boolean (optional)
-- mouse: boolean (optional)
--- ...: number (optional - Keys to disable, can have unlimted)

lib.progressCircle(data)

Example:

if lib.progressCircle({
duration = 2000,
position = 'bottom',
useWhileDead = false,
canCancel = true,
disable = {
car = true,
},
anim = {
dict = 'mp_player_intdrink',
clip = 'loop_bottle'
},
prop = {
model = `prop_ld_flow_bottle`,
pos = vec3(0.03, 0.03, 0.02),
rot = vec3(0.0, 0.0, -1.5)
},
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end

progress_circle

lib.progressActive​

Returns true if a progress bar is currently active.

lib.progressActive()

lib.cancelProgress​

If there is a progress bar active and the progress bar can be cancelled then it cancels it.

lib.cancelProgress()
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/Interface/textui/index.html b/docs/ox_lib/Client/Interface/textui/index.html index 514db749..6f5f05e1 100644 --- a/docs/ox_lib/Client/Interface/textui/index.html +++ b/docs/ox_lib/Client/Interface/textui/index.html @@ -5,7 +5,7 @@ TextUI | Overextended - + @@ -15,7 +15,7 @@ the default icon type will be solid.
If you want to use a different icon type, i.e apple as a brand, you need to define icon as a table with the first value being the icon type as a string, and the second being the icon name.

icon = {'fab', 'apple'}

lib.hideTextUI​

Hides the currently visible TextUI window

lib.hideTextUI()
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/cache/index.html b/docs/ox_lib/Client/cache/index.html index 837cc35c..d8c260c6 100644 --- a/docs/ox_lib/Client/cache/index.html +++ b/docs/ox_lib/Client/cache/index.html @@ -5,14 +5,14 @@ Cache | Overextended - +

Cache

Caches data related to the player and handling some events or statebags.
An interval runs every 100ms to update data that cannot be checked via handlers.

https://github.com/overextended/ox_lib/blob/master/resource/cache/client.lua

States​

cache.ped        -- player entity id
cache.vehicle -- vehicle entity id
cache.seat -- vehicle seat index

lib.onCache​

Register a callback function when the value is changed.

lib.onCache('vehicle', function(value)
print('vehicle', value)
end)

lib.onCache('seat', function(value)
print('seat', value)
end)
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/callback/index.html b/docs/ox_lib/Client/callback/index.html index 34b94305..fa9217d6 100644 --- a/docs/ox_lib/Client/callback/index.html +++ b/docs/ox_lib/Client/callback/index.html @@ -5,13 +5,13 @@ Callbacks | Overextended - +

Callbacks

Triggers a registered server callback and registers an event handler for the response.

lib.callback​

The response is handled in a separate coroutine.

-- name: string
-- delay: number or false
-- cb: function
lib.callback(name, delay, cb, ...)

lib.callback('ox_inventory:getItemCount', false, function(count)
print(count)
end, 'water', {type = 'fresh'})

lib.callback.await​

The current coroutine is yielded until a response is received.

-- name: string
-- delay: number or false
lib.callback.await(name, delay, ...)

local count = lib.callback.await('ox_inventory:getItemCount', false, 'water', {type = 'fresh'})
print(count)
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/disableControls/index.html b/docs/ox_lib/Client/disableControls/index.html index 576f1c9b..38fee02d 100644 --- a/docs/ox_lib/Client/disableControls/index.html +++ b/docs/ox_lib/Client/disableControls/index.html @@ -5,13 +5,13 @@ Disable Controls | Overextended - +

Disable Controls

lib.disableControls​

-- Call on frame to disable all stored keys.
lib.disableControls()

lib.disableControls:Add​

-- vararg: number
lib.disableControls:Add(...)

lib.disableControls:Remove​

-- vararg: number
lib.disableControls:Remove(...)

lib.disableControls:Clear​

-- vararg: number
lib.disableControls:Clear(...)
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/misc/index.html b/docs/ox_lib/Client/misc/index.html index 3f552e0d..0ccd2abd 100644 --- a/docs/ox_lib/Client/misc/index.html +++ b/docs/ox_lib/Client/misc/index.html @@ -5,13 +5,13 @@ Misc | Overextended - + - + \ No newline at end of file diff --git a/docs/ox_lib/Client/points/index.html b/docs/ox_lib/Client/points/index.html index f01257ce..79e03d62 100644 --- a/docs/ox_lib/Client/points/index.html +++ b/docs/ox_lib/Client/points/index.html @@ -5,13 +5,13 @@ Points | Overextended - +

Points

Simple and centralised distance checking, supporting callbacks when entering, leaving, and standing in-range of set coordinates.

-- coords: vector3
-- distance: number
-- data: table
lib.points.new(coords, distance, data)

local point = lib.points.new(playerCoords, 5, {
dunak = 'nerd',
})

function point:onEnter()
print('entered range of point', self.id)
end

function point:onExit()
print('left range of point', self.id)
end

function point:nearby()
DrawMarker(2, self.coords.x, self.coords.y, self.coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.0, 1.0, 1.0, 200, 20, 20, 50, false, true, 2, nil, nil, false)

if self.currentDistance < 1 and IsControlJustReleased(0, 38) then
print('inside marker', self.id)
print(self.dunak)
end
end
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/streaming/index.html b/docs/ox_lib/Client/streaming/index.html index 6d60f9b5..c8f4ea66 100644 --- a/docs/ox_lib/Client/streaming/index.html +++ b/docs/ox_lib/Client/streaming/index.html @@ -5,14 +5,14 @@ Streaming | Overextended - +

Streaming

Check if assets exist, such as models, and loads them into memory.
Throws errors for invalid assets and returns true if the asset is loaded.

lib.requestAnimDict​

-- dict: string
-- timeout: number [default: 100]
lib.requestAnimDict(dict, timeout)

lib.requestAnimSet​

-- set: string
-- timeout: number [default: 100]
lib.requestAnimSet(set, timeout)

lib.requestModel​

-- model: string
-- timeout: number [default: 100]
lib.requestModel(model, timeout)

lib.requestStreamedTextureDict​

-- dict: string
-- timeout: number [default: 100]
lib.requestStreamedTextureDict(dict, timeout)

lib.requestNamedPtfxAsset​

-- fxName: string
-- timeout: number [default: 100]
lib.requestNamedPtfxAsset(fxName, timeout)
- + \ No newline at end of file diff --git a/docs/ox_lib/Client/vehicleProperties/index.html b/docs/ox_lib/Client/vehicleProperties/index.html index f3a8e896..7de3ccaa 100644 --- a/docs/ox_lib/Client/vehicleProperties/index.html +++ b/docs/ox_lib/Client/vehicleProperties/index.html @@ -5,14 +5,14 @@ Vehicle Properties | Overextended - +

Vehicle Properties

Mostly follows the format used by ESX and QBCore, with extra data such as damaged/missing props.
https://github.com/overextended/ox_lib/blob/master/resource/vehicleProperties/client.lua#L5

lib.getVehicleProperties​

-- vehicle: entity
lib.getVehicleProperties(vehicle)

lib.getVehicleProperties(GetVehiclePedIsUsing(PlayerPedId()))

lib.setVehicleProperties​

Requires the vehicle to belong to the client. Do not use NetworkRequestControlOfEntity.

-- vehicle: entity
-- props: table
lib.setVehicleProperties(vehicle, props)

RegisterNetEvent('lualib:setVehicleProperties', function(netid, data)
lib.setVehicleProperties(NetToVeh(netid), data)
end)

The server should tell the owner of the entity to set properties, using the following trigger.

TriggerClientEvent('lualib:setVehicleProperties', entityOwner, vehNetId, data)
- + \ No newline at end of file diff --git a/docs/ox_lib/Server/acl/index.html b/docs/ox_lib/Server/acl/index.html index 637f4d88..e2744bf3 100644 --- a/docs/ox_lib/Server/acl/index.html +++ b/docs/ox_lib/Server/acl/index.html @@ -5,14 +5,14 @@ Permissions | Overextended - +

Permissions

Wrapper around the built-in ACL system. Handles lib.addCommand and ox_groups permissions.
Refer to Basic Aces & Principals overview/guide for more information.

lib.addAce​

Assigns the ace permission to a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.

-- principal: string
-- ace: string
-- allow: boolean
lib.addAce(principal, ace, allow)

lib.addAce('group.admin', 'command.say')

lib.removeAce​

Removes the ace permission from a principal. Third parameter defaults to 'allow', while false sets the permission to 'deny'.

-- principal: string
-- ace: string
-- allow: boolean
lib.removeAce(principal, ace, allow)

lib.removeAce('group.admin', 'command.say')

lib.addPrincipal​

Assigns a principal to a parent principal. Children inherit permissions from the parent.

-- child: string
-- parent: string
lib.addPrincipal(child, parent)

lib.addPrincipal('player.1', 'group.moderator')

lib.removePrincipal​

Removes a principal from a parent principal.

-- child: string
-- parent: string
lib.removePrincipal(child, parent)

lib.removePrincipal('player.1', 'group.moderator')
- + \ No newline at end of file diff --git a/docs/ox_lib/Server/addCommand/index.html b/docs/ox_lib/Server/addCommand/index.html index 625a7ad4..ab391175 100644 --- a/docs/ox_lib/Server/addCommand/index.html +++ b/docs/ox_lib/Server/addCommand/index.html @@ -5,13 +5,13 @@ Command | Overextended - +

Command

-- principal: string or false
-- command: string
-- callback: function
-- parameters: table (optional)
-- help: string (optional)
lib.addCommand(principal, command, callback, parameters, help)

lib.addCommand('group.admin', {'additem', 'giveitem'}, function(source, args)
args.item = Items(args.item)
if args.item and args.count > 0 then
Inventory.AddItem(args.target, args.item.name, args.count, args.metatype)
end
end, {'target:number', 'item:string', 'count:number', 'metatype:?string'})
- + \ No newline at end of file diff --git a/docs/ox_lib/Server/callback/index.html b/docs/ox_lib/Server/callback/index.html index b026ad71..29deb679 100644 --- a/docs/ox_lib/Server/callback/index.html +++ b/docs/ox_lib/Server/callback/index.html @@ -5,13 +5,13 @@ Callbacks | Overextended - +

Callbacks

lib.callback.register​

-- name: string
-- cb: function
lib.callback.register(name, cb)

lib.callback.register('ox_inventory:getItemCount', function(source, item, metadata, target)
local inventory = target and Inventory(target) or Inventory(source)
return (inventory and Inventory.GetItem(inventory, item, metadata, true)) or 0
end)
- + \ No newline at end of file diff --git a/docs/ox_lib/Server/logger/index.html b/docs/ox_lib/Server/logger/index.html index c620c696..7ba208a7 100644 --- a/docs/ox_lib/Server/logger/index.html +++ b/docs/ox_lib/Server/logger/index.html @@ -5,7 +5,7 @@ Logger | Overextended - + @@ -14,7 +14,7 @@ Modify your server.cfg with the newly generated API key and intake server.

  • datadoghq.com
  • us3.datadoghq.com
  • us5.datadoghq.com
  • datadoghq.eu
set datadog:key "yourapikey"
set datadog:site "datadoghq.com"
-- source: string | number
-- event: string
-- message: string
-- ...: string
lib.logger(source, event, message, ...)

Source is passed to ddsource and creates a tag. Could be playerId, identifier, -1, or server.
Event is passed to ddservice and displays in the logs list.
Additional arguments are converted into tags for additional filtering and search options.

local vehicle = Ox.CreateVehicle(false, `sultanrs`, vec(-56.479122, -1116.870362, 26.432250, 0.000030517578))
lib.logger(-1, 'CreateVehicle', json.encode(vehicle))

image

image

- + \ No newline at end of file diff --git a/docs/ox_lib/Server/version/index.html b/docs/ox_lib/Server/version/index.html index da622f22..e634e6e3 100644 --- a/docs/ox_lib/Server/version/index.html +++ b/docs/ox_lib/Server/version/index.html @@ -5,13 +5,13 @@ Version check | Overextended - +
- + \ No newline at end of file diff --git a/docs/ox_lib/Shared/locale/index.html b/docs/ox_lib/Shared/locale/index.html index 2a0d62d9..556ea110 100644 --- a/docs/ox_lib/Shared/locale/index.html +++ b/docs/ox_lib/Shared/locale/index.html @@ -5,14 +5,14 @@ Localisation | Overextended - +

Localisation

Allows players to set a preferred language and attempt to load locale files in any resources using the module.
Locale files should use the ISO Language Code and be saved as ./locales/langcode.json

Players can use setlocale [langcode], and admins can use serverlocale [langcode] to change the loaded file.

-- str: string
-- ...: string | number
locale(str, ...)

Additional arguments can be sent to format the locale output.

-- Load the locale module
lib.locale()

SetInterval(function()
print(locale('grand_theft_auto'))
print(locale('suspect_sex', locale('male')))
end, 5000)
locales/en-US.json
{
"grand_theft_auto": "grand theft auto",
"male": "male",
"female": "female",
"suspect_sex": "suspect is %s",
}
locales/fr-FR.json
{
"grand_theft_auto": "vol de voiture",
"male": "homme",
"female": "femme",
"suspect_sex": "le suspect est %s",
}
fxmanifest.lua
files {
'locales/*.json'
}
- + \ No newline at end of file diff --git a/docs/ox_lib/Shared/version/index.html b/docs/ox_lib/Shared/version/index.html index 5c9464fc..f10e3723 100644 --- a/docs/ox_lib/Shared/version/index.html +++ b/docs/ox_lib/Shared/version/index.html @@ -5,13 +5,13 @@ Dependency version | Overextended - +

Dependency version

lib.checkDependency​

Check if a resource is using a specified version or higher, allowing for compatibility checks or throwing errors.

-- repository: string
-- version: string
lib.checkDependency(repository, version)

if not lib.checkDependency('ox_lib', '1.5.0') then error() end
- + \ No newline at end of file diff --git a/docs/ox_lib/index.html b/docs/ox_lib/index.html index fcb92d41..f84f3630 100644 --- a/docs/ox_lib/index.html +++ b/docs/ox_lib/index.html @@ -5,7 +5,7 @@ Getting Started | Overextended - + @@ -15,7 +15,7 @@ a shared_script in your fxmanifest.lua file.

shared_scripts {
'@ox_lib/init.lua'
}

Or if the library is the only shared script you use you can do:

shared_script '@ox_lib/init.lua'

That's it!
You can now use the library functions inside of your resource, check the rest of the documentation to see how to utilise them.

- + \ No newline at end of file diff --git a/docs/oxmysql/Getting Started/benchmark/index.html b/docs/oxmysql/Getting Started/benchmark/index.html index 2b9bf549..a5aab3cb 100644 --- a/docs/oxmysql/Getting Started/benchmark/index.html +++ b/docs/oxmysql/Getting Started/benchmark/index.html @@ -5,13 +5,13 @@ Benchmark | Overextended - +

Benchmark

Internal benchmark

Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)

Round-trip-time for exports

Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries)

Lua (5.4)​

local val = 10000
RegisterCommand('luasync', function()
local queryTimesLocal = {}
local result
MySQL.prepare.await('SELECT identifier from users WHERE lastname = ?', {'Linden'})

for i=1, val do
local time = os.nanotime()
local r = MySQL.prepare.await('SELECT identifier from users WHERE lastname = ?', {'Linden'})
queryTimesLocal[#queryTimesLocal+1] = (os.nanotime() - time) / 1000000
if i==1 then result = r end
end

local queryMsLow, queryMsSum = 1000, 0

for _, v in pairs(queryTimesLocal) do queryMsSum = queryMsSum + v end
for _, v in pairs(queryTimesLocal) do
if v < queryMsLow then queryMsLow = v end
end

local averageQueryTime = queryMsSum / #queryTimesLocal
print(json.encode(result))
print('Low: '.. queryMsLow ..'ms | Avg: '..averageQueryTime..'ms | Total: '..queryMsSum..'ms ('..#queryTimesLocal..' queries)')
end)

JavaScript​

const val = 10000
RegisterCommand('jssync', async() => {
const queryTimesLocal = [];
let result
await exports.oxmysql.prepare_async('SELECT identifier from users WHERE lastname = ?', ['Linden'])

for(let i=0; i < val; i++) {
const startTime = process.hrtime()
const r = await exports.oxmysql.prepare_async('SELECT identifier from users WHERE lastname = ?', ['Linden'])
queryTimesLocal.push(process.hrtime(startTime)[1] / 1000000)
if (i === 0) result = r
}

const queryMsSum = queryTimesLocal.reduce((a, b) => a + b, 0)
const queryMsLow = queryTimesLocal.sort((a, b) => a - b)[0]
const averageQueryTime = queryMsSum / queryTimesLocal.length

console.log(result)
console.log('Low: '+ queryMsLow +'ms | Avg: '+averageQueryTime+'ms | Total: '+queryMsSum+'ms ('+queryTimesLocal.length+' queries)')
})
- + \ No newline at end of file diff --git a/docs/oxmysql/Getting Started/issues/index.html b/docs/oxmysql/Getting Started/issues/index.html index 048bc2d5..a8606822 100644 --- a/docs/oxmysql/Getting Started/issues/index.html +++ b/docs/oxmysql/Getting Started/issues/index.html @@ -5,14 +5,14 @@ Common Issues | Overextended - +

Common Issues

Unable to establish a connection​

This is usually the result of incorrect database settings or your password containing reserved characters (; , / ? : @ & = + $ #).

Solution

Ensure you have entered the correct database settings in the mysql_connection_string convar.
You can try using the semicolon-separated format if your password contains reserved characters.

No such export ... in resource oxmysql​

Typically the result of failing to follow instructions.

Solution

Download the latest release build (not source) of oxmysql, and ensure it is starting before any resources that require it.

- + \ No newline at end of file diff --git a/docs/oxmysql/Getting Started/placeholders/index.html b/docs/oxmysql/Getting Started/placeholders/index.html index 1fe301cb..77efc97c 100644 --- a/docs/oxmysql/Getting Started/placeholders/index.html +++ b/docs/oxmysql/Getting Started/placeholders/index.html @@ -5,13 +5,13 @@ Placeholders | Overextended - +

Placeholders

This allows queries to be properly prepared and escaped; the following lines are equivalent.

"SELECT group FROM users WHERE identifier = ?", {identifier}
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}

Named placeholders are deprecated and should be avoided as much as possible.

- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/index.html b/docs/oxmysql/Usage/index.html index 8d471f68..2b095a0b 100644 --- a/docs/oxmysql/Usage/index.html +++ b/docs/oxmysql/Usage/index.html @@ -5,13 +5,13 @@ Usage | Overextended - +

Usage

-- Lua
MySQL.query('SELECT * from users WHERE identifier = ?', {identifier}, function(result)
-- callback response
-- same as MySQL.Async.fetchAll
end)
CreateThread(function()
local result = MySQL.query.await('SELECT * from users WHERE identifier = ?', {identifier})
-- await a promise to resolve
-- same as MySQL.Sync.fetchAll
end)
// JS
exports.oxmysql.query('SELECT * from users WHERE identifier = ?', [identifier], (result) => {
// callback response
})(async () => {
const result = await exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier]);
// await a promise to resolve
})();
exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier]).then((result) => {
// utilise .then to resolve a promise like a callback
});
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/insert/index.html b/docs/oxmysql/Usage/insert/index.html index 25bc51cc..b8dfb9d1 100644 --- a/docs/oxmysql/Usage/insert/index.html +++ b/docs/oxmysql/Usage/insert/index.html @@ -5,13 +5,13 @@ Insert | Overextended - +

Insert

Inserts a new entry into the database and returns the insert id for the row, if valid.

Lua​

Callback​

-- Alias: exports.oxmysql:insert
-- Alias: MySQL.Async.insert
MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName}, function(id)
print(id)
end)

Promise​

-- Alias: exports.oxmysql:insert_async
-- Alias: MySQL.Sync.insert
CreateThread(function()
local id = MySQL.insert.await('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName})
print(id)
end)

JavaScript​

Callback​

exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', [playerIdentifier, firstName, lastName], function(id) {
console.log(id)
})

Promise​

(async () => {
const id = exports.oxmysql.insert_async('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)',
[playerIdentifier, firstName, lastName]) {
console.log(id)
})()
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/prepare/index.html b/docs/oxmysql/Usage/prepare/index.html index 2a3fce7d..19dbae55 100644 --- a/docs/oxmysql/Usage/prepare/index.html +++ b/docs/oxmysql/Usage/prepare/index.html @@ -5,14 +5,14 @@ Prepare | Overextended - +

Prepare

The only function that provides true prepared statements, granting native protection and query planning by MySQL.
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.

  • Date will not return the datestring commonly used in FiveM
  • TINYINT 1 and BIT will not return a boolean
  • You can only use ? value placeholders, ?? column placeholders and named placeholders will throw an error

When using SELECT, the return value will match query, single, or scalar depending on the number of columns and rows selected.

Lua​

Callback​

-- Alias: exports.oxmysql:prepare
-- Alias: MySQL.Async.prepare

MySQL.prepare('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
end)

Promise​

-- Alias: exports.oxmysql:prepare_async
-- Alias: MySQL.Sync.prepare

CreateThread(function()
local result = MySQL.prepare.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
end)

JavaScript​

Callback​

exports.oxmysql.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
})

Promise​

(async () => {
const result = await exports.oxmysql.prepare_async('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
})()
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/query/index.html b/docs/oxmysql/Usage/query/index.html index 119980be..2f3d9f8c 100644 --- a/docs/oxmysql/Usage/query/index.html +++ b/docs/oxmysql/Usage/query/index.html @@ -5,14 +5,14 @@ Query | Overextended - +

Query

Generic function that can be utilised for any query.
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.

Lua​

Callback​

-- Alias: exports.oxmysql:query
-- Alias: MySQL.Async.query

MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
end)

Promise​

-- Alias: exports.oxmysql:query_async
-- Alias: MySQL.Sync.query

CreateThread(function()
local result = MySQL.query.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
end)

JavaScript​

Callback​

exports.oxmysql.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
})

Promise​

(async () => {
const result = await exports.oxmysql.query_async('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
})()
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/scalar/index.html b/docs/oxmysql/Usage/scalar/index.html index beac3f17..0258c0f1 100644 --- a/docs/oxmysql/Usage/scalar/index.html +++ b/docs/oxmysql/Usage/scalar/index.html @@ -5,13 +5,13 @@ Scalar | Overextended - +

Scalar

Returns the first column for a single row.

Lua​

Callback​

-- Alias: exports.oxmysql:scalar
-- Alias: MySQL.Async.fetchScalar

MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}, function(firstname)
print(firstname)
end)

Promise​

-- Alias: exports.oxmysql:scalar_async
-- Alias: MySQL.Sync.fetchScalar

CreateThread(function()
local firstname = MySQL.scalar.await('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
print(firstname)
end)

JavaScript​

Callback​

exports.oxmysql.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier], function(firstname) {
console.log(firstname)
})

Promise​

(async () => {
const firstname = await exports.oxmysql.scalar_async('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier]) {
console.log(firstname)
})()
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/single/index.html b/docs/oxmysql/Usage/single/index.html index 352d6463..35f04e57 100644 --- a/docs/oxmysql/Usage/single/index.html +++ b/docs/oxmysql/Usage/single/index.html @@ -5,13 +5,13 @@ Single | Overextended - +

Single

Returns the columns for a single row.

Lua​

Callback​

-- Alias: exports.oxmysql:single
-- Alias: MySQL.Async.fetchSingle

MySQL.single('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
if result then
print(result.identifier, result.firstname, result.lastname)
end
end)

Promise​

-- Alias: exports.oxmysql:single_async
-- Alias: MySQL.Sync.fetchSingle

CreateThread(function()
local result = MySQL.single.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if result then
print(result.identifier, result.firstname, result.lastname)
end
end)

JavaScript​

Callback​

exports.oxmysql.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
if (result)
console.log(result.identifier, result.firstname, result.lastname)
})

Promise​

setImmediate(async () => {
const result = await exports.oxmysql.single_async('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
if (result)
console.log(result.identifier, result.firstname, result.lastname)
})
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/transaction/index.html b/docs/oxmysql/Usage/transaction/index.html index 91dabf11..422fe186 100644 --- a/docs/oxmysql/Usage/transaction/index.html +++ b/docs/oxmysql/Usage/transaction/index.html @@ -5,14 +5,14 @@ Transaction | Overextended - +

Transaction

Transactions​

A transaction executes multiple queries and commits them only if all succeed. If one fails, none of the queries are committed. The return value is a boolean, which is the result of the transaction.

Specific Format​

When using the Specific format you must pass one parameter to the oxmysql export. In this case, the queries parameter contains your queries and the SQL variables unique to each query.

This is useful for transactions where the queries do not share many SQL variables.

Usage​

Lua​

local queries = {
{ query = 'INSERT INTO `test` (id) VALUES (:someid)', values = { ['someid'] = 1 } },
{ query = 'INSERT INTO `test` (id) VALUES (:someid)', values = { ['someid'] = 2 } }
} -- NOTE, the 'values' tables can be named 'parameters' here for MySQL-Async compatibility.

-- Async
-- Alias: exports.oxmysql:transaction
-- Alias: MySQL.Async.transaction
MySQL.transaction(queries, function(result)
print(result)
end)

-- Sync
-- Alias: exports.oxmysql:transaction_async
-- Alias: MySQL.Sync.transaction
local result = MySQL.transaction.await(queries)
print(result)

JavaScript​

const queries = [
{ query = 'INSERT INTO `test` (id) VALUES (:someid)', values = { someid = 1 } },
{ query = 'INSERT INTO `test` (id) VALUES (:someid)', values = { someid = 2 } }
] // NOTE, the 'values' objects can be named 'parameters' here for MySQL-Async compatibility.

// Async
exports.oxmysql.transaction(queries, (result) => {
console.log(result)
})

// Sync
const result = await exports.oxmysql.transactionSync(queries)
console.log(result)

Shared Format​

When using the Shared format you must pass two parameters to the oxmysql export. The queries and the parameters those queries will use.
This is useful if your queries use the same SQL variables.

Lua​

local queries = {
'INSERT INTO `test` (id, name) VALUES (:someid, :somename)',
'SET `name` = :newname IN `test` WHERE `id` = :someid'
}

local parameters = { ['someid'] = 2, ['somename'] = 'John Doe', ['newname'] = 'John Notdoe' }

-- Async
-- Alias: exports.oxmysql:transaction
-- Alias: MySQL.Async.transaction
MySQL.transaction(queries, parameters, function(result)
print(result)
end)

-- Sync
-- Alias: exports.oxmysql:transaction_async
-- Alias: MySQL.Sync.transaction
local result = MySQL.transaction.await(queries, parameters)
print(result)

JavaScript​

const queries = [
'INSERT INTO `test` (id, name) VALUES (:someid, :somename)',
'SET `name` = :newname IN `test` WHERE `id` = :someid'
]

const parameters = { someid = 2, somename = 'John Doe', newname = 'John Notdoe' }

// Async
exports.oxmysql.transaction(queries, parameters, (result) => {
console.log(result)
})

// Sync
const result = await exports.oxmysql.transactionSync(queries, parameters)
console.log(result)

Transaction Isolation Level​

This can be set through the convar mysql_transaction_isolation_level which should be an integer ranging from 1-4. The default convar value set by oxmysql is 2.

Convar ValueResult
1Repeatable Read
2Read Committed
3Read Uncommitted
4Serializable
- + \ No newline at end of file diff --git a/docs/oxmysql/Usage/update/index.html b/docs/oxmysql/Usage/update/index.html index ab29aa5a..4f9d0a3f 100644 --- a/docs/oxmysql/Usage/update/index.html +++ b/docs/oxmysql/Usage/update/index.html @@ -5,13 +5,13 @@ Update | Overextended - +

Update

Returns the number of affected rows by the query.

Lua​

Callback​

-- Alias: exports.oxmysql:update
-- Alias: MySQL.Async.execute

MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier}, function(affectedRows)
if affectedRows then
print(affectedRows)
end
end)

Promise​

-- Alias: exports.oxmysql:update_async
-- Alias: MySQL.Sync.execute

CreateThread(function()
local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier})
if affectedRows then
print(affectedRows)
end
end)

JavaScript​

Callback​

exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
if (affectedRows)
console.log(affectedRows)
})

Promise​

setImmediate(async () => {
const id = exports.oxmysql.update_async('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
if (affectedRows)
console.log(affectedRows)
})
- + \ No newline at end of file diff --git a/docs/oxmysql/index.html b/docs/oxmysql/index.html index 54eec1bc..24c3ca18 100644 --- a/docs/oxmysql/index.html +++ b/docs/oxmysql/index.html @@ -5,7 +5,7 @@ Getting Started | Overextended - + @@ -15,7 +15,7 @@ Reference the following for an idea of how to set your connection options. You must include one of the following lines, adjusted for your connection and database settings.

set mysql_connection_string "mysql://root:12345@localhost/es_extended?charset=utf8mb4"
set mysql_connection_string "user=root;database=es_extended;password=12345;charset=utf8mb4"

Certain special characters are reserved or blocked and may cause issues when used in your password.
For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts.

You can also add the following convars if you require extra information when testing queries.

set mysql_slow_query_warning 150
set mysql_debug true

Using the UI​

Before using the UI first you have to make sure you have the mysql_ui convar set to true:

set mysql_ui true

Also make sure that you have command ace permission access, then you should be able to use the mysql command in game to open up the UI and see your query data.

- + \ No newline at end of file diff --git a/index.html b/index.html index 6fd433c2..0c81c4ef 100644 --- a/index.html +++ b/index.html @@ -5,13 +5,13 @@ Overextended | Overextended - +
ox

Overextended

Official documentation for Overextended resources

- + \ No newline at end of file diff --git a/markdown-page/index.html b/markdown-page/index.html index b8296f56..c1711489 100644 --- a/markdown-page/index.html +++ b/markdown-page/index.html @@ -5,13 +5,13 @@ Markdown page example | Overextended - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file