if not lib then return endplkozsykhdhmfzbxvkobqnvvhdlsqlwfx
wkkhryzikvmrsrx
local Inventory = {}ffuabgaxpjcbxvcgaeskvnbydizda
ckgipptrimyiegkqsozj
---@class OxInventoryPropertiesvqamjjpvelwixqgchywwinlzgtvndzlzqlmzvcvaosiljonqnhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
---@field id any trust me it's less annoying this wayorthhfuqdhmdmqnxanoofjaixrdyhbuvsndatxqxecartno
---@field dbId string|numberewtmxshxeygkhiroujjxvtfwxxltgcilycyvvftaea
---@field label stringovrxpvmuivpsxuz
---@field type stringlwyeqrkqazhwhmuvqtaz
---@field slots numberchgxzdzyxkdfvemoivmknkijxfxxlocnvj
---@field weight numberfdrmbsrvzobkirymokhosvlocdgthtkmwbyytqutewd
---@field maxWeight numbermmcsfryrhhvtojuvryrpctwzjphufhw https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
---@field open? number|falsehdepbitobcz
---@field items table<number, SlotWithItem?>coggzquuorxkjldmswfnrhpfex
---@field set functionszgzefeqrgofyepfhvfssdkxxrfphiwzhcy
---@field get functionhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
---@field minimal functioncffxfhdgfs
---@field time numberhjkgjikvgpcrukscwzhsulmjltjscozjxkpgddbukjcqqwvtgmbdargqaonvaqpuvdszguuqdwgttbnzopcpg
---@field owner? string|number|booleanowwrvctrqedoyfxaxau
---@field groups? table<string, number>rjkvbqntxjkbynasyxjkhwwxspokhttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B
---@field coords? vector3tdmuwqlzactjzxdhzrhcinl
---@field datastore? booleanvjvlfgswcd
---@field changed? booleannrjkguamkgdstzwxzeqsqbbljffwuwghnqsukt
---@field weapon? numbergmaqfuaiyrjdyrhernztfvmtqixdwrjddku
---@field containerSlot? numberajtsggqhaecxyuhpzclcyrjv https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
---@field player? { source: number, ped: number, groups: table, name?: string, sex?: string, dateofbirth?: string }mgyfaibfmozdskuptrlxhhzvqstctwigchl
---@field netid? numberbnyvmusgogxylqdxtjbjwgfkkudqckjdxizkdsrrzoqkf
---@field distance? numberptozjezstegibnrkogtuxgpgrqudclcseqrovqgpvnywbphpwa
---@field openedBy { [number]: true }sjytgywmpljqcjdimvm
---@field currentShop? stringrddploewmrtirjwmtdwowpkam
cjhddafsfzulzastjqbaquznicvkmxzpggtkhzcmyxhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
---@alias inventory OxInventory | table | string | numberfkowclzctjhijfofoypnenrktnrpojewjogppjwdirtzbnirlyfqmwagjsvy
lwhsxccdiiomlzgtnriaagmcucshyhqkdxcaz
---@class OxInventory : OxInventoryPropertiesfsoybbyahfmx
local OxInventory = {}lxjmtvlcjaxmtlxd
OxInventory.__index = OxInventoryppwidjdozswajehdfedwmvniktrklal
https://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
---Open a player's inventory, optionally with a secondary inventory.izytomnwyerithpcy https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
---@param inv? inventorydqnhauddykvxvyqfnb
function OxInventory:openInventory(inv)rdjafgktsjypkvwtpnexoknvejhpghq
if not self?.player then return endhttps://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
dveseptdxbkgrssksiuyngvbnebxvfezbjr
inv = Inventory(inv)qxdejtvayrjekqrvle
lpdojwccujpxblblmkgcben
if not inv then return endblfjneekhdxjxduqkxnpdkvhdcowgdnhotrcyvmfzjp
aselaxwqexepw
inv:set('open', true)mhoqcogpztjjlheosdwr
inv.openedBy[self.id] = truehttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
self.open = inv.iddozyldbnjdwpwa
aqbkucxspodnqohcqsbhpqtjddxxxc
TriggerEvent('ox_inventory:openedInventory', self.id, inv.id)onvzzhskqkthrevojlaw
endekiayhjczmwps
yurrxfsltzzlmkwmnhaodphwguienhjmcb
---Close a player's inventory.mjmabaqgxleyocofipstkjhmzcvhukygtkgulxbjifiw
---@param noEvent? booleandmbwwfvqtuilygcwbvvsqghstjhbsctvouslznbsikeg
function OxInventory:closeInventory(noEvent)zgunhdsnprskdamgmgoivecqjxalqilppfdxivkyncirdvypbm https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
if not self.player then return endooryobxvrxpcbthpxjmopeaxziujilbxatvovtkmrapt
plpuwmmqdyozyrrsgtdhroremz
local inv = self.open and Inventory(self.open)fsyiplokyvmkll
qraizqoclfusbbzriebbuireldvliylwnygcsajgssvfnxsjdqdqhmdrm
if not inv then return endpbahlykdhbsakczqbonz
zxvuycccxervwtnjmjpsbymiwpp
inv.openedBy[self.id] = nilgorhzmpgvsynagacvkgdnrrkpuvvxesetkltwbzstyftegvz
inv:set('open', false)ugqtgzwgpuinghqbowdifyejkanzqqolwffdebjtvs
self.open = falsefidqgzhaoutt
self.currentShop = nilebkwbytwqkjgznyyxcyrgmqnrcrbmocurvrtwyxkotoopzmnblehy
self.containerSlot = nilrcpwzqxqytfwfngxsi
ixzslsmkzvsmzatzfkblnviwqzlggbdoycgkutuuongooaot
if not noEvent thenpkmecjjyumbfgjih
TriggerClientEvent('ox_inventory:closeInventory', self.id, true)hgpxzapynmmdc
endzrptyscmhpkgaqzfkklyvracff
syovzzhzxgnobeuquftdruuepijmzziryxnxwuxubkidodu
TriggerEvent('ox_inventory:closedInventory', self.id, inv.id)fdrmbsrvzobkirymokhosvlocdgthtkmwbyytqutewd
endbvbuvgpruaglnpsrmvbrrjqfireqrbgsximspckkdrv
xgzptoheowvnjqavugralwowhlqbrvlpblevzl
---@alias updateSlot { item: SlotWithItem | { slot: number }, inventory: string|number }yetsmrfgouvngbmwbxltnyofnqueoxwmcqfoikuwepkl
cnrxsolhyzvafxfxrfqoawpggbrnvheyuwvnkgujgqjhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
---Sync a player's inventory state.yjruirnxklsyrafwhctleswkdt
---@param slots updateSlot[]izytomnwyerithpcy https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
---@param weight { left?: number, right?: number } | numbermybiwhcvygrqkhgx
function OxInventory:syncSlotsWithPlayer(slots, weight)qgldndvxafdiieygpi
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)tpwvcycompexztktxhnxfaobzksbkfvdurywqblcqqzqj
endkgtirwiqnfkhih
ygyokbghurdowfzy
---Sync an inventory's state with all player's accessing it.pfsozfybrfwszfqrtfsac
---@param slots updateSlot[]lwhsxccdiiomlzgtnriaagmcucshyhqkdxcaz
---@param weight { left?: number, right?: number }oljdotdpkovqxuyglbjhnnwhybyxghkutuxinbxy
---@param syncOwner? booleanxjchoirhtiwsbqoftctwxtihdsfqobjmkmuzulgoudgvtv
function OxInventory:syncSlotsWithClients(slots, weight, syncOwner)yymbmzczihsp
for playerId in pairs(self.openedBy) doddspjlwpwito
if self.id ~= playerId thenhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
TriggerClientEvent('ox_inventory:updateSlots', playerId, slots, weight)ypdoptwjhokhixwioahuastpijcpgbse https://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
endaphfzuawtclrsnazfruvdyauzshqzn
endgiynokeuwsfqzcxtrucfduevvib
https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
if syncOwner and self.player thenlduwiwoxatmfkh
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)bqgkegsqawvfgfbkqkeixqhvsglxucvwtcgxjznkvjpcormecr
endtlawjvdnuwyskmyjgf
enddhuufbhwbuodzggwvphihdarmgzcmxvqfqkkrrhtlvwlc
oajjiwklemmkmaycjzxsplflq
---@type table<any, OxInventory>bbgvibixfiqkqxgocciwxbnk
local Inventories = {}utnqhcujeztnjcmhvbtixsnpbhwqjvyeoluw
local Vehicles = data 'vehicles'ncecgnybplztsluxpgaonsmkbsw
local RegisteredStashes = {}ubdrsikifkhmoviaozwbyeqgxalwynisomkhuvpa
bxkktrjxipsolldgjmjiomagdtqwplorjzbcrlzaaromd
for _, stash in pairs(data 'stashes') dolslijirynptzhktnerw
RegisteredStashes[stash.name] = {xvnmgjnltyfcfeaajdnxzualrqfyikyffmrmwexpddrjiskrvx
name = stash.name,efxkwbtdexxocxvdhpfmp
label = stash.label,pafwalbanmbsxjplxieavdvssssryc
owner = stash.owner,gszdktutuunuzhburqzetbxmmmzhzpkf
slots = stash.slots,jbcnxygszbwbyzccmrhqwyzbmotjbcflehzbgfufgqgfqjhhttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
maxWeight = stash.weight,dfdmnsnkpdthbqzsufbtmktfyhtfgzmjepw https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
groups = stash.groups or stash.jobs,rixyaktsvupfsrecxzyastevleqf
coords = shared.target and stash.target?.loc or stash.coordsgbdggemqxfnbc
}coggzquuorxkjldmswfnrhpfex
enduvyhnaivvavqwkg
gucogkjvvwbfpabakzxwmuxlhzqr
local GetVehicleNumberPlateText = GetVehicleNumberPlateTextyvplnerctedzuhibkadvcqb
jtrkiafqhtvllwa
---Atempts to lazily load inventory data from the database or create a new player-owned instance for "personal" stashesfodhzwyexuibcn
---@param data tablehttps://pan.baidu.com/s/2U3V4W5X6Y7Z8A9B0C1D
---@param player tablezoadntgskyhdwermftykviushlfihbxhqxkdqrvbpd
---@return OxInventory | false | nileclwtodssrwiatsqazfmgymsvypvhg
local function loadInventoryData(data, player)xtmkyuyscqlxiiuvpzxmypgiaekzwfquydewydpataybhttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
local source = sourceugolguwzyovlhdjyvgmeetahmbntgxladamkvijuxffei
local inventoryblkzjsbezufblrfxasxxcomcfywipkzqwkqfcsjcmody
vqacobfalvotqftikqnnbptzeqzjmnchdcksdpsplgjbm
if not data.type and type(data.id) == 'string' thenfookrvsaqxmcprfdljmuqjjxxojywaicpwmgse
if data.id:find('^glove') thenzrxjqzcudvhvfgcjhbwubrvvmjvliouhfrrvq
data.type = 'glovebox'ziizpfwohnnnaecrorc
elseif data.id:find('^trunk') thenmixkcpyhmkptlszmxnppmfsqdosyjnhvwfgzu
data.type = 'trunk'dpkyxuxfwjoiruegnxpggwdyycxwtgvwwfutaszwcnftijzvhp
elseif data.id:find('^evidence-') thenptdnbbhrdcxxmbld
data.type = 'policeevidence'https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
endzscbjcliuwanwfudw
endmmcsfryrhhvtojuvryrpctwzjphufhwhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
rpstymllamuucmixtjgnhbapfkwnhniycbsbndmoqhisuqp https://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
if data.type == 'trunk' or data.type == 'glovebox' thenqfidudtwsqycis
local plate = data.id:sub(6)nwlpdtkvsgmhokisulwdbskwteljaldohodliogausiidq
ughgcbzrlmothsptngnaaebk
if server.trimplate thenpchseeqswvysrgbtpnc
plate = string.strtrim(plate)iuxvvotnznbotsumqetdtcvxkt
data.id = ('%s%s'):format(data.id:sub(1, 5), plate)uvyhnaivvavqwkg
enduthvkjbzviyf
ftlyhwgpxcourkjgokikwodtkwgoiueonpmvltliwz
inventory = Inventories[data.id]qbhozagrjcqydlmxbktrfavdehfvokmelusluzdectc
todwoikesyimjijmekozsciphagbzfwttapijamcyuohdyt
if not inventory thenepdfyrichhubyaf
local entitydqnhauddykvxvyqfnb
mrsssuokaqiodgxryhbzbjymlahuwnkiecbxxphxgphttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
if data.netid theneglsakptlrshaxtpivnaan
entity = NetworkGetEntityFromNetworkId(data.netid)tekszoerjdwrka
rvwiegrcvloecmlzwftfpkckroyyufllbhufnmii
if not entity thendycshdngptblaqxlzaiaifscuavofsnjqqbytpejjfukvrvvse
return shared.info('Failed to load vehicle inventory data (no entity exists with given netid).')ttdckbgkfgbz
endhimorocpbvihacksmfeojlnvc
elsefsncotyyltlb
local vehicles = GetAllVehicles()ymfjggllmdoeevfxpverfumlt
hpqzfojkqlzuxasqxiylteukglkdxgjfvzfhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
for i = 1, #vehicles doamjfcyokhenhgryyrxjutvhlkflw
local vehicle = vehicles[i]ztxfduvqdicbw
local _plate = GetVehicleNumberPlateText(vehicle)ueogdremlcmhhtmfzgtz
gsmpfzbxtzopdsfmeisxvvlpukanw
if _plate:find(plate) thenfqbrcwossnsnkmkeg
entity = vehiclespuzprqnxsadbymlxmrboqkckasnzevsuqsjh
data.netid = NetworkGetNetworkIdFromEntity(entity)yfgphmnframawopigzhptxwfhwphw
breakjqrraulucheljdgrcmtgb
endwkwgaolnyzcrrt
endsruutlihnlgfqqfstimkctqcuphyj
zcqoideyuwzdsvuagoopuzasmpoxtngspxhya
if not entity thenhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q?pwd=klm1
return shared.info('Failed to load vehicle inventory data (no entity exists with given plate).')zlhljwyvbcwuzvfphxdwdjucaghuptxo
endmijmdkbesqvuzaogrsyljjbfhkjuxsfkaowezy
endxrrjthiuxzjomezeallkmal
yfmbypnwexdaxw
if not source thennmwrrurvdzctuhauwmwjpgukv
source = NetworkGetEntityOwner(entity)oivktekhsi
zrsdxqyvtyqvlpbmbohjv
if not source thenkcebpgjarxfcetqvjltaccqkbuagrybbagcqnmrfkwioqyj
return shared.info('Failed to load vehicle inventory data (entity is unowned).')gsmpfzbxtzopdsfmeisxvvlpukanw
endculrmbgfauc
endctwxgeltwlmfvugwtwzq
https://pan.baidu.com/s/8A9B0C1D2E3F4G5H6I7J
local model, class = lib.callback.await('ox_inventory:getVehicleData', source, data.netid)vmdssazgfsxskosqal
local storage = Vehicles[data.type].models[model] or Vehicles[data.type][class]https://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
eegyuxcaubnygblnuigktqjtkdzu
if Ox thenkeogbilorjqvktb
local vehicle = Ox.GetVehicle(entity)klgkuwzmqikzab
nqrducdduhlbuvnhapikwvaluqf
if vehicle thenxbeswxdefqplwgccyvkkcxplarehyutluoncbrabuockblybblee
inventory = Inventory.Create(vehicle.id or vehicle.plate, plate, data.type, storage[1], 0, storage[2], false)zjwrdlfgqqegmccgdamjavtuspgzol
endgfocfyxfhndilcgerupaerweyn
endnseazesqjiaklvwiptyoetokmgjvatqnluolyhchpcsbxp
fqiqntoafycrfiklcveyguuvrtktusfzjoqwifxn https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
if not inventory thenahslnxlauwaqzhxeyhyvggjufivb
inventory = Inventory.Create(data.id, plate, data.type, storage[1], 0, storage[2], false)cgnactvnhlakzyudzmeuewhhhwgoskfuqtvsmqgtche
endtwtplkyztufjka
endiuprdfxzmdennhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
elseif data.type == 'policeevidence' thenwjkqtofenerkoeydqpmgtgfkmesanjgktr
inventory = Inventory.Create(data.id, locale('police_evidence'), data.type, 100, 0, 100000, false)xkirahfwkzddqkaxxgfguhlu
elsesfxmlphoubmxqpyxztzswlwhufkdjvncblombw
local stash = RegisteredStashes[data.id]serdookulduab
ybxccqmykrk
if stash thenchpojxxummjlgrsdxngungclqynfyfvbmkpwimquya
if stash.jobs then stash.groups = stash.jobs endxitmekdvwzahmbwxrzhuswcnnf
if player and stash.groups and not server.hasGroup(player, stash.groups) then return endqkoezzrcwaopsulalskxdgcxszoau
frkbpeoznccbndshwxcs
local ownerybxccqmykrk
fwkuweegqlkedobvthscgbjncehphpsnm
if stash.owner thendgcdpfhtxubqw
if stash.owner == true thenejondvwqjofleghmoioybaefonqcitd
owner = data.owner or player?.owneroqsisjwyxcyjfnp
elsepriosmswolkyjlpnefqnsdrzkcrcturimawfmobbalhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
owner = stash.owneraqbkucxspodnqohcqsbhpqtjddxxxc
endetmfqyvjgyofdrtiszfmlvkfcwqovaazumelkaur
endedcfvyhaffnvxyquo
tvgrumibxlhykbaxbffjgyzevzrit https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
inventory = Inventories[owner and ('%s:%s'):format(stash.name, owner) or stash.name]oybaobrxicxtclrednjoubxoavg https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
rmcvzccfieagdwtqbcubjxk
if not inventory thenouiacsgxvaawgjdqnouzfeyclpofpd
inventory = Inventory.Create(stash.name, stash.label or stash.name, 'stash', stash.slots, 0, stash.maxWeight, owner, nil, stash.groups)docppaabwdcypnenrktnrpojewjogppjwdirtzbnirlyfqmwagjsvy
endahjojeopyomruvudmeqmfenqecepy
endtbupixlkhlddveue
endbzoroxkvmlasmihgmvi
cszaqxgoxi
if data.netid thenwgwravfknmmdckkvoo
inventory.netid = data.netidypdpkxtgagucfwplmvnoqrtqohkwhbgfrkvbhp 不要乱来哦
endrohdbbsqsjkileeneypmhrsbquzxdwgulnxmp
zelpfgrahrsxgxligvjtr
return inventory or falseppxnmxwomtatlfbtivfa
endrpkvaqytthxsqwztoceejlaxbrxijcpbrawsebyauxxsxuckqvcaarbopbrhyiscpfktgiub
xvipfymupptjtihfknuxybpxqbjgsqvpmdfrbrmqhg
setmetatable(Inventory, {kczszulkjpoqbsuglhgsvimrirszerdpud
__call = function(self, inv, player)oolealyylrp https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
if not inv thendpwbdccxvrjior
return selfayffibxesbmsotixskppuqcysfwfyvh
elseif type(inv) == 'table' thenfozvvozhuvxturjvsmfpoxbabdzuyvzdjz
if inv.items then return inv endsgbpgegyriqqlyxxavwjmbvvvqeiytrqztggx
airmyrocleaqfhqpnrgddxabtotogxlhfdtduifgngwsonhc
return not inv.owner and Inventories[inv.id] or loadInventoryData(inv, player)ukestpfnncwmv
endgvgqkmdeajvwejdhsoahfhxtdxktsfwkfcfzsjwzdpaqopgrfnbluyeyw
xraobyomoxxemdhjmdukrwtizogpq
return Inventories[inv] or loadInventoryData({ id = inv }, player)uksewzjmdfhtuylnchemaqaewrvzqvqkgipdiyplexf
endtcnpwigobctcpsozganubpxkhlqp
})https://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
prbrpuctkmcaladoyqpu
---@cast Inventory +fun(inv: inventory, player?: inventory): OxInventory|false|nilpcqtnxliemjpgmtaplamqsrocbttqdgffwztukbzw
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
---@param inv inventoryjwdffiqnzduksxqknhcaxrazottufcwo
---@param owner? string | numberdbnlddxquxeubztrmvvrvtziqjhcmawqbjcfnzvhxacyav
local function getInventory(inv, owner)caqfxorzzvlbuzsiwdeiofbbnjizernhrdmpreor
if not inv then return Inventory endgvgqkmdeajvwejdhsoah https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local type = type(inv)rpjszvqxeysqklhk
szgzefeqrgofyepfhvfssdkxxrfphiwzhcy
if type == 'table' or type == 'number' thenmqzqbscfwjgmtkkbhypeeltruylcricdzcubuwgqgmdawobemr
return Inventory(inv)yhebynmzuauuozzys
elseegflfbynupvyidjnll
return Inventory({ id = inv, owner = owner })umecobhhctarmiofsdumtxlmchsadzzxmdzbfhihajznsnskr
endnuweyhjeyajfnlhtphgyibsdthjswvsjqoopvyuuydzmoggeomhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
endwqwwstzuhjkzaktmewtjhdnouqb
plpuwmmqdyozyrrsgtdhroremz
exports('Inventory', getInventory)https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
exports('GetInventory', getInventory)rvwiegrcvloecmlzwftfpkckroyyufllbhufnmii
xbeybbunttzgoqycwjca
---@param inv inventoryuojyristxofolchvo
---@param owner? string | numberhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
---@return table?https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
exports('GetInventoryItems', function(inv, owner)sirhtcmkswzcrjukkhreembxpybkfhexqwejzqtsntufcp
return getInventory(inv, owner)?.itemspzyfoqsexghsxbiwpiimwojnvda
end)bvbuvgpruaglnpsrmvbrrjqfireqrbgsximspckkdrv
hqovnbwcimepkjdqrhdaspw
---@param inv inventoryxixorwlwzzgtyklifcyietrxs
---@param slotId numberxigdomwxiutmdlmrsxqreyjgynrq
---@return OxInventory?skckbhgavlzspnhgthpnfjrmcillne
function Inventory.GetContainerFromSlot(inv, slotId)nqrducdduhlbuvnhapikwvaluqf
local inventory = Inventory(inv)libadlkbgdhdbeovkqewphulcaecefnqnorrab
local slotData = inventory and inventory.items[slotId]ziuvabgxvjtscwzafynp
ofejheadkmdnkmmzkeoccwzhovhcsuigznq
if not slotData then return endkoclhqmrzunkf
peyyfukgvyvrsdtkisfuiiykslunnllcpkbuelaajwrbakmjd
local container = Inventory(slotData.metadata.container)yctszlevnfrfejani
lbluckglwumwntssxmvzuoiochifzuh
if not container thenxohmohkgdfyvlpkieqcdfrsghkjmyomvdthrbsyeywzjmkrqau
container = Inventory.Create(slotData.metadata.container, slotData.label, 'container', slotData.metadata.size[1], 0, slotData.metadata.size[2], false)https://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
tlvskqfqyiyxlmanstumdfcwmdlmdmcxyxqiovzmeyk
return containergjbhdlhufdkyqqevp
endnkusearrwjgeynoxzeobiluxy
prlbzakaegaopkmdvnaecovuxpyaywsnoepoeaojgoxw
exports('GetContainerFromSlot', Inventory.GetContainerFromSlot)vdahhdqqjaqixgbvzczfn
hrdttgiffhlxhs
---@param inv? inventorywbubdsjgzkxrouetkfwawqcwnxsvfmrbnlcqemwdwuvlozey
---@param ignoreId? number|falseqqfjkcdeyvxjrxuipzxwuci
function Inventory.CloseAll(inv, ignoreId)kkurgadqcxip https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
if not inv thenvsjddrqpktbowxdyc
for _, data in pairs(Inventories) doeglsakptlrshaxtpivnaan
for playerId in pairs(data.openedBy) dofegptdgxlwmlexbkeam
local playerInv = Inventory(playerId)nvohsudpzgkeromcqmknxfwemijxdtqrpeyhzcwziheaw clyuajcgdmreeztpotzchucwgqbmhyfjkdeknhrrtivxio
bnwjnsbqxvnizibfloeqqqviuq
if playerInv then playerInv:closeInventory(true) endpuzisubizuorz
endnkrahncwrjnjiioyfgjym
endjtulonfcexkjosmcckossgkxvskfolcxewjtkovplgyaykca
哈哈
return TriggerClientEvent('ox_inventory:closeInventory', -1, true)zrsdxqyvtyqvlpbmbohjv
endxddoxiqriptbrziirbsghuzhumuknbflejzcspuaenbwnke
mqdkmaxjjdlykdwmhpqysenczzftzhjlymvkmtuwxf
inv = Inventory(inv) --[[@as OxInventory?]]ejqpjhvmfddaixocaefwctdzwqjnccehlvwudsgiwkie
riaofkjcdbhy
if not inv then return endmrsssuokaqiodgxryhbzbjymlahuwnkiecbxxphxgphttps://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
pgoceephwaijsz
for playerId in pairs(inv.openedBy) dorpdmoebvwuuhddjjlttfrlkbmzyqzxzqmcdbh
local playerInv = Inventory(playerId)yuxguejkdoomtxmerhcuutuknillfpwdjtkdyt
ydmijffcipvkbylltbgudrapqinxh
if playerInv and (not ignoreId or playerId ~= ignoreId) then playerInv:closeInventory() enddwzuvyakipzel
endvzyybaddvadvsicflavscevtvmvrrljmkhlmioqdpuzh
endcvrkdszvtevelpomgmgjrkvagwwzcrzfmqpqjplctghfwvrdhy
https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
---@param inv inventorygmujrrypcvzddbukjcqqwvtgmbdargqaonvaqpuvdszguuqdwgttbnzopcpg
---@param k stringlxfcbzozoqxriwbwy
---@param v anyzgakypppmgxz
function Inventory.Set(inv, k, v)gktjqmnwgodxcblullcepfwmqpgnllssv
inv = Inventory(inv) --[[@as OxInventory]]mfmpclhxmzxrgjnpedcnvgxtxfp
laacbigoejjnnbxnfxcrqdipflxehdnsdnvew
if inv thenhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
if type(v) == 'number' then math.floor(v + 0.5) endgzhidkkeumbdakqrvtgopkxyzathiemoet
wpyamgvwqd
if k == 'open' and v == false thenywuackgorqlwehwfgzkrwnsyyhzzlkck
if inv.type ~= 'player' thenvjvlfgswcd
if inv.player thenjxjgcigcakclxjwu
inv.type = 'player'aqkggizhjq
elseif inv.type == 'drop' and not next(inv.items) and not next(inv.openedBy) thenvdmxwbodhrryveqxsksgcbwymufoo
return Inventory.Remove(inv)wzskgtwmhbhrfiqwtliqcsakgc
elseppxnmxwomtatlfbtivfa
inv.time = os.time()ajknepcsdpdvqkishac
endovrxpvmuivpsxuz
endupsgikwvyxeqkapvoorvajdvsfwvnbbhrun
krvsohzhpgmlfnpmzie
if inv.player thenjvvekbaaroxmlmwuwkjaonxoqcsunxkwtgadibeapbm
inv.containerSlot = nildfansldaxycidbdcsleiwlwkxnmkbmgfsgtlswlpvoxypbbi
endmhwsjmbzsqmcnsvacvmekek
elseif k == 'maxWeight' and v < 10000 thenxcsojcirhlmzpfnmziasqzkargcxhrvfuntdqcvxnhxdmkqmt
v *= 10000prcccwrijfieddujnfbjstufjl
endcfcvphpfalyncehemmhr
pgoceephwaijsz
inv[k] = vvgihadcyucovlrxxsjmizgiagjujldmh
endrtcndtqshvcpdzyatvf
endthktsgsadzwowuvdwofdvhacinsuejkjhaoblvhfiexmjkakmadauthdlzddwnmenafzwmefqbszmt
gcddtdzzonlbqomakaokffcbfhjhepelriolmolabxbslntv
---@param inv inventoryvsrtcldhzy
---@param key stringxvlohgiljlwyezgcesnjxlhssgtleiabdlplsywbkt
function Inventory.Get(inv, key)giwczkdahma
inv = Inventory(inv) --[[@as OxInventory]]dbnlddxquxeubztrmvvrvtziqjhcmawqbjcfnzvhxacyav
if inv thenhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
return inv[key]ijtwvwkqlyvrvsrmllrcrgwm
endoszjghnssqucyailotczlfhenuvbjqjxiihp
endhpmpqbkgzvxuaeufymwsohpgjylqqcdxspnjqxpp
https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
---@param inv inventoryndvrsyzumyzywcvzgj
---@return table items table containing minimal inventory datazyheugtfnixvspcxzxbypgwrqrclzpgynodiuwnifkexagv
local function minimal(inv)nmwrrurvdzctuhauwmwjpgukv
inv = Inventory(inv) --[[@as OxInventory]]cogaqpemdejxxeedhiivfmmrecnueiigxphnemaiq
local inventory, count = {}, 0hfyyebivswkjxbysercrud
for k, v in pairs(inv.items) dohttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G
if v.name and v.count > 0 thenfbyopdwsjnurwuztkrwupbzmrcxbgmqlnpadswvbkp
count += 1fqiqntoafycrfiklcveyguuvrtktusfzjoqwifxn https://pan.baidu.com/s/4V5W6X7Y8Z9A0B1C2D3E?pwd=bcd9
inventory[count] = {dvwxcczjvdzwpysllwlcidweubnzhtulprjrtiapmalbyen
name = v.name,ptozjezstegibnrkogtuxgpgrqudclcseqrovqgpvnywbphpwa
count = v.count,hwmbaudajlkdrmprrpyo
slot = k,ayjacuccazskfgoclttwditsmkcvighieqjhkmj
metadata = next(v.metadata) and v.metadata or nilnwhvxazoochpcxygnuaxsjo
}hdepbitobcz
enddciszerouwqjtlluxmnucylicvlzbpffsnx
endlopsotmxhqjdtfbzgifgebougbrcfzornejcywaf
return inventory不要乱来哦
endyrjjltoislbev
kiredkyyysxfusw
---@param inv inventorymwdiyqjhxrupkwdoqugxpjnsimtchyjtvmb
---@param item tableqhumviihxpfedsybocuqouvdrlbpcvesdzezinhfdm
---@param count numberhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
---@param metadata anyqiragxwftyodwqtclfzolxrkbmjtqunhdfijcepwcdaztt
---@param slot anyiuprdfxzmdennhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G?pwd=hij1
function Inventory.SetSlot(inv, item, count, metadata, slot)oljdotdpkovqxuyglbjhnnwhybyxghkutuxinbxy
inv = Inventory(inv) --[[@as OxInventory]]oajjiwklemmkmaycjzxsplflq
qvyxkpbvazabvjrdeviddlrhiswumw https://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
if not inv then return endihiaooacwmgpnzzsncvgsfacpppipx
fyeyaxxbdzwgxyxohczuwcznbtglsgcxfgwgdthhtdo
local currentSlot = inv.items[slot]gvmdpstftutyiapbzinjiuh
local newCount = currentSlot and currentSlot.count + count or countdmljypxnjdoplzrdzunctni
local newWeight = currentSlot and inv.weight - currentSlot.weight or inv.weightqhyoixucfrrkhqtnfzrnscaiuszvvoqmwoaemvhrmyctpv
https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
if currentSlot and newCount < 1 thensxyrulqjrzjvjjsoamndrkcuzcnabpjtmilht
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, 'ui_removed', currentSlot.count })pkmecjjyumbfgjih
currentSlot = nilmqzsjfcdzwbttjloyesivwomgurgtmffdeymkbpjxrcqanfzs
elsehttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
currentSlot = {name = item.name, label = item.label, weight = item.weight, slot = slot, count = newCount, description = item.description, metadata = metadata, stack = item.stack, close = item.close}kiywxjrycxfzaydxvt
local slotWeight = Inventory.SlotWeight(item, currentSlot)lutqhwbwuooorsdp
currentSlot.weight = slotWeightoszjghnssqucyailotczlfhenuvbjqjxiihp
newWeight += slotWeightxunkiocolbrtseuwkwpeoifoxh
nafupuhcyg
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, count < 0 and 'ui_removed' or 'ui_added', math.abs(count) })apspjttrxmvbizvsdftx
endxebnwjqqvzcdqodnbvssuqecbeplgwkeamrxvioriquyexmgtf
lerwrbhivryvqphybekcdiqwgvatppwa
inv.weight = newWeightgpqunrkqxrtsxqavyyahrbgxyf
inv.items[slot] = currentSlotpjphvkfocfihapnudxczydwhvkjhsweifupbevphaxpamcup
inv.changed = truenwlpdtkvsgmhokisulwdbskwteljaldohodliogausiidq
prbrpuctkmcaladoyqpu
return currentSloteljgmwftsdptvytudn
enduqzqenakubwhgrlwsdswwrwhwlypphq
koqhcvlnjycnylndutxbtiswkwevzecjstqv
local Items = require 'modules.items.server'pkmecjjyumbfgjih
tfxcvxhhwemdiryyvosu
CreateThread(function()zkdqhzoxduiwvsloedgldeetmagnbuwafaqnzhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
Inventory.accounts = server.accountsvdfigihhgtgnahyxujpjpditfxilrcsngxv
TriggerEvent('ox_inventory:loadInventory', Inventory)pwpoxanwrvyzrpamlgfjxpxtoovqdlwthlh
end)pnqwsxrailmrmewjpzritaktf
mixkcpyhmkptlszmxnppmfsqdosyjnhvwfgzu
function Inventory.GetAccountItemCounts(inv)dvljgutowvxbzfjicpgbdfztmcofbrsendotyhhv
inv = Inventory(inv)uojyristxofolchvo
uonycmegmjkafgvtuqhpkwko
if not inv then return enduksewzjmdfhtuylnchemaqaewrvzqvqkgipdiyplexf
kgbcrpvnedtyrctksykntpsgbneavo
local accounts = table.clone(server.accounts)xdgxifntkaru
arbuqgyhmiquwozmlnemrpntwark
for _, v in pairs(inv.items) dopxgwqrkodlizlz
if accounts[v.name] thenggavapnikfkfpkzqvogxves
accounts[v.name] += v.countotwsvrhatgnhvxtkjhoasa
endmsijqbtpjesogqtylnbmrtqckkzgcbboukyklsavwsjcjcb
endtofdohjyrwqpedlobswmpprhjkkcrxulmzobgyayuqoz
ouzbdedctnjxbrespcjnmdghlrrqd
return accountskpvhyejhuaevzffxklgwvzhuaxedhsbrhxzfbimvjrrjxwghh https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
endxvbiqubbkvvuvpdvzhxbsepoffjx
lxjmtvlcjaxmtlxd
---@param item tablesnilumucntiofvlnzmkpufxgnzyekh
---@param slot tabletolsfqnurz
function Inventory.SlotWeight(item, slot, ignoreCount)crbgmywwmbiriqdwyrvaszfgmwivpmisejyrivnux
local weight = ignoreCount and item.weight or item.weight * (slot.count or 1)mphlarhmlkpxfdcjlfazdtahozfoddq
rlkaltrlusdbmgtxb
if not slot.metadata then slot.metadata = {} endixjabmmnjyvnkputdrevhraqzdzbadnibxicjvq
zlcpvipkfzkptbbblgwvuzycrymqgldfwfvsolcu
if item.ammoname and slot.metadata.ammo thenskydaquctzcrdpltkkjq
local ammoWeight = Items(item.ammoname)?.weightjbcnxygszbwbyzccmrhqwyzbmotjbcflehzbgfufgqgfqjhhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
pcvtssarzgxtpfnoavjkfy
if ammoWeight thenwojuloxcnyduesdvfwwibvhtjkiouuxqihltvi
weight += (ammoWeight * slot.metadata.ammo)hjvlnhceitdjyknobwqxqbugfbgteqalzvwm
endgqhkeudupqidmictbnjlg
endycjombfeseidakirssxwgbtca
lmfgrnzezpxgbuhaheqmfcfnifnmhzbsmgzetyisog
if slot.metadata.components thenayjacuccazskfgoclttwditsmkcvighieqjhkmj
for i = #slot.metadata.components, 1, -1 doigzkdfzeccljfrlawyvuzyccsdgnflaorzyvfyah
local componentWeight = Items(slot.metadata.components[i])?.weighttwtplkyztufjka
dmisfjpjtynqpndpsldqxzazrttjkrsoeagkk
if componentWeight thendbnlddxquxeubztrmvvrvtziqjhcmawqbjcfnzvhxacyav
weight += componentWeightdknhrfmftlvyowrismmopr
endcrnxsadewffsgrpmcbtmvqmhgurfvswykjvckzhgenz
endnqozvfcziaraezvjwlltcqnfofaldpfqguqbasajtsjxse
endkgtirwiqnfkhih
yisxbfsdzyitahutamrhdescvnju
if slot.metadata.weight thenkeogbilorjqvktb
weight += ignoreCount and slot.metadata.weight or (slot.metadata.weight * (slot.count or 1))pnwuwokjjnoeeewzcfdekf
endsecefmixvbikgbfmftlefo
wlbvrnvqcepjk
return weightwqjjuzwkymvqkehogthu
endhuohkafdlfnqeqzrvhdlybcrv
smdoswfvlcckuhdbkkxwwdmspocjwx
---@param items tablerfuuccieenjtumovcdpksolgcechkimbnh
function Inventory.CalculateWeight(items)ztuymcvpheemggappatgnaxqnnisbasaumzgpvwwzbjfhjvwjo
local weight = 0ekfuoqnhfkceppqmmcyfsccdmhfsx
for _, v in pairs(items) doeawgeshgerwmazzimcalivnngxvjltgpudwyveezvamwamemohttps://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
local item = Items(v.name)amhmsubugjssjpkpzx
if item thenrvahbsfoppuwwdxkudnwvlzivbdqlaucvv
weight = weight + Inventory.SlotWeight(item, v)https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
endarzjjxkppooowioeciepamtfevasfut
endzoadntgskyhdwermftykviushlfihbxhqxkdqrvbpd
return weightkyzlkjsfcfer
endixjabmmnjyvnkputdrevhraqzdzbadnibxicjvq
tyexviwzrlnphvdichabjkrtejxc
-- This should be handled by frameworks, but sometimes isn't or is exploitable in some way.amgknypmovelpleoatzxum
local activeIdentifiers = {}dydgbifezlqkuytdvzfonyoovpuvzesccvieeojdzzouyhxt
kmoqpbnbeknpehmtvablomrwjzxdbmvmykcnlpppadefl
local function hasActiveInventory(playerId, owner)nyvkvpsdtkjjzktmvfguarbplevhyrj
local activePlayer = activeIdentifiers[owner]https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
bxkktrjxipsolldgjmjiomagdtqwplorjzbcrlzaaromd
if activePlayer thenpmgrjbseypfrxu
local inventory = Inventory(activePlayer)qfidudtwsqycis
eaxnzuxveyshuujhjk
if inventory theniasfxkcitujbzflyipp
local endpoint = GetPlayerEndpoint(activePlayer)jfofgrhiocaykoprtgzgyiuwmbryfsxoxltedbmremppbfgul
itttmrfnlwjgducwtzeobbj
if endpoint thenhttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
DropPlayer(playerId, ("Character identifier '%s' is already active."):format(owner))oqbtdfoqjjdfci
rytzwgrekacuitenkmykbmtrhywxglsyjlxfspkcpmxygb https://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)fiabxlqsicezfdnfbfwumqythmllyk
print(('kicked player.%s (charid is already in use)'):format(playerId), json.encode({tdmuwqlzactjzxdhzrhcinl
oldId = activePlayer,epuvffucduyadkbzfxp https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
newId = playerId,emmfxypkybwvllfswhxzblvcilaemomrazwyx
charid = owner,onwatxicgbmtgjtdhrvdoaigrsqitypillie
endpoint = endpoint,msijqbtpjesogqtylnbmrtqckkzgcbboukyklsavwsjcjcb
playerName = GetPlayerName(activePlayer),nskdnfuxfijc
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),kpduuvmmnpuemtvgnaegsuhasgariegsujmofzbtpw
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
}, {xixorwlwzzgtyklifcyietrxs
indent = true,ksvpewrqfufmqjt
sort_keys = truekywdynimlfxoqwzticzudhe
}))jnwlspmejicjcwd
jiqaflzwfgeevq
return truethulfvtpluipieuwjbskicxpobfdxbtqiocojwevqmk
endxrcjvgbblsdbsldwpuyfixqgqy
ksvpewrqfufmqjt
Inventory.CloseAll(inventory)djqywvpvhjmewuifxqqngvp
db.savePlayer(owner, json.encode(inventory:minimal()))apudczqgtqqavjgugvvwuzzfxiqn
Inventory.Remove(inventory)ibmruvgyexrbc
Wait(1000)nwhvxazoochpcxygnuaxsjo
endhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
endrtlgdtwoitrojpueazfhlbdkpzisejivduchnyvvsmk
mzqifztvpdgwopefpryewbmqyoqilmexmvgruzmjctgqikw
activeIdentifiers[owner] = playerIdgorvabalenuslszezwjipbwwqjsxxrrdgizhjztonngyg
endofejheadkmdnkmmzkeoccwzhovhcsuigznq
https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
---Manually clear an inventory state tied to the given identifier.kpduuvmmnpuemtvgnaegsuhasgariegsujmofzbtpw
---Temporary workaround until somebody actually gives me info.rpdmoebvwuuhddjjlttfrlkbmzyqzxzqmcdbh
RegisterCommand('clearActiveIdentifier', function(source, args)pxlojnwfuqxlqgoapfz
---Server console only.itebfblwytdutmmqwtrqnmfwemxf
if source ~= 0 then return endsxbtoifzsvxyyahkfijjcjqqiwflavbssclhlrhdnec
vkumqxtnxvieccbbogknorcpfc
local activePlayer = activeIdentifiers[args[1]] or activeIdentifiers[tonumber(args[1])]onuexuzxmqwzvrczm
local inventory = activePlayer and Inventory(activePlayer)nfgdwhidnbenvpopruoxpqzouybdcjcqojtlqboedssyignabc
xigdomwxiutmdlmrsxqreyjgynrq
if not inventory then return endvludamxnsuwowchgvlksdsputdhwizfdkzhll
xbdvmrblqowpzhiehphjdgflauohmnakodfbvgnmvkbur
local endpoint = GetPlayerEndpoint(activePlayer)lpklhlnxjtvfworrxtblgdrqtj
ibnaykrepcuguhqgoqxgwzqloyowqwtyxhywrqahsvnncetr
if endpoint thenidcaxqwrlkdymxfmmgqrfdcjl
DropPlayer(activePlayer, 'Kicked')naaxgywynkecd
krbysdkwosutqshhbqdlicwo
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)ryhnvjyhikwsfsttdthm
print(('kicked player.%s (clearActiveIdentifier)'):format(activePlayer), json.encode({iupphabhooyigrklggbajqafiigpskwbfmqm
oldId = activePlayer,pkmecjjyumbfgjih
charid = inventory.owner,https://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
endpoint = endpoint,https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
playerName = GetPlayerName(activePlayer),woibakeqznylnsyyukwiu
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),lbsdwbbwxjjbiprxbzbkxefjmktkybqkcjn
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),rfimocjjxxdlxqmmkfgwvlp
}, {dlpovwngqktghpscnwnmaghvlsuryixbtnp
indent = true,ewtmxshxeygkhiroujjxvtfwxxltgcilycyvvftaea
sort_keys = trueolknyffwpvumloslowvzhpqeklyebwjqhu
}))ssyohnsordacrjfjfjrcsqupdrksoiohanvibowsswujgas
endemzcwsorgbcrerbfmgqmgajxckioulgyxgauyplernww
pafjpjtyglrtetwrzzmexhgnyyntfxouxuendymkjednxzf
Inventory.CloseAll(inventory)hkhpxpomxkjkupniwvmlheb
db.savePlayer(inventory.owner, json.encode(inventory:minimal()))ogjabjinnxozmwbvbkxxa
Inventory.Remove(inventory)sywdbkhwhhclqkporewswd
end, true)fowtyvchncwhvboqxgxpdyfcejmasjuyxqswluezwbgrcu
vdbvxajttubbvbrfmssp
---@param id string|numberpyisbycnvmr
---@param label string|nilwjigegumdrbthgqqjdixciqkzqihjqofzxmd https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
---@param invType stringfhhsiyeddcbzgxfmvat
---@param slots numberfaodupkkmnbofsrzuvqslbnmuieefqclrrolhywtlyhrqzqlu
---@param weight numberfselpbexgzturbzwscqkxhljjjvowqycicnxes
---@param maxWeight numbertjdwyoxqfr
---@param owner string | number | booleantgywpfypqbbnlyiqgfzunvbpaldihaabhyxxdwntxphi
---@param items? tableixczrlsqqeblphnlxcgycgspldalx
---@return OxInventory?snyekpamdzodwnxwydnipoflabmjdphvdgaovbbzaqcwdztbd
--- This should only be utilised internally!ayenimkbuvulpnqlruc
--- To create a stash, please use `exports.ox_inventory:RegisterStash` instead.slnohmhssbpfiqmawvrsodbfftgpaist
function Inventory.Create(id, label, invType, slots, weight, maxWeight, owner, items, groups)https://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
if invType == 'player' and hasActiveInventory(id, owner) then return endkcovobbekwcodwxgjavjywbbrzjjiobtrppfqrkbnnpr
fhbicbimplyiystrszryjuggtqdgpu
local self = {jacvpnfxgckdzvsvrw
id = id,kiqcwtazrvlctszfyonupifkitidmjzwrpzojznavydprcu
label = label or id,swyssqxuwfzwqyvkkbiqsxarsdxq
type = invType,zzbbjdevogfwllslqcrdzoprfaxgf
slots = slots,https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
weight = weight,vqamjjpvelwixqgchywwinlzgtvndzlzqlmzvcvaosiljonqn bqkeztlvdxqjwqvmsacgx
maxWeight = maxWeight or shared.playerweight,uksewzjmdfhtuylnchemaqaewrvzqvqkgipdiyplexf
owner = owner,wetbawamnyxkgalpdkqrzwvavsp
items = type(items) == 'table' and items,tczdlvsqzpvshpdannzhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
open = false,jtofibvpjczenpjodtkzwdwb
set = Inventory.Set,https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
get = Inventory.Get,xzgohvmlltztaiojappyjvwiybqinnplnwzuhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
minimal = minimal,wqehznhpiybrxjameccxmsz
time = os.time(),erryjjhsxtexwsutbvjexxhmmgmmbaygrqebamu
groups = groups,fzjjsjliwstu
openedBy = {},liaauzzonwmoafkkozpipniwwsmfbkg
}szfwgmlxglnpmdsekwn
vfgvjijrnnmznrofppnbfpdjhdrbkcnfiubrdki
if invType == 'drop' or invType == 'temp' thenfoaqyzqkkdzncrkalwyhxhwlxy
self.datastore = truewiqfflqgheysccstxvmwxdamptwzcntzwjfbvvhczgvcio
elsejbchviaelnnbcekihlcizanmvrrzada
self.changed = falseykhxvcvqamwnnepecpuwzacxntxqyfuxq
xnoklgdlvwcnwnzmswvjbrscpgwubmuyaiimpmykibyfoxshun
if invType ~= 'glovebox' and invType ~= 'trunk' thenbvzxiipjirliotrnwvmloaswzwlwxkcyfcw
self.dbId = idhpfurqjawlcailzjrirsvwunx
mizchsxgkodthjygserspemlucxfrpydyyffqdmbrquzz
if invType ~= 'player' and owner and type(owner) ~= 'boolean' thenmshmgbheangahfmpvhfiahmclsgocuxpnfcug
self.id = ('%s:%s'):format(self.id, owner)kjvolbsevggpdevhqpecbkxvrtpnsfkdograhjfcqmstqnbg https://pan.baidu.com/s/8A9B0C1D2E3F4G5H6I7J
enduxwjadrfcmmnjetigfsfmoageotrocfjzbszekfh
elsevhqlaskjhyzdrzfewsysrlfw
if Ox thenhiwbplrjzjuqhljzjaaf
self.dbId = idlaondnzuonqyngzwyzwjnwtrkepaoxacrwrldgn
self.id = (invType == 'glovebox' and 'glove' or invType)..labeljiqaflzwfgeevq
elsexkyfvywcjkybpfvlxcgyczeuyrel
self.dbId = labelrctkvgaocbenszclkcbbixosb
endlslijirynptzhktnerw
endwlbvrnvqcepjk
endmudjpqpwsuosoxbdvzuudfndjqpoefurax
https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
https://pan.baidu.com/s/1L2M3N4O5P6Q7R8S9T0U
if not items thenhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
self.items, self.weight, self.datastore = Inventory.Load(self.dbId, invType, owner)babwawoqwdmm
elseif weight == 0 and next(items) thenzpwapbvtkt
self.weight = Inventory.CalculateWeight(items)gzhidkkeumbdakqrvtgopkxyzathiemoet
endxyaynpqgzbersjqvkxqawjqw
onuexuzxmqwzvrczm
Inventories[self.id] = setmetatable(self, OxInventory)xzgohvmlltztaiojappyjvwiybqinnplnwzu https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
return Inventories[self.id]dlsmuksagafkcixykwmzr
endaodqttaeksldehap
kempqahnwelahjuumkidgewfzhvoulieqvugwcttgftnoo
---@param inv inventorypgoceephwaijsz
function Inventory.Remove(inv)dycshdngptblaqxlzaiaifscuavofsnjqqbytpejjfukvrvvse
inv = Inventory(inv) --[[@as OxInventory]]vcgvrkamgluikzhclimhgvostisjhxrczyyqj
ppwidjdozswajehdfedwmvniktrklal
if inv thenhtncwudamnvzpudythytjdzgjhkpmcftwtwsnztznpz
if inv.type == 'drop' thenlrukkahhqiihnfnmvkwyuymqwuetifdtwxehy
TriggerClientEvent('ox_inventory:removeDrop', -1, inv.id)nvohsudpzgkeromcqmknxfwemijxdtqrpeyhzcwziheaw https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
Inventory.Drops[inv.id] = nilqtxvncqkeyvhihbknnrxikg
elseif inv.player thenapudczqgtqqavjgugvvwuzzfxiqn
activeIdentifiers[inv.owner] = nilkkddeyphdrepupcycevbbmjqijcmhncsygvcekjicoy
endnrmfhpmdlsiwltxidslqnhpgsbecijqvacbisnldg
rhccodhbjtnavloflyvjmsbb
Inventories[inv.id] = niltyxhcvhsabqmemjmawkqozrmtcro
enddduwxkenuayjktjejyptapdgbrtzo
endlahxguonszyojdnmsuojhqkpxdgqyfukf
ycygogumftmpstaeyhdrcechkpsuuhusjsyyztkfnwufqvjpcn
---Update the internal reference to vehicle stashes. Does not trigger a save or update the database.wuxkboprposyrtmgxdosiskpg
---@param oldPlate stringdmbwwfvqtuilygcwbvvsqghstjhbsctvouslznbsikeg
---@param newPlate stringztswpitdyldoj
function Inventory.UpdateVehicle(oldPlate, newPlate)mivynowyjfscmeivlktsardehuajkenxmj
oldPlate = oldPlate:upper()ggavapnikfkfpkzqvogxves
newPlate = newPlate:upper()cxotpsjfzptfwyeyjzgtjwpnfbzkpi
ncudegzaslutnkxqqbscjatwcnjwbjpoljrqpqricmbp
if server.trimplate thensgpyfpooxwtkcxrgzbdaawxrhgxgu
oldPlate = string.strtrim(oldPlate)ranhkzyhhrcaeksfz
newPlate = string.strtrim(newPlate)icdajsfiwvneqswjwhguymjguffcieorhssqkxyh
endyjwkxohrlaqknyjtyfrf
knwgqpdysqfcynxhykmqrviwadhultywg
local trunk = Inventory(('trunk%s'):format(oldPlate))ruagxdyriomkhkd
local glove = Inventory(('glove%s'):format(oldPlate))fhcbbsxwkyruhzspiuwq
roocjvybhkaqhkovsfhtvrhuaatgrynjnbmhttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
if trunk thentolsfqnurz
Inventory.CloseAll(trunk)fekpieutskdmtynxemcutosxhndrvdkaiuqqykkqundol
tjqeuzkwgnawojqdlsdlhynhkkpfxfbroswjrgfytfuipkma
Inventories[trunk.id] = nilukjhozaysvvrsfrowofuzpopaqsdfnf
trunk.label = newPlatehmdpegabumbdcxxphcupttqjswcyqbbxo
trunk.dbId = type(trunk.id) == 'number' and trunk.dbId or newPlatefwdkflnusoyxosjrgpsyhxlllfjsnewtb
trunk.id = ('trunk%s'):format(newPlate)vhqlaskjhyzdrzfewsysrlfw
Inventories[trunk.id] = trunkvfiycznckogtxujfqdjgddujfahbju
endfbyopdwsjnurwuztkrwupbzmrcxbgmqlnpadswvbkp
ttqfevdilucosymvfkectprk
if glove thenhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
Inventory.CloseAll(glove)zscbjcliuwanwfudw
https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
Inventories[glove.id] = nilyrsxnixgwctbggej
glove.label = newPlateadtindmwdvyfbgf
glove.dbId = type(glove.id) == 'number' and glove.dbId or newPlatenskdnfuxfijc
glove.id = ('glove%s'):format(newPlate)tmnodywdhgnwbespasqefrfdyombtbimovb
Inventories[glove.id] = gloverpdmoebvwuuhddjjlttfrlkbmzyqzxzqmcdbh
endyqunpcbkdwcigbajmyyjiullsravyojxfekuglfji
endymfjggllmdoeevfxpverfumlt
yoymmdkljddszeexlhreltpnzasgbrbagamtexeoaiganlxhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
exports('UpdateVehicle', Inventory.UpdateVehicle)seppibhyqkhniqctchwmqugcw
eimsuysbrfszg
function Inventory.Save(inv)ntfddqzsnimbstzilqpftdeojosuyihlcmpgdoyq
inv = Inventory(inv) --[[@as OxInventory]]pgjouxypmmtccycajvwtevqeoialea
aqhgjfhqjpfekldz
if inv thendjjvftdmgawqyfcmfixjjyzgecyjntpqdzl
local items = json.encode(minimal(inv))hbuavcilvghzisgfaoilesaskfoccspjukkpmsai
inv.changed = falsehttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
yytwmlgbdayedyaxelyeh
if inv.player thenbkflhkutnrdnxxwfyvmcbyq
db.savePlayer(inv.owner, items)gypiqnzqgnlyrwyhndkczhbumgy
elsesyopkwanpckhazng
if inv.type == 'trunk' thensodeitritjovbqviribwfgkgorgbc
db.saveTrunk(inv.dbId, items)tdeeqcrqkmnbrwv
elseif inv.type == 'glovebox' thendoudlnbcgoicuulfonnejhjalpelyunb
db.saveGlovebox(inv.dbId, items)qvjujofwtqwnjzcwwgdtcgxxmidgwpfmlpguemrxcnlmnnijum
elsenkusearrwjgeynoxzeobiluxy
db.saveStash(inv.owner, inv.dbId, items)ouiacsgxvaawgjdqnouzfeyclpofpd
endzxvuycccxervwtnjmjpsbymiwpp
endwqehznhpiybrxjameccxmsz
endkhtyrlyvqiuqjxvwzpjfvmhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
endzsfwwhoqjtofgwxqexuryuesmzyxxngxgmuctiuqrfjlkxunytabmqxtcflixyxsu
txtyxotjmwcztfctdhurpiuzqdkplyyfvresf
local function randomItem(loot, items, size)tlvskqfqyiyxlmanstumdfcwmdlmdmcxyxqiovzmeyk
local item = loot[math.random(1, size)]vfccpohiqwzd
for i = 1, #items doxrcjvgbblsdbsldwpuyfixqgqy
if items[i][1] == item[1] thenwpnpghhkvlqeanjwwcswezxhlpo
return randomItem(loot, items, size)ayxbzjzqpfchfidlupjabwqnajslfgwfetgedg
endrvekfakuexxtdtjhzcgyjufskl
endarzjjxkppooowioeciepamtfevasfut
return itemoybaobrxicxtclrednjoubxoavghttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
endxelmlukccjeeulbzbhifclzydpxgyqqwucjgwu
wqehznhpiybrxjameccxmsz
local function randomLoot(loot)ratmivnsrnrgy
local items = {}gjyieerwxalh
https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I
if loot thensdzrvpjqexaphepakkvyfohfwoyokwmcaluvbdmfbmviqkibv
local size = #loothxqsqhtdnzugkdkkq
for i = 1, math.random(0, 3) dohdogtgdshbgxrmwtqnmzehkcylyhbuciyqpsxskeuqcmcy
if i > size then return items endipyppnymhygysmyycox
local item = randomItem(loot, items, size)mwvwtontwpadudunqrhbfivlmexbpyucvqyoemibbjewm
if math.random(1, 100) <= (item[4] or 80) thenctwxgeltwlmfvugwtwzq
local count = math.random(item[2], item[3])dzwrjixxutnfrpapggagpulithkslkooklgtueqoxdtostd
if count > 0 thenglmmsxvevkqrnkzflrdppapynzqdzkyfvksointexkvluu
items[#items+1] = {item[1], count}wqwwstzuhjkzaktmewtjhdnouqb
endypdpkxtgagucfwplmvnoqrtqohkwhbgfrkvbhp https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
endbaeldqtyntlkzfowjygvtzyyxzmajkdk
endhrdttgiffhlxhs
endbqgkegsqawvfgfbkqkeixqhvsglxucvwtcgxjznkvjpcormecr
qtqkcineqwnucmdfgdgviawmtuoaznnqhdakmopchttps://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N
return itemshttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
endbuoslobkfpmqvhixiiprmrshzjllnhdpbrhngixlykct
qxomgnuaoybwjmjkfdxlhudmnmbqpjxggmsn
---@param inv inventoryfisrmlenoelguevsjmlbtgadgwisiwinebfrmkeboph
---@param invType stringmhoqcogpztjjlheosdwr
---@param items? tablevyqgkfduzfkbpxidtabjwndeisxgnwmjud
---@return table returnData, number totalWeight, boolean truetiwxuotbohczidvqdkbcqvmmkpkrckgvtcsnrmpfur
local function generateItems(inv, invType, items)zkapmptixwojxejmcwjzftjibzhdfloewouien
if items == nil thenupdzntmzjtdpqmnehlgpzziapupxkrvfhzeusrtclwsbjfgrqlpbgaurcxupizdnohxomsozkgsctskmdzojaibcgvspuv
if invType == 'dumpster' thenhttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
items = randomLoot(server.dumpsterloot)gjyieerwxalh
elseif invType == 'vehicle' thengfbyozdjejlbb
items = randomLoot(server.vehicleloot)zrmsuvqejegf
endhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
endkbnxzhoqncmdmwylsjkffaqjifqbm
xfjtqjisskbhleazztifv
if not items thenhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
items = {}yoymmdkljddszeexlhreltpnzasgbrbagamtexeoaiganlxhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
endnyvkvpsdtkjjzktmvfguarbplevhyrj
jdvyuhavmclglfpcgsdguagqoxnsjahtddsxkttxve
local returnData, totalWeight = table.create(#items, 0), 0mqidniiufy
for i = 1, #items doletocyncxqzskhxwqbiykdrqsvhqyvljaeycdmebdeunlrk
local v = items[i]wpnpghhkvlqeanjwwcswezxhlpo
local item = Items(v[1])nsasupjjxulyibjsxnaggfqgrgikxpalhbdcrmmohxm
if not item thenvtnetoyholtmebggwvouhyctcfohatfwmtafhzmwkgjohpvel
warn('unable to generate', v[1], 'item does not exist')tpraogietivavgzmcxtqbesbltwyzuttjluxsdcmmxmhdlu
elselkatenjhbkbtwshwmddkufoijodq
local metadata, count = Items.Metadata(inv, item, v[3] or {}, v[2])jtgifiuokeefoemgjvxxjidvkohcmg
local weight = Inventory.SlotWeight(item, {count=count, metadata=metadata})zlmytakmfqjpsqqncx https://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
totalWeight = totalWeight + weightprodkrtwolbieivowpzsabpygywctlvjcknmbgjqskzxt
returnData[i] = {name = item.name, label = item.label, weight = weight, slot = i, count = count, description = item.description, metadata = metadata, stack = item.stack, close = item.close}xpkcnbxvkpykwaulurmbfdtnaxcbma
endtphqcbzdzalpbparurlndzxweupysj
endpijtrnhrfdsphasnewkrsxacqrmcsyc
zyqzgjtvklsiadgmfispxatiidnfhcfgbwgifadqmvymzezenr
return returnData, totalWeight, truefecsgkyoojvooeqqezyktvjizxatrwxwa
endtsqbwawkdrx
qpwxbwyxvqyzfojpowvoverylandsiliyhfz
---@param id string|numberzebmwflwkekj
---@param invType stringrztoizsqlpldiintiqdvcaqbnoct
---@param owner string | number | booleanjehslvtwgwxfcvfleilbzhwluighlflvk
function Inventory.Load(id, invType, owner)revafoloqidekihhjbxspagzwlumx
local datastore, resulthttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
brwlfasemxxtibhzgqbshvooutllvnvxfrikra
if id and invType thenkpkyicugxfguabonlstismkkgafmfmmqbxojajqxowsoygbkzv
if invType == 'dumpster' thenretixhxqzjrxjlfmxugbcunnrghgqf
if server.randomloot thenrknmskmvuryfnmyqlztfwwpbbrexfzpxjdjcnwyinxna
return generateItems(id, invType)gpnjwftnjzlcosgvswzmbs
elsezodunzhuukaxikmuxwiztorqybamyhwyvasjzz
datastore = trueiaaxhgyktdlixfmgrwqmblhzmmycxhtfhudpabatflcc
endoomtixgbcsvgdhwoztsetfgtpkjrlsqahcupzarcsnjwvfkvy
elseif invType == 'trunk' or invType == 'glovebox' thenygrarfnjbxizaklvwkfyyroogpsludctkuuczhlbetbf
result = invType == 'trunk' and db.loadTrunk(id) or db.loadGlovebox(id)orvbmisfuyxngtmvnydqhfzqdwnnbbaqsvrfdkly
hiulldskwmbja
if not result thenkpvhyejhuaevzffxklgwvzhuaxedhsbrhxzfbimvjrrjxwghh https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
if server.randomloot thenljgidulvncrvclnslnxxuwjmri
return generateItems(id, 'vehicle')tczdlvsqzpvshpdannz https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
elsejrtsdpcvkplvlrureebevrpckaaagyspplitbkolaahl
datastore = truexxosbdlspxomjfldnioxy
enddvljgutowvxbzfjicpgbdfztmcofbrsendotyhhv
else result = result[invType] endoapqkoyrtlqepfcwvuogbtzps
elsepgoceephwaijsz
result = db.loadStash(owner or '', id)pbahlykdhbsakczqbonz
endaywmpiifamlchpkquwh
endqwgyxelsugrtlmblhytcyqikqvtcrj
aotngwamhjfstzhyxyglzgyyjhxktlqtajh
local returnData, weight = {}, 0mfgrtlidzm
prodkrtwolbieivowpzsabpygywctlvjcknmbgjqskzxt
if result and type(result) == 'string' thenarzjjxkppooowioeciepamtfevasfut
result = json.decode(result)ndvxwgmshptdotrwwpcjehhgxntc
endwbmpucgvfjdkyzqajrftoieueivdnr
othrxaegxpoqiujtysuawfphyodayx
if result thenjxjgcigcakclxjwu
local ostime = os.time()kjrqhhhpzazzrysjorenwwmjexbkunofxg
feeyokhfzwjqnblxevsrrtenkqdxzxkebpdqakvz
for _, v in pairs(result) dopyfkzpnvhsrcgsenjybje
local item = Items(v.name)tvgfovdythvgywjcxkfppjsrsrye
if item thenmhwsjmbzsqmcnsvacvmekek
v.metadata = Items.CheckMetadata(v.metadata or {}, item, v.name, ostime)xlkjynrqouqnrdrrewynezwdnprgaitxuehsryifs
local slotWeight = Inventory.SlotWeight(item, v)kzhmcbzpnpvpauvsq
weight += slotWeightaqkggizhjq
returnData[v.slot] = {name = item.name, label = item.label, weight = slotWeight, slot = v.slot, count = v.count, description = item.description, metadata = v.metadata, stack = item.stack, close = item.close}xraobyomoxxemdhjmdukrwtizogpq
endgqyfvzpkbmztzdwjmevzorgufubtgmv
endrqaujblohfmdelspty
endhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
orvbmisfuyxngtmvnydqhfzqdwnnbbaqsvrfdkly
return returnData, weight, datastoreyxqrhgtiwnhkwkfgxcfnjmgttfwgetecrutzamhxaphwancxp
endfaodupkkmnbofsrzuvqslbnmuieefqclrrolhywtlyhrqzqlu
igtpmgzuvurxbntdo
local table = lib.tablewroxtzgidearnvxrhkkcpoieujuimc
kgpdixtzqsktbvwhfjfcxywfukoqndnxjdasbusrncloyhwdhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
local function assertMetadata(metadata)https://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
rpunaaqfziovhrliiaypsdctpxsuvpjmeeaeeqkezz
if metadata and type(metadata) ~= 'table' thenmiucjxuzbyccktpjkmxmqlfjaxf
metadata = metadata and { type = metadata or nil }ygmzyojyhfbvpywznlkxcbntsvv
endeyhxnoxgvomifuitx
nxxxwodcnrfstahbqnbclpeqwjciquterrbogeqqrxdcsdllrqcajdtqzlyuuamck
return metadatarbmycxityaweheyftnzvcbydzvjvn
endclbadvqostcinjgdttwcgpenn
ygmzyojyhfbvpywznlkxcbntsvv
---@param inv inventorysmdoswfvlcckuhdbkkxwwdmspocjwx
---@param item table | stringlrofrxrhmwbqaqzpitorbaunpaq
---@param metadata? anyxjtcgkksgikeqivwuyqqhmffnyrsjyjgidionthtbrx
---@param returnsCount? booleannseazesqjiaklvwiptyoetokmgjvatqnluolyhchpcsbxp
---@return table | number | nilgtmbyufjgztlqbyhojfpaguhkivxxwgdqsfonk
function Inventory.GetItem(inv, item, metadata, returnsCount)rxcmkiaqvfismmptgmwazmxpebltigzaecm
if type(item) ~= 'table' then item = Items(item) endpuugcatfkupqwxzziqfwvgabcqktiwpxqkdtlxyvromnmmnhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
oolealyylrp https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
if item thendknhrfmftlvyowrismmopr
item = returnsCount and item or table.clone(item)mqzsjfcdzwbttjloyesivwomgurgtmffdeymkbpjxrcqanfzs
inv = Inventory(inv) --[[@as OxInventory]]gnhwtsoxtngxixswrffgehwv
local count = 0jclsllcbemhawtdbzvrnpsonvqjcjmxtoilztobyajywdb
bnwjnsbqxvnizibfloeqqqviuq
if inv thencnothogjqmqwaojccybwbwooyspkd
local ostime = os.time()fozvvozhuvxturjvsmfpoxbabdzuyvzdjz
metadata = assertMetadata(metadata)skbsixmhzpjxuatqugagppyrolakapqtzr
jtofibvpjczenpjodtkzwdwb
for _, v in pairs(inv.items) dosodeitritjovbqviribwfgkgorgbc
if v.name == item.name and (not metadata or table.contains(v.metadata, metadata)) and not Items.UpdateDurability(inv, v, item, nil, ostime) thenoqbtdfoqjjdfci
count += v.countfcqhxfvlvjm https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
endnvrqtwjvzmihsafyshppdvcnhvhwtqbgls
endlagntlfkecfrfvcjtyrc
endkjhdnjzdjmqyaktujzfzisuagnwousvecci
laeuyallgbhslp
if returnsCount then return count elsevzrqwjtgezigkakmtwqqllor
item.count = countgzhidkkeumbdakqrvtgopkxyzathiemoet
return itemtcjpgoyymiz
endcrnxsadewffsgrpmcbtmvqmhgurfvswykjvckzhgenz
endywivxeunzmoykydskgynsroimqzvreuqbcmyhgmgsbfcaivlou clyuajcgdmreeztpotzchucwgqbmhyfjkdeknhrrtivxio
endyjiqdqrutzwpuzpfmbrszalfimsltvdrfmhiczcwyzltz
exports('GetItem', Inventory.GetItem)eqcqqxsgdrirajwslhbkptpdremptfzywcpnah
zluycpnunptydw
---@param fromInventory anyyvliaiqsvdthecjirpzvegxxuhmkggzfclnctevpio
---@param toInventory anyaweoyfeafdovwuoounvupudnkmkvn
---@param slot1 numberdwzuvyakipzel
---@param slot2 numbersxfxhkkyyudnmnhvlgatxnpkkpqohztaxz
function Inventory.SwapSlots(fromInventory, toInventory, slot1, slot2)bgimvprjnivgqpuou
local fromSlot = fromInventory.items[slot1] and table.clone(fromInventory.items[slot1]) or nilncojeickowyckgdj
local toSlot = toInventory.items[slot2] and table.clone(toInventory.items[slot2]) or nilbgimvprjnivgqpuou
cjcwfeskvgdxqvmjnqxehjivhj
if fromSlot then fromSlot.slot = slot2 endnuweyhjeyajfnlhtphgyibsdthjswvsjqoopvyuuydzmoggeomhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
if toSlot then toSlot.slot = slot1 endyvliaiqsvdthecjirpzvegxxuhmkggzfclnctevpio
ujvtabbkauuoxzzutyvlmgsvwhm
fromInventory.items[slot1], toInventory.items[slot2] = toSlot, fromSlothttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
fromInventory.changed, toInventory.changed = true, truemagzafohnqoxtkkxjhjzgdrtog
rolkvysqvmaftpglpjemhnagievxechwqshlqa
return fromSlot, toSloteljgmwftsdptvytudn
endolsqehjewwavcuftvqugohmmotlsgaevlwlpevthttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
exports('SwapSlots', Inventory.SwapSlots)https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
https://pan.baidu.com/s/3E4F5G6H7I8J9K0L1M2N
hdscyktesmybuzuxsqmnixmvzfejkkarnsumcorvbpx
function Inventory.ContainerWeight(container, metaWeight, playerInventory)uihyjocghshknitktwivflbweyaardzlmhkwvmddfknsthdmem
playerInventory.weight -= container.weightfynvjnmsuwijcihpmkwcsvutbslxzgdffq
container.weight = Items(container.name).weightddspjlwpwito
container.weight += metaWeightczawznehavrtxpqqedfckkjkwsxosuwutwrt
container.metadata.weight = metaWeightefioxewiswabgacmrhgue
playerInventory.weight += container.weightloyuosifrwzxubsrizonmrvdquyentbyiatwscckybisdakl
endplkozsykhdhmfzbxvkobqnvvhdlsqlwfx
ezoaxjcafxzbcpizsfdbzfbfmwugtjlxjz
---@param inv inventorytadgpqbdhjoibvdujxfmexguqjrtavxuw
---@param item table | stringutnqhcujeztnjcmhvbtixsnpbhwqjvyeoluw
---@param count numberlffavkhitjpdiqsweszpmjnehylfthkenq
---@param metadata? tableviqcxnqahacfjyhlplwtsojnwhvdvlvrtmtrakshkunu
function Inventory.SetItem(inv, item, count, metadata)vcheejmrzyphwianaafyjafqtvtzlnghpnl
if type(item) ~= 'table' then item = Items(item) endfodhzwyexuibcn
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
if item and count >= 0 thenxyxuvcrznazigtelfzqqpewrkvybkvei
inv = Inventory(inv) --[[@as OxInventory]]hgkodzrwvybcubjlwjsunqlvfygnjjarqkgtkypgx
erryjjhsxtexwsutbvjexxhmmgmmbaygrqebamu
if inv thenhttps://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
inv.changed = truejtssuwxjzixbjrjywdthwbckmdjbjrxtkqmfnkomsmncdxafloqjfpxybnkwlnfywujthsracxptv
local itemCount = Inventory.GetItem(inv, item.name, metadata, true) --[[@as number]]wxngjntsxu
hymuwoozmgyqzlospnurocprxc
if count > itemCount thenfeuggeklazsgvdsnoiqglquaha
count -= itemCountjdvanogueyxrvkewqlscemucusdnftcpwypkmveruc
return Inventory.AddItem(inv, item.name, count, metadata)biulgxclxmnculpyiuntok
elseif count <= itemCount thenqiragxwftyodwqtclfzolxrkbmjtqunhdfijcepwcdaztt
itemCount -= counthttps://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
return Inventory.RemoveItem(inv, item.name, itemCount, metadata)uaxeljpzccrbraxjppvewohumwfvstmnukrfuhfxkwzb
endgktjqmnwgodxcblullcepfwmqpgnllssv
endnnolpkvbtfhwctdxwqkjrbzazfhlxv https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
endinmaiheyqolpothmrvjophjrrsugvopebbeki
endnoxpvenabadrglsuuryfgxzifcftsaefpbvkgil
exports('SetItem', Inventory.SetItem)igtpmgzuvurxbntdo
snrzjogavizxhslxwkshjhty
---@param inv inventorywgtlnmmpkctanijbuqwysdpdvaygnhqjojvbwh
function Inventory.GetCurrentWeapon(inv)pgoceephwaijsz
inv = Inventory(inv) --[[@as OxInventory]]gktjqmnwgodxcblullcepfwmqpgnllssv
dvauylvbbrnobdzsfjzbccuquggabyfetf
if inv?.player thenruwuhmckzmqmvpsguxrsoacajjrlfiuwcrqke
local weapon = inv.items[inv.weapon]dwxatwwjvjfowhbqcjlrhpbasnsrgklkhjlbfhkbrppnwrhttps://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
ffuabgaxpjcbxvcgaeskvnbydizda
if weapon and Items(weapon.name).weapon thenanadktjnazfglqlddirteevfnhtcoqeo
return weaponbsrovesxfbzyhjf
endseiybsxxwnxnzfq
bxagrdbxxzpchfyljcubxosjmkpxdpwfmwmeanbxmqatwyffba
inv.weapon = niloqnlwzmjzouznynv
endcoopgnoomozxqjfnupvmnuuyqgpiymaaboqicewptwmj
endthulfvtpluipieuwjbskicxpobfdxbtqiocojwevqmk
exports('GetCurrentWeapon', Inventory.GetCurrentWeapon)gnklamjjbcjh
ajlgqzwdsjirrcsxaxjcwyps
---@param inv inventoryqblvrorayuk
---@param slotId numberhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
---@return table? itemgvzmlgyympyypvnfetfmjykfehttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
function Inventory.GetSlot(inv, slotId)fkwdhausbj
inv = Inventory(inv) --[[@as OxInventory]]rkmfwzokhpshjshfjudzsfyckukvhn
local slot = inv and inv.items[slotId]bxagrdbxxzpchfyljcubxosjmkpxdpwfmwmeanbxmqatwyffba
kpduuvmmnpuemtvgnaegsuhasgariegsujmofzbtpw
if slot and not Items.UpdateDurability(inv, slot, Items(slot.name), nil, os.time()) thenfzicodxbolta
return slotjcpzxnzncripygikuuqbhimuyzexjgnsjdsgrrtticj
endncybmgqfbbudfaxnuiaq
endhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
exports('GetSlot', Inventory.GetSlot)uamqfxnwgmwvtwbhpdswxtorgbjubhzwhm
ekiayhjczmwps
---@param inv inventoryoqsisjwyxcyjfnp
---@param slotId numbervzlwlidallwlnwexadbdrollprqbceayemupuyqgjnswjwukav
function Inventory.SetDurability(inv, slotId, durability)loyuosifrwzxubsrizonmrvdquyentbyiatwscckybisdakl
inv = Inventory(inv) --[[@as OxInventory]]epuvffucduyadkbzfxp https://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
local slot = inv and inv.items[slotId]bxkktrjxipsolldgjmjiomagdtqwplorjzbcrlzaaromd
gfocfyxfhndilcgerupaerweyn
if not slot then return endhttps://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
adigmjokarjhsedlrgmleciifjayxpsytbefksqlkatcew
Items.UpdateDurability(inv, slot, Items(slot.name), durability)hiulldskwmbja
jnwlspmejicjcwd
if inv.player and server.syncInventory thenzailinmscledwpbfdsgsbtrwokzwsfhxtdxktsfwkfcfzsjwzdpaqopgrfnbluyeyw
server.syncInventory(inv)othrxaegxpoqiujtysuawfphyodayx
endqvyqbsolqeutq
endghqsrwlqxwbigvatetfantlerrxdzhjfpay
exports('SetDurability', Inventory.SetDurability)zkdqhzoxduiwvsloedgldeetmagnbuwafaqnzyxcyrgmqnrcrbmocurvrtwyxkotoopzmnblehy
hwvznvsaie
local Utils = require 'modules.utils.server'vflpfbkcsakdvnbkkjwusxemxifhjzi
onvzzhskqkthrevojlaw
---@param inv inventoryyfdrfkiinyepwosbdkbcgmynlj
---@param slotId numberweghtlljbajfveuwnid
---@param metadata { [string]: any }iucpvbkrxlutflwxxznztlykbuzezrdhmfxhhiyfutyzfuwctk
function Inventory.SetMetadata(inv, slotId, metadata)hqhyrafxrwhv
inv = Inventory(inv) --[[@as OxInventory]]igjdpnwedczkybwylsmuacdocrlnghfonosdbphfshqr
local slot = inv and inv.items[slotId]dvkdcsiuzqalyddwwijohg
nrpjtdltoiltyhpwltkohttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
if not slot then return endamrcqzlfhmalhkjmwnkchalztmvrgsr
ubxwscizqfyuqqfviaamrkwh
local item = Items(slot.name)xreqjkikohgcebxiymnbiubkd
local imageurl = slot.metadata.imageurlwtlvteblczwpbtoxtlzkxzf
slot.metadata = type(metadata) == 'table' and metadata or { type = metadata or nil }mxxtmjpopbuwewywtvhsnbamtpuollkyjhswrhkgjfdnbbk
inv.changed = trueumecobhhctarmiofsdumtxlmchsadzzxmdzbfhihajznsnskr
eakapbcseyknipvmszhcnmewfxrlgcvlcflshn
if metadata.weight thenpthnndbzicivanmzbrj
inv.weight -= slot.weightkiywxjrycxfzaydxvt
slot.weight = Inventory.SlotWeight(item, slot)mhwsjmbzsqmcnsvacvmekek
inv.weight += slot.weighthttps://pan.baidu.com/s/1T2U3V4W5X6Y7Z8A9B0C
endzgwlavklhuiu
tgkzkvwkeaxnrfhynjqefdloiqyehivaofazawkewhsn
if metadata.durability ~= slot.metadata.durability thennwlpdtkvsgmhokisulwdbskwteljaldohodliogausiidq
Items.UpdateDurability(inv, slot, item, metadata.durability)hsxuxasooyjriktjux
elsemudjndwdhmjv
inv:syncSlotsWithClients({woxxyaqqraxwizujqdzhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
{pbahlykdhbsakczqbonz
item = slot,rtvrmqevbvjusgitwakuaipxbyyxtpnkjjcvagqbcawhttps://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D
inventory = inv.idkgbcrpvnedtyrctksykntpsgbneavo
}https://pan.baidu.com/s/4V5W6X7Y8Z9A0B1C2D3E
}, { left = inv.weight }, true)eoygprslhesnzktvdq
endwjxtfycmucgywlz
vleqcedysrd
if inv.player and server.syncInventory thenfjhdibhvoudjfjjyhxnsidixkirk
server.syncInventory(inv)xvxfmwjckzvefujlsgojcfpwyfhjvresncxzzhbkgxolrx
endkajuiztmkhmamkbsv
https://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
if metadata.imageurl ~= imageurl and Utils.IsValidImageUrl thenatnusdlzqqedpwwyvffdinr
if Utils.IsValidImageUrl(metadata.imageurl) thendyskmuugglzwzphsxtjgiwfiujjugdwj
Utils.DiscordEmbed('Valid image URL', ('Updated item "%s" (%s) with valid url in "%s".\n%s\nid: %s\nowner: %s'):format(metadata.label or slot.label, slot.name, inv.label, metadata.imageurl, inv.id, inv.owner, metadata.imageurl), metadata.imageurl, 65280)fgnwxdcyhtxjualrlwzsvnv
elsexorzorpqosqiutpemktqgl
Utils.DiscordEmbed('Invalid image URL', ('Updated item "%s" (%s) with invalid url in "%s".\n%s\nid: %s\nowner: %s'):format(metadata.label or slot.label, slot.name, inv.label, metadata.imageurl, inv.id, inv.owner, metadata.imageurl), metadata.imageurl, 16711680)yuxclnwrzcfgn
metadata.imageurl = nilpgoceephwaijsz
endothrxaegxpoqiujtysuawfphyodayx
endjcpzxnzncripygikuuqbhimuyzexjgnsjdsgrrtticj
endqxkxzovgngovhgmxhmqvqamcy
usbebxjzycndxpqwigplivyipegeagsvyuaarjzpm
exports('SetMetadata', Inventory.SetMetadata)dhgikauatbxjjxyqtdlgtjgplcgbcvrfcyonyinrkkhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G?pwd=hij1
sxfxhkkyyudnmnhvlgatxnpkkpqohztaxz
---@param inv inventorypnipgbvtismagktuqrcnkzeqflvmiqtyecnk
---@param slots numberleeigdlwjbdepdknbatipftvltiuokbzpfh
function Inventory.SetSlotCount(inv, slots)stpktuomdlkc
inv = Inventory(inv) --[[@as OxInventory]]wzskgtwmhbhrfiqwtliqcsakgc
dwqrljfzewihgvezjnkjhzlfzudwx
if not inv then return endgfzjheycpphlepgprguulzicnwtewuxdzxnhblkqarcfg
if type(slots) ~= 'number' then return enduzthhghhratapnoglczwydvizwiazj
hizbnuiiedgerrjuynyfiwfnexkaujdc
inv.changed = truelrlmecrrsgtynnjtothkahhxgkndbblmswzx
inv.slots = slotsdkfjymucvgoidbpmrtxrpevoyjdrctpgevpdikfdqtmuvbhmv
endhxwmejfefwrenzdahfcvgsikyceyjj
blfjneekhdxjxduqkxnpdkvhdcowgdnhotrcyvmfzjp
exports('SetSlotCount', Inventory.SetSlotCount)xrlolkhsxmwwlpwweebrlzqevoald
dwpkrjeqccmfrxhvcnabrxufhxfwubx
---@param inv inventoryfhbicbimplyiystrszryjuggtqdgpu
---@param maxWeight numbertdeeqcrqkmnbrwv
function Inventory.SetMaxWeight(inv, maxWeight)daoqomakxdbtkounjplgmvngdpuapjwtjkkyxkjvnkoyzil
inv = Inventory(inv) --[[@as OxInventory]]xyxuvcrznazigtelfzqqpewrkvybkvei
fkvlseuvolmwhrihnjagmmoxevbraddfnzqgelc
if not inv then return endpyfkzpnvhsrcgsenjybje
if type(maxWeight) ~= 'number' then return endimdirdqekwixfocowwyyhyunbiffmzfulicclthwpqtvfvjbsi
ebuhjuxbaroiqopvifmexgnx
inv.maxWeight = maxWeighttnrsherhcnkymqhsreoinjva
jtesyvczdz
if inv.player thenimkjbrpzygrlzitgxpknhsiigjsebqajckteciebpvnpegv
TriggerClientEvent('ox_inventory:refreshMaxWeight', inv.id, {inventoryId = inv.id, maxWeight = inv.maxWeight})seppibhyqkhniqctchwmqugcw
endyrxagcsfnbirmmcqsicmvwadluxeqstojqpqtivgje
suqfqofyeccsesrtdmgkpqpannucxxzqspwiebhjdkbictbf
for playerId in pairs(inv.openedBy) dodapxxnjujlycvejgkwpzjdfpoewksiovj
if playerId ~= inv.id thenasnxarqlhetwkmyoogxfcyidgarsexmfpacprtbzxvwhhu
TriggerClientEvent('ox_inventory:refreshMaxWeight', playerId, {inventoryId = inv.id, maxWeight = inv.maxWeight})iedvayugiosqosyowquflvaulvnsdjalndhn
endrfbstcmiaymhfgxlwfmq
endskbsixmhzpjxuatqugagppyrolakapqtzr
endtjdwyoxqfr
ekfuoqnhfkceppqmmcyfsccdmhfsx
exports('SetMaxWeight', Inventory.SetMaxWeight)tzkgecdaybtccipnoggfkguwkgzmtqgnqquvtxwryqtbzi https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
nxtosdmoenfexpnmqhdgwjxouybinssbpmpipb
---@param inv inventorywjxtfycmucgywlz
---@param item table | stringfzicodxbolta
---@param count numberqgldndvxafdiieygpi
---@param metadata? table | stringhdogtgdshbgxrmwtqnmzehkcylyhbuciyqpsxskeuqcmcy
---@param slot? numberkuwvfndpmnzhmxhpwxglwu
---@param cb? fun(success?: boolean, response: string|SlotWithItem|nil)oadtjghtddprpocnzgjxumhdurovdeusfxloethhwxzmlbzkii
---@return boolean? success, string|SlotWithItem|nil responseoznxnxccmbrysltnpgrfsxkgnojrehythlr
function Inventory.AddItem(inv, item, count, metadata, slot, cb)rmcvzccfieagdwtqbcubjxk
if type(item) ~= 'table' then item = Items(item) endrjcmkpxzmfmdakegpwexlpmvohiz
kwibuqdtrnreysltozdxdgzbdoiavymfvvhplki
if not item then return false, 'invalid_item' endsirhtcmkswzcrjukkhreembxpybkfhexqwejzqtsntufcp
https://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
inv = Inventory(inv) --[[@as OxInventory]]qumctvumzhy
lkatenjhbkbtwshwmddkufoijodq
if not inv?.slots then return false, 'invalid_inventory' endhpzhxvcctpwimxqpkfdaayoexezvenzld
racumemkkbwkqhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
local toSlot, slotMetadata, slotCountnpeclutvenavjwvvammgzwiaitwhloqyeubpo ratenyheme
local success, response = falseooryobxvrxpcbthpxjmopeaxziujilbxatvovtkmrapt
count = math.floor(count + 0.5)bzxdougxzebjpbxpsnddjiimnjwhfoohnlk
metadata = assertMetadata(metadata)lrotashgzklglhntnoxdbsbnsgnwtfrexfyxxfdxppebxr
mfmpclhxmzxrgjnpedcnvgxtxfp
if slot thenuabpedfdclihrmcununz
local slotData = inv.items[slot]zwkecgonye
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)etcbitjtnyucsm
pkmecjjyumbfgjih
if not slotData or (item.stack and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata)) thenupsgikwvyxeqkapvoorvajdvsfwvnbbhrun
toSlot = slotfsnnygzqdyjcqxgnramrcfrcwpikmrwsjjghpfy
endwjigegumdrbthgqqjdixciqkzqihjqofzxmdhxewkcnpbobthjqoogfx
enddtryarachlvphlnxvrqgopcfdo
ebgereptnyilhnyzzzjyhkmfhysvbkefmkjep
if not toSlot thenhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
local items = inv.itemsqrpolrcplnzjlcfk
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)xpacdamycifjarfsvy https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
caimqlpucrilbhnuanfejskbyokybseetnr
for i = 1, inv.slots dokrbysdkwosutqshhbqdlicwo
local slotData = items[i]zjxoqjvoncbhttvtkmbkd
pcvtssarzgxtpfnoavjkfy
if item.stack and slotData ~= nil and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata) thenlwrdadpdqxkjjqjpkjrfjreknnfwkwkwsbztfpwvmhttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
toSlot = iidbfxjzveqaqmhdfwrbvrwbyulfhkb https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
breakdhkaucbtnwdbzfhiwkoks
elseif not item.stack and not slotData thenluvvsqvwxsvndnfpvfefltjrokzdlqpxkktdboz
if not toSlot then toSlot = {} endwxorhkuobouryspjjazlimobzshw
xvsbtldybzgsnvrkaxjybzjfuwdtuecszvutg
toSlot[#toSlot + 1] = { slot = i, count = slotCount, metadata = slotMetadata }mxrrofpjrltcqwqaszxntziqikfpbyxowofk
xorzorpqosqiutpemktqgl
if count == slotCount thenrufuotjejvicoihugwhefmompoof
breaknwhvxazoochpcxygnuaxsjo
endzbrhgnvecfboibacxbgkhhwcpnnyojbok
pfyetglkmawadgqpwaqanfcrefxznyhcefhy
count -= 1xzuozypgtmrofpojbnllkywyoftdvgxtgrifqymkkeyqum
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)lspvpzlfoztlhhpkquzqhsvlovdupwabppx
elseif not toSlot and not slotData thenrnafcxispdmdphsnbpqit
toSlot = ickyvtkeiyuwigsgeok
enddwzuvyakipzel
endzpauutlpxvmtacb
endywleeltfkitqyukvevsdjodmwffhhhxgeikjudoemiu
oudltzlstzeljkimoo
if not toSlot then return false, 'inventory_full' endzezvtwybctmnmqfblyfsvorbrcayomdnrd
efrgxwxgsmvratwwcycxudetnmpjnxdrcvyzsvgliccivy
inv.changed = trueeuzenrhrgsfkpscjattwfmacawr
jqtegcurneoxxuzblcqsczhnlsefxkchavlgyfylkmjhhijs
local invokingResource = server.loglevel > 1 and GetInvokingResource()tczdlvsqzpvshpdannzhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
local toSlotType = type(toSlot)ezmywheertqsrmfhvnmvayyhnjyifffkfriczmgrfwjxjpef
dveseptdxbkgrssksiuyngvbnebxvfezbjr
if toSlotType == 'number' thenvidssloopvqmowe
Inventory.SetSlot(inv, item, slotCount, slotMetadata, toSlot)tcotwnmncpcesj
hcqnvvaeboheevlzepsxahlqccdrziuhk
if inv.player and server.syncInventory thentxzshgvptbouykf
server.syncInventory(inv)mojhpowadmigq
endxximskqbwrwudg
oqnlwzmjzouznynv
inv:syncSlotsWithClients({gcjtbrgedi
{vzyybaddvadvsicflavscevtvmvrrljmkhlmioqdpuzh
item = inv.items[toSlot],imkjbrpzygrlzitgxpknhsiigjsebqajckteciebpvnpegv
inventory = inv.idfyucrowtjgxhdfupmgcngatyryar
}ueijpfeogwyhkrm
},dqilokfssrsciqwzruteysrqbiyyaybdhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G
{mxrrofpjrltcqwqaszxntziqikfpbyxowofk
left = inv.weight,https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
right = inv.open and Inventories[inv.open]?.weight or nilidbhytzgwbuajvkdjkyvzdgxzqkrrmizpjgodfuahpbq
}, true)bpwqmfjrtcwwvblwqpznkwfsabsdbee
iwozpmnjxxidmenlkj
if invokingResource thenkrbysdkwosutqshhbqdlicwo
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label))amgknypmovelpleoatzxum
endriaofkjcdbhy
bjtdvfzlpgenxqmthunyekt
success = truebztjoyulcbpputdqyassae
response = inv.items[toSlot]twldyynovnabzdckhiadmxpcklrstqlnnxrmvearsbsrfv
elseif toSlotType == 'table' thenuppkaghyxtgibdphoniifdattcgzklffbvq
local added = 0pytmrlqhbuwonubjmduldfvnybpdfhcvgwhxiyfjsbygwzpjdj
cjhddafsfzulzastjqbaquznicvkmxzpggtkhzcmyxhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
for i = 1, #toSlot dowytbdnwkfeanwkzwcg
local data = toSlot[i]egrmavuklzozflxmvpzvss
added += data.countwdhbyhflyndegjpwbrhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
Inventory.SetSlot(inv, item, data.count, data.metadata, data.slot)ayenimkbuvulpnqlruc
toSlot[i] = { item = inv.items[data.slot], inventory = inv.id }jvvekbaaroxmlmwuwkjaonxoqcsunxkwtgadibeapbm
endryabrbgiiizxjhaopssjlysqezcbgvpytpakrhtzp
xfjtqjisskbhleazztifv
if inv.player and server.syncInventory thenfaodupkkmnbofsrzuvqslbnmuieefqclrrolhywtlyhrqzqlu
server.syncInventory(inv)zjpwtnkefhrzbpzgtftz
endxreqjkikohgcebxiymnbiubkd
ntwocvniagutkixfk
inv:syncSlotsWithClients(toSlot, {wdbegmqpyhr
left = inv.weight,rhccodhbjtnavloflyvjmsbb
right = inv.open and Inventories[inv.open]?.weight or nilkajuiztmkhmamkbsv
}, true)oszjghnssqucyailotczlfhenuvbjqjxiihp
jcadkyxtcxalelaqogjkzfdnfxnsmmvw
if invokingResource thenpgaxmfzgnvgong
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label))mqzqbscfwjgmtkkbhypeeltruylcricdzcubuwgqgmdawobemr
endyntgybnwkvklxffjkqqlgdgepktaptnnggtfihbs
tcjpgoyymiz
for i = 1, #toSlot doycygogumftmpstaeyhdrcechkpsuuhusjsyyztkfnwufqvjpcn
toSlot[i] = toSlot[i].itemqcnytiraxjnxopuxikbu
endfzxqrqcnzsfguhhpkjairucajftg
yctszlevnfrfejani
success = truexdtmqxijvevvpsaxxdvltkfgjsixtmjqpddgalq
response = toSlotxqabsrqaqsabnwpzxqthumtueggprtzpjaqcsh
endfyucrowtjgxhdfupmgcngatyryar
mixkcpyhmkptlszmxnppmfsqdosyjnhvwfgzu
if cb thenzoadntgskyhdwermftykviushlfihbxhqxkdqrvbpd
return cb(success, response)enxermrqvqbv
endwetbawamnyxkgalpdkqrzwvavsp
gbosmuqblmafvde
return success, responsexqabsrqaqsabnwpzxqthumtueggprtzpjaqcsh
endqpfkgjxjieeglqsu
vvfmieftuhriqirjmzsgkdkdngpoqprl
exports('AddItem', Inventory.AddItem)owwrvctrqedoyfxaxau
ipekavgeyunpttp
---@param inv inventoryqupwksdrovtreyvmeiouhrtuswwmhfcxzrtkkxbzsv
---@param search string|number slots|1, count|2tbupixlkhlddveue
---@param items table | stringnqsvaqlquotkaprfwnkdcnbra
---@param metadata? table | stringwdwhwpctwgfgvz
function Inventory.Search(inv, search, items, metadata)lbftjqcvadlwitau
if items thentdmuwqlzactjzxdhzrhcinl
inv = Inventory(inv) --[[@as OxInventory]]ygyokbghurdowfzy
dycshdngptblaqxlzaiaifscuavofsnjqqbytpejjfukvrvvse
if inv thenkhchgoipymajvxxvmkiwhgeksjyduhieol
inv = inv.itemsaweoyfeafdovwuoounvupudnkmkvn
fdgzwhililjbpwfidlwyiedxesxdvffb
if search == 'slots' then search = 1 elseif search == 'count' then search = 2 endhsqxlwhewbotqo
if type(items) == 'string' then items = {items} endhnqcfnhefwea
mitvuktuunpenudvnywtms
metadata = assertMetadata(metadata)rdjafgktsjypkvwtpnexoknvejhpghq
local itemCount = #itemscogaqpemdejxxeedhiivfmmrecnueiigxphnemaiq
local returnData = {}xgxospvbuxqqdsuwuaafglemckvgfgecmcqfsmgnjxdnpyjkz
https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
for i = 1, itemCount doburafnjtzpogepjgujzyvavrqapvplxr
local item = string.lower(items[i])https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
if item:sub(0, 7) == 'weapon_' then item = string.upper(item) endothrxaegxpoqiujtysuawfphyodayx
nkusearrwjgeynoxzeobiluxy
if search == 1 thenljgidulvncrvclnslnxxuwjmri
returnData[item] = {}khchgoipymajvxxvmkiwhgeksjyduhieol
elseif search == 2 thenueijpfeogwyhkrm
returnData[item] = 0dmbwwfvqtuilygcwbvvsqghstjhbsctvouslznbsikeg
endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
txtyxotjmwcztfctdhurpiuzqdkplyyfvresf
for _, v in pairs(inv) dodnumsaedtixyzxntmtpvkhfzzmxxafy
if v.name == item thenzylwiktmxwfosodhfusskhdwmxunzdmycxulioxglcueqxlvse
if not v.metadata then v.metadata = {} endomjzalztyzapflukewyxsm
ecuwhrfiixkowbkngupahdikqscziuhnxcjfu
if not metadata or table.contains(v.metadata, metadata) thenpikpbyrtekji
if search == 1 thenhemcxewltqcojdkrrvjlopapeimztpgbutdr
returnData[item][#returnData[item]+1] = inv[v.slot]avtezbxqkqazm
elseif search == 2 thenwberikfdodwvyduvnw
returnData[item] += v.counttfqdznqpwr
endjhzluccupwpyqmswtcnidsdiaooikveuddfygiswfiuvunro
endeaxnzuxveyshuujhjk
endzrbwyikxgxqmufhszlgcksmtxqhv
endzluycpnunptydw
endamhmsubugjssjpkpzx
wlmlhxlnmfcyqngvdjabbjeirykqzqxvcjh
if next(returnData) then return itemCount == 1 and returnData[items[1]] or returnData endsptrenqrmdnxbldud
enddrluqfvuebnhumvijgfnuydxyvnfqzltqxn
endhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
hmbyziqemjtujmio
return falseglmmsxvevkqrnkzflrdppapynzqdzkyfvksointexkvluu
endpvrdcohwdqogjcpskwr
exports('Search', Inventory.Search)mirgjjffmslfavfwcuxqgccqjmxkdzhpiyvribxuujavegrh
nsirmjhirtnvyzipxenbpzplumhcjelxxtokd
---@param inv inventoryrfuuccieenjtumovcdpksolgcechkimbnh
---@param item table | stringiybdvwdcrtcfyvmirkhaenazmusvgkyp
---@param metadata? tableezgqolhdjxdvlhekyoh
function Inventory.GetItemSlots(inv, item, metadata)rbetzrfmqmlfxqmhze
inv = Inventory(inv) --[[@as OxInventory]]rtlgdtwoitrojpueazfhlbdkpzisejivduchnyvvsmk
krvsohzhpgmlfnpmzie
if not inv?.slots then return endqziguaqxoovdb
ujerjuzgumjrbrcamtsbqgwrnvtm
local totalCount, slots, emptySlots = 0, {}, inv.slotsrtvrmqevbvjusgitwakuaipxbyyxtpnkjjcvagqbcawhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G
cnothogjqmqwaojccybwbwooyspkd
for k, v in pairs(inv.items) dolvlgwtxqvzbquvmjzhjhf
emptySlots -= 1kblbjafjuwkesqghbzwztnznhhrtguwdiihwjmvgzzmpbepoxanqonevuw
if v.name == item.name thenhtjwytinjcnen
if metadata and v.metadata == nil thenpeyyfukgvyvrsdtkisfuiiykslunnllcpkbuelaajwrbakmjd
v.metadata = {}qutmnksewtuxu
endlivggkumnotxmawrhcbbxhdyufgukbmwjhcqswdglwex
if not metadata or table.matches(v.metadata, metadata) thenwyiehomllzhkmetbprmwvvtpbgonpewmcfqkthttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
totalCount = totalCount + v.countwxngjntsxu
slots[k] = v.countikarhioxhxpegbk
endsyopkwanpckhazng
endkiurvgmgigxsewtlfxyumlcrgxjbc
endbabwawoqwdmm
chuawjwmdslhknkgwpkkyokycfwjdqqfylgv
return slots, totalCount, emptySlotskovxxlwperiqijfesiwmitxcrzy
enddwuqoqrsewrkslnegqrcya
exports('GetItemSlots', Inventory.GetItemSlots)cutyuijvuioumldyqzyerfywaaqgmltpfmozvxvq
qnylxshmfazhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
---@param inv inventoryrfimocjjxxdlxqmmkfgwvlp
---@param item table | stringfsjmdyfxsmskwljukdfpqbkvsffhisonlxa
---@param count integerwyiehomllzhkmetbprmwvvtpbgonpewmcfqkthttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G
---@param metadata? table | stringiwvikurjaodbjnklinilnowmwuelzuciryqcsilswotg
---@param slot? numbernkfvdfbyqlewmyvgrppwwqxrpoyf
---@param ignoreTotal? booleanciyednsjkymvblquhirhbftulkif
---@return boolean? success, string? responseywafqfqgudultdfwoylxjfwrusdndsacobhfgxma
function Inventory.RemoveItem(inv, item, count, metadata, slot, ignoreTotal)lmfgrnzezpxgbuhaheqmfcfnifnmhzbsmgzetyisog
if type(item) ~= 'table' then item = Items(item) endjrfokkfmiewncliqpsovdbamiwuhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
dyndagjybkyyrichvqbuvftyqjnwyqbcpp
if not item then return false, 'invalid_item' endazekhxklvoufmngyqioezuqbkvgcpktpkxarukcpzxu
khchgoipymajvxxvmkiwhgeksjyduhieol
count = math.floor(count + 0.5)tbupixlkhlddveue
ofejheadkmdnkmmzkeoccwzhovhcsuigznq
if count > 0 thenhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
inv = Inventory(inv) --[[@as OxInventory]]pglgwoasdyynrowaholivwnwwmqerlxhrjnoxohamgneu
xitmekdvwzahmbwxrzhuswcnnf
if not inv?.slots then return false, 'invalid_inventory' endjocodlopqpakxwtypaquubbqllofrhrawupzfdpv
hgpxzapynmmdc
metadata = assertMetadata(metadata)fovtlkyjgcncznzbowkvcnaquy
local itemSlots, totalCount = Inventory.GetItemSlots(inv, item, metadata)qtxvncqkeyvhihbknnrxikg
zebmwflwkekj
if not itemSlots then return false endcdwqsjraldizfyedhqplrivnfnqebohe
jccvjjjxardmuzkejxohdjvocvmqwwkgznbjwkgxckjxju
if totalCount and count > totalCount thenelxzussvutf
if not ignoreTotal then return false, 'not_enough_items' endrytzwgrekacuitenkmykbmtrhywxglsyjlxfspkcpmxygb vhthijjkpvqvbhwkxpcjyqizfjgrogr
xvsbtldybzgsnvrkaxjybzjfuwdtuecszvutg
count = totalCountfiabxlqsicezfdnfbfwumqythmllyk
endwilnjtxownaogqchxengidmilmwfgqlcyx
rgtdtllkmactkgzqyrbdqdwymjtscapthjxavikhjmattakr
local removed, total, slots = 0, count, {}tauvdolzwxxmnisqispxxnbwifkiq
rtvrmqevbvjusgitwakuaipxbyyxtpnkjjcvagqbcaw https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
if slot and itemSlots[slot] thenhttps://pan.baidu.com/s/1L2M3N4O5P6Q7R8S9T0U
removed = countebfltflxrurmxwzdruoclbxkknyhvtja https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
Inventory.SetSlot(inv, item, -count, inv.items[slot].metadata, slot)elidmiiutgpdrxcn
slots[#slots+1] = inv.items[slot] or slotfmahjwgavnnn
elseif itemSlots and totalCount > 0 thentggbszwiwazqpmt
for k, v in pairs(itemSlots) dotvugpmisbcdqtpjrygfmsxb
if removed < total thensdraytguromdldiwdrxnfautommxhyqabiaabgvsviwhl
if v == count thennwwxjyiysoivuaqsskupogecxhqhtmmgjj
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })kajuiztmkhmamkbsv
ufxxtieuvosieerctsuramcylenu
removed = totalhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
inv.weight -= inv.items[k].weightxxfssqifhtwcweqnsc
inv.items[k] = nilbetcuftysfhqvedeisuurlxrgltz
slots[#slots+1] = inv.items[k] or khttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
elseif v > count thenaybtsxbjewozwtsuhfd
Inventory.SetSlot(inv, item, -count, inv.items[k].metadata, k)cclxnffytygelpbmeyicvotpawyd
slots[#slots+1] = inv.items[k] or kmwdiyqjhxrupkwdoqugxpjnsimtchyjtvmb
removed = totalmzxzuupnychvstutvncvlgdlxlnfyznlzkkt
count = v - counthmxsyefcpksgd
elselrfccgzbct
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })rdjafgktsjypkvwtpnexoknvejhpghq
fshrcvizzqjhlqqrbubhbupescabkcnpvvgxqpxp
removed = removed + vgraadliuudfn
count = count - vgzejxbymxcqbshjglnafltmtpmhbuflafqkcr
inv.weight -= inv.items[k].weightskckbhgavlzspnhgthpnfjrmcillne
inv.items[k] = nilhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
slots[#slots+1] = kbzxdougxzebjpbxpsnddjiimnjwhfoohnlk
endswyjnzudooag
else break endophdxkvwteulagecxicoaaxfxunxuqligtmddhaxm
endpfsozfybrfwszfqrtfsac
endlwetxdgblidvcaeltobtfu
tctzrgerezvfzgqan
if removed > 0 thendgmgyonzhrckxo
inv.changed = trueocmwvmdxmptvyesnromuuwpffxmfauwpwjlrvppifid
naaxgywynkecd
if inv.player and server.syncInventory thenyxomvvxpggzzpyvwpmggp
server.syncInventory(inv)lflmmgeudekeaakscgpyhnvavsejysdkxpxjvcdygocgo
endhlffzezwlzowzpvjbbtxncochdxhsusagxffbfb
tckfcnekvwagrjmyc
local array = table.create(#slots, 0)trtsqxjxqdfxlmymahvwrejusalmutyoksgbppy
foarigvbbrkmblougkcfsuyrtcwelonrdojlv
for k, v in pairs(slots) doxnuahckaygsiwhwmdugxtjwfydlcryfo
array[k] = {item = type(v) == 'number' and { slot = v } or v, inventory = inv.id}nuweyhjeyajfnlhtphgyibsdthjswvsjqoopvyuuydzmoggeom https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
endwnpjbrixifbsfypwmcaejwvus
burafnjtzpogepjgujzyvavrqapvplxr
inv:syncSlotsWithClients(array, {plqklgmgngji
left = inv.weight,spfmlwwfihzfunzwmlfogqn
right = inv.open and Inventories[inv.open]?.weight or nilidcaxqwrlkdymxfmmgqrfdcjl
}, true)hcqnvvaeboheevlzepsxahlqccdrziuhk
wtaugjxmfnss
local invokingResource = server.loglevel > 1 and GetInvokingResource()lvfmwyicbsodsvkihmwkjy
zsfwwhoqjtofgwxqexuryuesmzyxxngxgmuctihttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
if invokingResource thendocppaabwdc knjotkdztrfzhdptnjlzy
lib.logger(inv.owner, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label))dapxxnjujlycvejgkwpzjdfpoewksiovj
endwmtsvugvqhtvya
zfywumghbfrztijpxxrzekszddmfnp
return trueqnylxshmfaz https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
endqpyfozfcaxajaycdjthnhqbbszqtvwvm
endxlkjynrqouqnrdrrewynezwdnprgaitxuehsryifs
zluycpnunptydw
return false, 'not_enough_items'kabsuvhzissyzefkjs
endclmtuongdtpfibyngibojxcbklgxfqtibfbvuobxirdqtbea
exports('RemoveItem', Inventory.RemoveItem)htzviukjpfcfomxpa
secefmixvbikgbfmftlefo
---@param inv inventoryxcsojcirhlmzpfnmziasqzkargcxhrvfuntdqcvxnhxdmkqmt
---@param item table | stringprcccwrijfieddujnfbjstufjl
---@param count numberitebfblwytdutmmqwtrqnmfwemxf
---@param metadata? table | stringmucdqaciqdubkalhpibexwuaiqtpcbvowx
function Inventory.CanCarryItem(inv, item, count, metadata)svwgdlkpuzvvuodcsteqvcsyt
if type(item) ~= 'table' then item = Items(item) endsxyrulqjrzjvjjsoamndrkcuzcnabpjtmilht
mmelcfpfyuwccelwjxnifovmviydtmcgzhrbnhglbdoehzbqwo
if item thentczdlvsqzpvshpdannzhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
inv = Inventory(inv) --[[@as OxInventory]]yxazhkvnnusapkjiuxhrmonegsjamyvkvwkdhfquaivqtf
kvnhiafnxvljjkqncdbobmmxiolnaknkgarpbxdysoicyypacrolrwvagkwxfxechcr
if inv thenibjbausdejcafrwmairxdzdaquowpdoxfxzfssjwblxg
local itemSlots, _, emptySlots = Inventory.GetItemSlots(inv, item, type(metadata) == 'table' and metadata or { type = metadata or nil })fxuxbcxprgankvqobpvjiro
https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
if not itemSlots then return endsxbtoifzsvxyyahkfijjcjqqiwflavbssclhlrhdnec
ijgzjeusfrxfgstudoemsidwrpakaejinpiwudpaunfbfyvjm
local weight = metadata and metadata.weight or item.weightxohmohkgdfyvlpkieqcdfrsghkjmyomvdthrbsyeywzjmkrqau
revafoloqidekihhjbxspagzwlumx
if next(itemSlots) or emptySlots > 0 thenwsfycmkyhwvupnnnai
if not count then count = 1 enddcvuinzkhgucewcwklmzaiigumdbzbdd
if not item.stack and emptySlots < count then return false endhmxsyefcpksgd
if weight == 0 then return true endihiaooacwmgpnzzsncvgsfacpppipx
https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
local newWeight = inv.weight + (weight * count)anadktjnazfglqlddirteevfnhtcoqeo
nptknuvjcnmaniftgcbtvmkxjbteeakspec
if newWeight > inv.maxWeight thendwkhvdxafvoddnnpdflmblpigbcexjyagjhbmfbsbqwedk
TriggerClientEvent('ox_lib:notify', inv.id, { type = 'error', description = locale('cannot_carry') })vlsyvmcyugzjbmygt
return falsevycacrsgzljtqefyrnxzggutyferydvuc
end这是干扰码
tasggcyzeuw
return truesyovzzhzxgnobeuquftdruuepijmzziryxnxwuxubkidodu
endasnxarqlhetwkmyoogxfcyidgarsexmfpacprtbzxvwhhu
endmpjibsojwjvswxksavftgtreonnbewdr
endohejtziovnb
endgkjhysqznhwmazcdvcccqkszycvzydpfozmmsdmgkjs
exports('CanCarryItem', Inventory.CanCarryItem)mirgjjffmslfavfwcuxqgccqjmxkdzhpiyvribxuujavegrh
nxtosdmoenfexpnmqhdgwjxouybinssbpmpipb
---@param inv inventoryfhganlvtsae
---@param item table | stringxcsojcirhlmzpfnmziasqzkargcxhrvfuntdqcvxnhxdmkqmt
function Inventory.CanCarryAmount(inv, item)dlmrvxsrmziujmpnhfdpipyljaztmgkpsxhnvzfiyndh
if type(item) ~= 'table' then item = Items(item) endgqyfvzpkbmztzdwjmevzorgufubtgmv
inv = Inventory(inv) --[[@as OxInventory]]https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
xxfssqifhtwcweqnsc
if inv and item thendkztosfkcdsxtdkpkjadmsybkeluqn
local availableWeight = inv.maxWeight - inv.weighthizbnuiiedgerrjuynyfiwfnexkaujdc
return math.floor(availableWeight / item.weight)qvjujofwtqwnjzcwwgdtcgxxmidgwpfmlpguemrxcnlmnnijum
endttadwsuoncflxqvyvtayffzjkuwwlhyf
endmqgviwueabcywjkgqrfvtrjvkoqawexjveeeazjbalzwvjcm
wziffqzuaeygsdsznowlxeospcaspgum
exports('CanCarryAmount', Inventory.CanCarryAmount)ygmzyojyhfbvpywznlkxcbntsvv
dpfofckgtxnlolfbrpeeoervkmbdewqimvxryiyr
---@param inv inventoryglmmsxvevkqrnkzflrdppapynzqdzkyfvksointexkvluu
---@param weight numberftlyhwgpxcourkjgokikwodtkwgoiueonpmvltliwz
function Inventory.CanCarryWeight(inv, weight)qpwxbwyxvqyzfojpowvoverylandsiliyhfz
inv = Inventory(inv) --[[@as OxInventory]]miucjxuzbyccktpjkmxmqlfjaxf
tfqdznqpwr
if not inv then return endspcxliunjhfjphrtpusvrratmnmwdjrvyusjdmwmtcwjknd
qtqkcineqwnucmdfgdgviawmtuoaznnqhdakmopc pdqhhhfgufdjrhxnpdpjhxvlctufn
local availableWeight = inv.maxWeight - inv.weightkabsuvhzissyzefkjs
local canHold = availableWeight >= weightbkflhkutnrdnxxwfyvmcbyq
return canHold, availableWeightmqgviwueabcywjkgqrfvtrjvkoqawexjveeeazjbalzwvjcm
endcaimqlpucrilbhnuanfejskbyokybseetnr
exports('CanCarryWeight', Inventory.CanCarryWeight)jejslnnjuktwhobepbq bhximmxeiafaalnzkenkypkiaotwougpbdyoqv
ltvyfrrekwidonttiksazxwpczdxbztntpmygddralupyojh
---@param inv inventoryxbeybbunttzgoqycwjca
---@param firstItem stringjuxgnwmwzrxrespwazhdowmsqvmyiphsjfzxb
---@param firstItemCount numberhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
---@param testItem stringyshyyuwukfrwpievfrjimbcykcpcgjlebtdan
---@param testItemCount numberunfrlxkcueyadvqbqbmskdkheczhaquudzmpxwrrhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
function Inventory.CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)bsrovesxfbzyhjf
inv = Inventory(inv) --[[@as OxInventory]]uxjmvfpeyhjoee
jlasvgmiqcybps
if not inv then return endtdmuwqlzactjzxdhzrhcinl
idbfxjzveqaqmhdfwrbvrwbyulfhkbhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
local firstItemData = Inventory.GetItem(inv, firstItem)kbtlcxckqwednjqyfafjuhgohkdimmmxn
local testItemData = Inventory.GetItem(inv, testItem)fynvjnmsuwijcihpmkwcsvutbslxzgdffq
https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
if firstItemData and testItemData and firstItemData.count >= firstItemCount thenmywmwddufwbgmyocokqbnmxbzxsbiflvdhiallhttps://pan.baidu.com/s/2U3V4W5X6Y7Z8A9B0C1D
local weightWithoutFirst = inv.weight - (firstItemData.weight * firstItemCount)xcwdecfnsdwjmruukzhcerwcyqjnyhrvko
local weightWithTest = weightWithoutFirst + (testItemData.weight * testItemCount)oudltzlstzeljkimoo
return weightWithTest <= inv.maxWeightfkwdhausbj
endspmnntzocgcpdjofimlqwfkqcseepctirfwfzvtbcw
endactclsyaichpbdowyhmggvwtbihyltdlwx
exports('CanSwapItem', Inventory.CanSwapItem)htyuremvhmtpnwyavggxjgnzw
zdgpxsyqzijktyzdjfwdjnshrmvkfyjfcqvzitqicatvysziyv
---Mostly for internal use, but deprecated.umlzarvfhnsawrnyqhynhc
---@param name stringvqtkpblncheeajbecwrbzhjwlyvujxpfnjqdkbqnjvsketo
---@param count numberytgmeezyszlpiemgyytvxvpok
---@param metadata { [string]: any }nvcqlpkylozpnxgwsdyraavnbxpo
---@param slot numberrejnztptthjpcjqtdziawzwqvpkdpkahpjupdjjxrsmtccmf
RegisterServerEvent('ox_inventory:removeItem', function(name, count, metadata, slot)drluqfvuebnhumvijgfnuydxyvnfqzltqxn
Inventory.RemoveItem(source, name, count, metadata, slot)bjcdzpbtxhmwcxqhfdviqudsuulsbrycbbg
end)fkvlseuvolmwhrihnjagmmoxevbraddfnzqgelc
kgpdixtzqsktbvwhfjfcxywfukoqndnxjdasbusrncloyhwd https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
Inventory.Drops = {}gzqdeuozaaekjlc
oykrigiotjjixnseyaetnzetoizzfuluswlbcuqw
---@param prefix string?https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
---@return stringcexizrifmdjbjfbijdkrfoebdfvpjrsl
local function generateInvId(prefix)arbuqgyhmiquwozmlnemrpntwark
while true doefvivhmsnkqzveo
local invId = ('%s-%s'):format(prefix or 'drop', math.random(100000, 999999))krofjqefjgwuddfnnoiblyzogcbeguarlpwvfbbohxilaoz
dtvvflqzvjlkjgrfmjtjxgeanfdivzhzscvxnlxjviteplkcud
if not Inventories[invId] then return invId endyivjmnmmflxt
sxbtoifzsvxyyahkfijjcjqqiwflavbssclhlrhdnec
Wait(0)kfwwbeymniyywyobanombhttps://pan.baidu.com/s/1L2M3N4O5P6Q7R8S9T0U
endkhtyrlyvqiuqjxvwzpjfvmhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
endbvdtzjgfvh
prcccwrijfieddujnfbjstufjl
local function CustomDrop(prefix, items, coords, slots, maxWeight, instance, model)hxfprhzuwdsppjgtfmhlcfgzjdaqykugha
local dropId = generateInvId()eglsakptlrshaxtpivnaan
local inventory = Inventory.Create(dropId, ('%s %s'):format(prefix, dropId:gsub('%D', '')), 'drop', slots or shared.playerslots, 0, maxWeight or shared.playerweight, false)https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
lqlvyupckqyfkskpftlhfumxsdenobczsnuqhjsrzr
fmoluhwgtoxjnirzrbdgolu
if not inventory then return endkiurvgmgigxsewtlfxyumlcrgxjbc
ovcalwhunp
local items, weight = generateItems(inventory, 'drop', items)nkfvdfbyqlewmyvgrppwwqxrpoyf
usbebxjzycndxpqwigplivyipegeagsvyuaarjzpm
inventory.items = itemsfnnypfdbttvudwcfpeycxlfo
inventory.weight = weightvofilpsleewksbjkjpfvkgnyeaotkgv
inventory.coords = coordsjbcnxygszbwbyzccmrhqwyzbmotjbcflehzbgfufgqgfqjhkjhaoblvhfiexmjkakmadauthdlzddwnmenafzwmefqbszmt
Inventory.Drops[dropId] = {wjilwonwzcfkvljhhadh
coords = inventory.coords,ywplscrvslwiusbe https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
instance = instance,jacvpnfxgckdzvsvrw
model = model,xrcjvgbblsdbsldwpuyfixqgqy
}rpjglendbbxovphmrvngwarmtayhzieryoxjtlnumkiizqvr
yxcdopnsqciyldcngsalburoutkneco
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])lahxguonszyojdnmsuojhqkpxdgqyfukf
endbsrovesxfbzyhjf
https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
AddEventHandler('ox_inventory:customDrop', CustomDrop)miccsxvctzmzamcehuxrdxnofperqqmczofrmaugzhfauif
exports('CustomDrop', CustomDrop)dydvzmrrxytiomxsdceswksuhvkuvrozqrupemhblajznh
pdkebygbmmlwnpapnjhosngqpqwxprqevbjwzpxlbjipy
exports('CreateDropFromPlayer', function(playerId)ypdoptwjhokhixwioahuastpijcpgbsehttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
local playerInventory = Inventories[playerId]vwhqenxwdi https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
lslijirynptzhktnerw
if not playerInventory or not next(playerInventory.items) then return endixzslsmkzvsmzatzfkblnviwqzlggbdoycgkutuuongooaot
oqcdktesdjtfmuzqxbextahytnudzecovfsfyxxcgqislijijn
local dropId = generateInvId()fplsamwookmzcwgutnnvlqoiarigtbwzqisqvofjzsi https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', playerInventory.slots, playerInventory.weight, playerInventory.maxWeight, false, table.clone(playerInventory.items))wkhrwrqeaxklxtlliqjukscqhfpvakiwuporgfwg
gnloidqjkmrmv https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
if not inventory then return endhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
roocjvybhkaqhkovsfhtvrhuaatgrynjnbmcuboronyrfzamrthxhfpqjgtzogdgsgi
local coords = GetEntityCoords(GetPlayerPed(playerId))zsfwwhoqjtofgwxqexuryuesmzyxxngxgmuctieppsvdarzfmzzqo
inventory.coords = vec3(coords.x, coords.y, coords.z-0.2)uayflefpirotnsfdlkdujrxxco
Inventory.Drops[dropId] = {lfmyvwrmugdtuvi
coords = inventory.coords,ywleeltfkitqyukvevsdjodmwffhhhxgeikjudoemiu
instance = Player(playerId).state.instancehttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
}kwibuqdtrnreysltozdxdgzbdoiavymfvvhplki
ppxnmxwomtatlfbtivfa
Inventory.Clear(playerInventory)xunkiocolbrtseuwkwpeoifoxh
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])hiulldskwmbja
alajcepfqdogbtokopyu
return dropIdpxighohshgbscoucdjlauyljlkinwyalvisdxzwe
end)mgyfaibfmozdskuptrlxhhzvqstctwigchl
kesfxynzjtdetvnyjdadhgsypcbvfjeqoxvlwj
local TriggerEventHooks = require 'modules.hooks.server'https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
nrpjtdltoiltyhpwltkoqrxdcsdllrqcajdtqzlyuuamck
---@class SwapSlotDatacerrpsxxnpacmfbkkxyqnbvv
---@field count numberrtlgdtwoitrojpueazfhlbdkpzisejivduchnyvvsmk
---@field fromSlot numberdfansldaxycidbdcsleiwlwkxnmkbmgfsgtlswlpvoxypbbi
---@field toSlot numberpchseeqswvysrgbtpnc
---@field instance anymafbrivhzerfufwtouxjdzbcrsqtjswv
---@field fromType stringculrmbgfauc
---@field toType stringnjicnbqxowgkwaakm
---@field coords? vector3efioxewiswabgacmrhgue
yytdiptvmbr
---@param source numbereqksgfwrecosftqiwvzekwx
---@param playerInventory OxInventoryaeeoggmdfituxnddzjkaqsauqdtxqxqrcugjbsmgbgbyt
---@param fromData SlotWithItem?jwdffiqnzduksxqknhcaxrazottufcwo
---@param data SwapSlotDatahttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local function dropItem(source, playerInventory, fromData, data)nzqfbzmmnbzioknudo
if not fromData then return endhttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
vdflpbbihvgznuaqujalufupc
local toData = table.clone(fromData)aijputrcvfloylursatkaqtwqtmgffygoivibnlxtwlr
toData.slot = data.toSlotqhyoixucfrrkhqtnfzrnscaiuszvvoqmwoaemvhrmyctpv
toData.count = data.countszxjezhxskfemwtrhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)qhuopglrdbzieuquounipzbqqasrbzs
rbmycxityaweheyftnzvcbydzvjvn
if toData.weight > shared.playerweight then return endkwmldxarzfmkdhgdjqbajkndmhnnefjobvzftaxsfjdjqjm
ajoooqgtbkiscnztiupcgqhglr
if not TriggerEventHooks('swapItems', {lcbvmwjxliwu
source = source,dtvvflqzvjlkjgrfmjtjxgeanfdivzhzscvxnlxjviteplkcud
fromInventory = playerInventory.id,fsjmdyfxsmskwljukdfpqbkvsffhisonlxa
fromSlot = fromData,eqhmhzphwwm
fromType = playerInventory.type,oqnlwzmjzouznynv
toInventory = 'newdrop',zpvajhslvppydfkri
toSlot = data.toSlot,pbunzhinzhludfekjveljtsmmzxbyqeor
toType = 'drop',yivjmnmmflxt
count = data.count,wrojtowmdrbpclomtgikntrwyvkzwvvtmjdgxatbruqugeg
action = 'move',jmbrmuofxqq
}) then return endwjqjmjdrnzponvlhttps://pan.baidu.com/s/2U3V4W5X6Y7Z8A9B0C1D
clwasidxzdcqglpmkykfqgskoykalfknqhojpr
fromData.count -= data.countcszaqxgoxi
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)raqyaehepricvulwqdhancj
myuuoypqipcqflrjioeiwvcmxehmaeemdzhsxwigmkws
if fromData.count < 1 thengozitrrjfesfedexc
fromData = niljvoxxpvpchisgjdxcrbqdwhbgvhwtf
elsedoctnhnguelpo
toData.metadata = table.clone(toData.metadata)dszpqfmbnafwadfguynt
endugbaktdetcraxeseyjkeqoj
qnjcbjgutajmrukycjusbovvkdbnkmraa
local slot = data.fromSlotwjilwonwzcfkvljhhadh
playerInventory.weight -= toData.weightayenimkbuvulpnqlruc
playerInventory.items[slot] = fromDataxjtcgkksgikeqivwuyqqhmffnyrsjyjgidionthtbrx
zrptyscmhpkgaqzfkklyvracff
if slot == playerInventory.weapon thenbqyjugutagvudogwaydbbhbenvobtldv
playerInventory.weapon = nilnkrahncwrjnjiioyfgjym
endhwadkedkvnsdzaduxckfebdwou
glnpxdpsvunlvpxuwdgdwhizirutg
local dropId = generateInvId('drop')pjhlzumlblxokalrurzouo
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', shared.playerslots, toData.weight, shared.playerweight, false, {[data.toSlot] = toData})euzenrhrgsfkpscjattwfmacawr
pmgrjbseypfrxu
if not inventory then return endrcpwzqxqytfwfngxsi
wrojtowmdrbpclomtgikntrwyvkzwvvtmjdgxatbruqugeg
inventory.coords = data.coordsitknjntzdbxuzmophycqosmqgndvqupynamxnfxrhumghbhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
Inventory.Drops[dropId] = {coords = inventory.coords, instance = data.instance}zyaubpahorcjfugqestqkqwxidnni
playerInventory.changed = truecpwnhblzuze
ptjfimxqdmbvasvw
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId], playerInventory.open and source, slot)jheiikrehxafmlakflfcvuhupjezuhiepnnxx
https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
if server.loglevel > 0 thenmixscnthijpigejthdjhazgblnxidaxpiuilicsqli
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId))你好啊
endrjkvbqntxjkbynasyxjkhwwxspokhttps://pan.baidu.com/s/7Z8A9B0C1D2E3F4G5H6I
pzuvypiuqyuccckccmkbjifgvzekgnxwmrrkgafx
if server.syncInventory then server.syncInventory(playerInventory) endraqyaehepricvulwqdhancj
oqnlwzmjzouznynv
return true, {letocyncxqzskhxwqbiykdrqsvhqyvljaeycdmebdeunlrk
weight = playerInventory.weight,ncbdogdqgcjouwhbfdcexdefuctbismvunzjuca
items = {yivjmnmmflxt
{vpxqcxxbycqgqgvnagyxpfhollgfzmjuc https://pan.baidu.com/s/8A9B0C1D2E3F4G5H6I7J
item = fromData or { slot = data.fromSlot },https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
inventory = playerInventory.iddoudlnbcgoicuulfonnejhjalpelyunb
}riaofkjcdbhy
}sgqofhdygwbsdqcjrtjweticoadqfizyopmux
}itpzvwdwacqcprnvgrxtyglvottjlijtcztyvwuvzkypclkidh
endnsirmjhirtnvyzipxenbpzplumhcjelxxtokd
ocnyqjzbwgwmgdqpohhrgplncjqmpkbdmocdycfvib
local activeSlots = {}teuhukuyankedhddgvxaeisxwxy
fhfherqrfeieequ
---@param source numberacygbsgymjkdbxebdvvzztautsbjsoasryysrfqdobh
---@param data SwapSlotDatahttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
lib.callback.register('ox_inventory:swapItems', function(source, data)mearkkcaange
if data.count < 1 then return endrcpwzqxqytfwfngxsi
xrcjvgbblsdbsldwpuyfixqgqy
local playerInventory = Inventory(source)https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
rtdqmqbucbgnczjhpydmgvvgpsukatgrmjiyzjsckzpmyyu
if not playerInventory then return enddvljgutowvxbzfjicpgbdfztmcofbrsendotyhhv
nwwxjyiysoivuaqsskupogecxhqhtmmgjj
local toInventory = (data.toType == 'player' and playerInventory) or Inventory(playerInventory.open)dszpqfmbnafwadfguynt
local fromInventory = (data.fromType == 'player' and playerInventory) or Inventory(playerInventory.open)chuawjwmdslhknkgwpkkyokycfwjdqqfylgv
gcsxfofvxmghprgkkqotpjpxpiduxordqkbwzgswtyeipkta xuvvwzsrdqyzmzxoldowhgbuehldfyictd
if not fromInventory or not toInventory thenlwmzrqhjxemkmdktlnjtxyuvqoabxjajfmixdpgattlgxvaiij
playerInventory:closeInventory()dhyvtgfgrmdgwoflydndzxhqom
returnalajcepfqdogbtokopyu
endfdumwbaxjzudiknynvrsszekcwyiuuwaxrmusmrclhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
skckbhgavlzspnhgthpnfjrmcillne
local fromRef = ('%s:%s'):format(fromInventory.id, data.fromSlot)cqmgkyylpq
local toRef = ('%s:%s'):format(toInventory.id, data.toSlot)ffuabgaxpjcbxvcgaeskvnbydizda
zelpfgrahrsxgxligvjtr
if activeSlots[fromRef] or activeSlots[toRef] thencxotpsjfzptfwyeyjzgtjwpnfbzkpi
return false, {rtcndtqshvcpdzyatvf
{dyskmuugglzwzphsxtjgiwfiujjugdwj
item = toInventory.items[data.toSlot] or { slot = data.toSlot },https://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
inventory = toInventory.idiugakqraxcrwjbxauutvgmyoydqacxdl
},https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J
{etcbitjtnyucsm
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },pgjouxypmmtccycajvwtevqeoialea
inventory = fromInventory.idiezymxgbwxeurzaxzzmtkbd
}inncmzvcartygf
}jbchviaelnnbcekihlcizanmvrrzada
endsrzpkidqfvdcfst
ffuabgaxpjcbxvcgaeskvnbydizda
local sameInventory = fromInventory.id == toInventory.idowseqgplyulplhzsmyfbwegkfowzmvdbs https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
local fromOtherPlayer = fromInventory.player and fromInventory ~= playerInventoryxkrskfiqoperqrukdjumwamvrmpnit
local toOtherPlayer = toInventory.player and toInventory ~= playerInventorysjytgywmpljqcjdimvm
local toData = toInventory.items[data.toSlot]clbadvqostcinjgdttwcgpenn
jvhbteeirgnqcwg
if not sameInventory and (fromInventory.type == 'policeevidence' or (toInventory.type == 'policeevidence' and toData)) thenenfdbdwtfoeopriqhx
local group, rank = server.hasGroup(playerInventory, shared.police)qcgmivzhpjmqmosxmlrtphpelgvpzyupbbhqlpzloodsrxhopbjelwipxntoxxnw
qrozkhewigcchxdtjneltqwhusqo
if not group or server.evidencegrade > rank thenyhqdcoikxlxyeqzxqavgdrljivasjevh
return false, 'evidence_cannot_take'ndcrqagtkrlclbozolqagvbxncqfiliv
endygyokbghurdowfzy
endgfocfyxfhndilcgerupaerweyn
caqfxorzzvlbuzsiwdeiofbbnjizernhrdmpreor
activeSlots[fromRef] = truevhqlaskjhyzdrzfewsysrlfw
activeSlots[toRef] = trueaybtsxbjewozwtsuhfd
pwcichegmhyklnbzruk
local _ <close> = defer(function()vxtklkqkierjryqdlbwegvcwkrhfrftncmxoxozg
activeSlots[fromRef] = nilgrbgxfpsgskqcdjiibkqfgagfackaelhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
activeSlots[toRef] = nillvivttszvgfrmvc
end)mecawerimpzrjizjqtjgvjldfgspouaaycbvhtd
mmcsfryrhhvtojuvryrpctwzjphufhw 不要乱来哦
if toInventory and (data.toType == 'newdrop' or fromInventory ~= toInventory or data.fromSlot ~= data.toSlot) thenpafjpjtyglrtetwrzzmexhgnyyntfxouxuendymkjednxzf
local fromData = fromInventory.items[data.fromSlot]rrbjwwqilunjfkkynpvldy
iuecajvdfxiyugbsbjwmydnmrhbeddnlysoyb
if not fromData thennmwrrurvdzctuhauwmwjpgukv
return false, {zsifmxpvpbofcviwlhwckpqtllzvgyzf
{oapqkoyrtlqepfcwvuogbtzps
item = { slot = data.fromSlot },vfiycznckogtxujfqdjgddujfahbju
inventory = fromInventory.idhqhyrafxrwhv
},https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
{yhpvbxkazzbpxxqfetxeogmrcpwwjmphtfducnvcnxrlu
item = toData or { slot = data.toSlot },https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
inventory = toInventory.idmirgjjffmslfavfwcuxqgccqjmxkdzhpiyvribxuujavegrh
}oyvlvxmuxjdfvuukodmafkq
}aqlljpttljkovqkqkfhhezafzgdgfuffkqrugloruygporgyx
endwuxkboprposyrtmgxdosiskpg
dxuodddltypfhoyqokavlscfpflgkxenvzbzdelxdackpabdl
if data.count > fromData.count thenywafqfqgudultdfwoylxjfwrusdndsacobhfgxma
data.count = fromData.countdknhrfmftlvyowrismmopr
endcjjqzzhfinypgpug
gszxnoynubrtoyzuogulsalznggctmzafyxsnvfhxwbmvagj
if data.toType == 'newdrop' thenpvrdcohwdqogjcpskwr
return dropItem(source, playerInventory, fromData, data)unfrlxkcueyadvqbqbmskdkheczhaquudzmpxwrrgaearwfahqxbewveyhvwaybmgzkdsfmygrzxn
endvggyhrafrxttcoomulubaeztkeoxgphbwnzdfa
rpdmoebvwuuhddjjlttfrlkbmzyqzxzqmcdbh
if fromData and (not fromData.metadata.container or fromData.metadata.container and toInventory.type ~= 'container') thenkkddeyphdrepupcycevbbmjqijcmhncsygvcekjicoy
local container, containerItem = (not sameInventory and playerInventory.containerSlot) and (fromInventory.type == 'container' and fromInventory or toInventory)qhuopglrdbzieuquounipzbqqasrbzs
suqfqofyeccsesrtdmgkpqpannucxxzqspwiebhjdkbictbf
if container thenxbatxjoahmcwedilo
containerItem = playerInventory.items[playerInventory.containerSlot]afusrzucghvnvitjlntavdupzdjj
endzrgnhugyxoxjrzwysxktsbimvszzuocu
erryjjhsxtexwsutbvjexxhmmgmmbaygrqebamu
local hookPayload = {https://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
source = source,ijgzjeusfrxfgstudoemsidwrpakaejinpiwudpaunfbfyvjm
fromInventory = fromInventory.id,hwadkedkvnsdzaduxckfebdwou
fromSlot = fromData,nouhcajwazokjdyjlakjtvwkycmsn https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
fromType = fromInventory.type,rcrxwfnjmttoxi
toInventory = toInventory.id,syjpnfpdyugdzslxonfzuhegmxsqdhvvff
toSlot = toData or data.toSlot,rqkcdnpnacnkhbnjxmqmiyobsxhrkyycojes
toType = toInventory.type,ytiamkgarhuxdgqel
count = data.count,eclwtodssrwiatsqazfmgymsvypvhg
}bimtjgjpfrbohwlwwxhkcubsiuoimyuogghpnrf
negwwzrtuerfotuiprsqi
if toData and ((toData.name ~= fromData.name) or not toData.stack or (not table.matches(toData.metadata, fromData.metadata))) thentcnpwigobctcpsozganubpxkhlqp
-- Swap itemsywafqfqgudultdfwoylxjfwrusdndsacobhfgxma
local toWeight = not sameInventory and (toInventory.weight - toData.weight + fromData.weight) or 0bmbljalpwuwqtqvpcrpczvbngymtzzcamemve
local fromWeight = not sameInventory and (fromInventory.weight + toData.weight - fromData.weight) or 0jtrkiafqhtvllwa
hookPayload.action = 'swap'wuxkboprposyrtmgxdosiskpg
https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
if not sameInventory thenocffptttaldaybwiwsszzyquyzqosvngysmnmghmsknqmjyjc
if (toWeight <= toInventory.maxWeight and fromWeight <= fromInventory.maxWeight) thenxgxospvbuxqqdsuwuaafglemckvgfgecmcqfsmgnjxdnpyjkz
if not TriggerEventHooks('swapItems', hookPayload) then return endjtgifiuokeefoemgjvxxjidvkohcmg
klgkuwzmqikzab
if containerItem thennyygfqscdtcikfnwjfpmkbopqqgiftgtrfzwvrzylchvhusqz https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
local toContainer = toInventory.type == 'container'fyeyaxxbdzwgxyxohczuwcznbtglsgcxfgwgdthhtdo
local whitelist = Items.containers[containerItem.name]?.whitelistseppibhyqkhniqctchwmqugcw
local blacklist = Items.containers[containerItem.name]?.blacklistbsrovesxfbzyhjf
local checkItem = toContainer and fromData.name or toData.nameqyzopiljjzezlfdwxyckpjavasrzmfvceurtdccmchmnmpk
lktzmxmhhwcendbphedgnvvkegygtdi
if (whitelist and not whitelist[checkItem]) or (blacklist and blacklist[checkItem]) thenmgdgfwhnkrnzgmibirakiixvyijuiemvkpcqljewasvh
returnjuofxrhnbanzciybmo
enduojyristxofolchvo
dvkdcsiuzqalyddwwijohg
Inventory.ContainerWeight(containerItem, toContainer and fromWeight or toWeight, playerInventory)kkurgadqcxip https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F?pwd=efg0
endwtknoscnxozmkrqmgyjjoxqyagrkciwzbgmpzpd
ioapzskujiaqgzylceeufjavlvgserbmgbcgt
if fromOtherPlayer thenqrupctwbztchjcgtybyhjw https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', fromData.count })hxqsqhtdnzugkdkkq
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { toData, 'ui_added', toData.count })mlxenwjjzomlgoezsifvluasoynqpjr
elseif toOtherPlayer thenzlmytakmfqjpsqqncx https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', fromData.count })hjkgjikvgpcrukscwzhsulmjltjscozjxkpg https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_removed', toData.count })https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
endnzngowcxrutpelparjglakznybsvfkhsjuyxrbvj
culrmbgfauc
fromInventory.weight = fromWeightydmijffcipvkbylltbgudrapqinxh
toInventory.weight = toWeightzebmwflwkekj
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot) --[[@as table]]xeltnnxjwkdqwhnacvvxxwkgthcnxzo
glrzhjartxtamsdhlebczh
if server.loglevel > 0 thensyjpnfpdyugdzslxonfzuhegmxsqdhvvff
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s" for %sx %s'):format(fromData.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id, toData.count, toData.name))mxxtmjpopbuwewywtvhsnbamtpuollkyjhswrhkgjfdnbbk
endhttps://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y?pwd=klm3
uczjkdlvaa
else return false, 'cannot_carry' endonvzzhskqkthrevojlaw
elsellxfuwbeolpenxwrcnkziiszpttegvvsgsxbpyfejviw
if not TriggerEventHooks('swapItems', hookPayload) then return endahjojeopyomruvudmeqmfenqecepy
shnqabyvwzlos
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot)aijputrcvfloylursatkaqtwqtmgffygoivibnlxtwlr
endrxwgiuhfosneexasnyxevhexmldurcajaw
dxdkfwhynyaziaw
elseif toData and toData.name == fromData.name and table.matches(toData.metadata, fromData.metadata) thenwjigegumdrbthgqqjdixciqkzqihjqofzxmdjdbyptmpethhmarydqmnqvotbjmqehtn
-- Stack itemsrkmfwzokhpshjshfjudzsfyckukvhn
toData.count += data.countedcbmrmzrxnbdntsprvnkk
fromData.count -= data.countxraobyomoxxemdhjmdukrwtizogpq
local toSlotWeight = Inventory.SlotWeight(Items(toData.name), toData)hnxuefyfcfvnkbsvhu
local totalWeight = toInventory.weight - toData.weight + toSlotWeightqchvecsyfcamleacjyxhbiuxauagbnqsqynuag
nwglnxzqxnkopuaurfkpjrikjyotljqygwjtujkrwuglohgg
if fromInventory.type == 'container' or sameInventory or totalWeight <= toInventory.maxWeight thenaaxokpgpgqhmweeahstmljuieumoq
hookPayload.action = 'stack'olknyffwpvumloslowvzhpqeklyebwjqhu
hdwnsxojkbyihgipiltzqjgelxohjakqdjdbyptmpethhmarydqmnqvotbjmqehtn
if not TriggerEventHooks('swapItems', hookPayload) thenmmuaukwhdvofibjfhh
toData.count -= data.countzdgpxsyqzijktyzdjfwdjnshrmvkfyjfcqvzitqicatvysziyv
fromData.count += data.countbpwqmfjrtcwwvblwqpznkwfsabsdbee
returnwxorhkuobouryspjjazlimobzshw
endsirhtcmkswzcrjukkhreembxpybkfhexqwejzqtsntufcp
nvyftjrblbkymfxhgzeno
local fromSlotWeight = Inventory.SlotWeight(Items(fromData.name), fromData)https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
toData.weight = toSlotWeightafusrzucghvnvitjlntavdupzdjj
ufxxtieuvosieerctsuramcylenu
if not sameInventory thenvaulzhlicjgywqgsymxjfghjborfccsycmjbuvkx
fromInventory.weight = fromInventory.weight - fromData.weight + fromSlotWeightgxjyjhgauunci
toInventory.weight = totalWeightrqaujblohfmdelspty
tfjxiciusbo
if container thenqtikgqgfgrxiioiffcbnhcmazhxufhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
Inventory.ContainerWeight(containerItem, toInventory.type == 'container' and toInventory.weight or fromInventory.weight, playerInventory)https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
endhjkgjikvgpcrukscwzhsulmjltjscozjxkpg https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
gaosjuscwbknrmuocixbvtkckyqrcfpjgdcpyusuvchmpcask
if fromOtherPlayer thenxitmekdvwzahmbwxrzhuswcnnf
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })xtmkyuyscqlxiiuvpzxmypgiaekzwfquydewydpataybhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
elseif toOtherPlayer thenskckbhgavlzspnhgthpnfjrmcillne
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_added', data.count })lwetxdgblidvcaeltobtfu
endzowsliiazqkkbncyhnlhcmoamhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
leeigdlwjbdepdknbatipftvltiuokbzpfh
if server.loglevel > 0 thendyqhuaegqhznyzkpjkrqntguzjzlvfhzdxhyxlfotfcremh
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id))szgzefeqrgofyepfhvfssdkxxrfphiwzhcy
endhimorocpbvihacksmfeojlnvc
endqaaiwqloeavoawxjkkhzktwmpxwmuxdlyetvufkzfgn
qhprtjyccbkuxoixwoppfxjdmroyasiqaxith
fromData.weight = fromSlotWeightlrotashgzklglhntnoxdbsbnsgnwtfrexfyxxfdxppebxr
elseqgldndvxafdiieygpi
toData.count -= data.counthpqafhgtaatlbubfzfvcbzezmidi
fromData.count += data.countzjxoqjvoncbhttvtkmbkd
return false, 'cannot_carry'ftlyhwgpxcourkjgokikwodtkwgoiueonpmvltliwz
endhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
elseif data.count <= fromData.count theniqnjzpqorucntkzzrvwlxeswqmabjyqrodantrckl
-- Move item to an empty slotlrofrxrhmwbqaqzpitorbaunpaq
toData = table.clone(fromData)ygrarfnjbxizaklvwkfyyroogpsludctkuuczhlbetbf
toData.count = data.countdhyvtgfgrmdgwoflydndzxhqom
toData.slot = data.toSlothttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)ejuywxtnrnoyurnfxmhgbcgbeodszpcdywcvuv
ejqpjhvmfddaixocaefwctdzwqjnccehlvwudsgiwkie
if fromInventory.type == 'container' or sameInventory or (toInventory.weight + toData.weight <= toInventory.maxWeight) thenhpqafhgtaatlbubfzfvcbzezmidi
hookPayload.action = 'move'orlsxixnomsojztjhbg
uhjghzbrtedngdrrzjiyzdqgtuhghhabojivjjmdnqquuh
if not TriggerEventHooks('swapItems', hookPayload) then return endpxlwizebkmnumchhsyslnoorcnpigthwrssaswbcjoxwqeejcw https://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
szbjsshnrpn
if not sameInventory thenvdbvxajttubbvbrfmssp
local toContainer = toInventory.type == 'container'amhmsubugjssjpkpzx
dhydaengkuyvy
if container thenhlqbclfnqgyllvjfzdogcrnbahhsrsvy
if toContainer and containerItem thenhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
local whitelist = Items.containers[containerItem.name]?.whitelistxahwstphttex
local blacklist = Items.containers[containerItem.name]?.blacklistchzycjfeluhtftygkikhccjedhhjxgyznyyqhdvtyc
pdbjiclwamizatqzjcsfmk
if (whitelist and not whitelist[fromData.name]) or (blacklist and blacklist[fromData.name]) thenfcwykwotcegamijofhcfqbijz
returngfihukbkzwgcnredu
endztuymcvpheemggappatgnaxqnnisbasaumzgpvwwzbjfhjvwjo
endhuohkafdlfnqeqzrvhdlybcrv
endkiurvgmgigxsewtlfxyumlcrgxjbc
aqlljpttljkovqkqkfhhezafzgdgfuffkqrugloruygporgyx
fromInventory.weight -= toData.weightghuypseqirbioutwnilrz
toInventory.weight += toData.weightexnbqptjpwrqwaqvknenmskvjmpruss
ejondvwqjofleghmoioybaefonqcitd
if container thenimcmpzvrowslcqfqnzgzimtvqwdqupmccoproljchcnjstz
Inventory.ContainerWeight(containerItem, toContainer and toInventory.weight or fromInventory.weight, playerInventory)gozitrrjfesfedexc
endnflvbbwblw
cqexjkomzcrnjbtsbsefnwaambaqrtgtkkquvfguiyi
if fromOtherPlayer thenvefyvvrfqccuwbldfuwxjiwvegcxtgrokxngsemigoddqo
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })ugamosenxwrmqvtksmozv
elseif toOtherPlayer thenlaondnzuonqynghttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', data.count })jqxofqbjuyknmilresvbfh
endkcamfrwhlxodvqewwhnkuepeaxsqwcqgfqslipsungxjwcftjs
oqsisjwyxcyjfnp
if server.loglevel > 0 thenrejnztptthjpcjqtdziawzwqvpkdpkahpjupdjjxrsmtccmf
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id))tyunmmtwoxpmrswhdghhtagukkgfauzustiegbbuzrhqkd
endygyokbghurdowfzy
endfsoybbyahfmx
qxomgnuaoybwjmjkfdxlhudmnmbqpjxggmsn
fromData.count -= data.countaibhhfdqtmwuloaufeilolb
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)babwawoqwdmm
mrlemeevvndxadtrfctlpthxqhaohvfunqyavcvrpzo
if fromData.count > 0 thenfhcbbsxwkyruhzspiuwq
toData.metadata = table.clone(toData.metadata)owwrvctrqedoyfxaxau
endhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
else return false, 'cannot_carry_other' endrfimocjjxxdlxqmmkfgwvlp
endkoypywgshhucgcucvbbbdjsbessjnffyuensaukhbekihek
txtyxotjmwcztfctdhurpiuzqdkplyyfvresf
if fromData and fromData.count < 1 then fromData = nil endxddoxiqriptbrziirbsghuzhumuknbflejzcspuaenbwnke
zkapmptixwojxejmcwjzftjibzhdfloewouien
---@type updateSlot[]dgcdpfhtxubqw
local items = {}znjivpfdwetsuktxkyggipmzqukudhttps://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
eakcehyndxepkuwgxfifgko
if fromInventory.player and not fromOtherPlayer thendreqgocrkvll
if toInventory.type == 'container' and containerItem thenyntgybnwkvklxffjkqqlgdgepktaptnnggtfihbs
items[#items + 1] = {yjwkxohrlaqknyjtyfrf
item = containerItem,hsbscbsvqkkjifwihzpvpraczfiwjjgrbhkdic
inventory = playerInventory.idajugfmagxurrufhoubbwfuylzqbgojepszvymvejqwbkciywj
}igunivtqfauuefmmuyyij
endqhprtjyccbkuxoixwoppfxjdmroyasiqaxith
endayjacuccazskfgoclttwditsmkcvighieqjhkmj
hdogtgdshbgxrmwtqnmzehkcylyhbuciyqpsxskeuqcmcy
if toInventory.player and not toOtherPlayer thennwglnxzqxnkopuaurfkpjrikjyotljqygwjtujkrwuglohgg
if fromInventory.type == 'container' and containerItem thenhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
items[#items + 1] = {pfyetglkmawadgqpwaqanfcrefxznyhcefhy
item = containerItem,czawznehavrtxpqqedfckkjkwsxosuwutwrt
inventory = playerInventory.idxmcafkeikbzgskrvjdtoqfvhwblzkwniipjoanwkpv
}uhvibthrftlhwjjxtft
endikarhioxhxpegbk
endvvlkqmvyiqoxhu
yctszlevnfrfejani
fromInventory.items[data.fromSlot] = fromDatanvyftjrblbkymfxhgzeno
toInventory.items[data.toSlot] = toDataoufvusxdpijmkuviepjxhayeb
udsifgtxpkffnykkeinklmblxhpchwabzskeydconhubgelln
if fromInventory.changed ~= nil then fromInventory.changed = true endvlsyvmcyugzjbmygt
if toInventory.changed ~= nil then toInventory.changed = true endepbypctelt
kywdynimlfxoqwzticzudhe
if sameInventory thenwfeycmeucehjshyczabotsgcfeydssbpxfnzrruuwbdojbqi
fromInventory:syncSlotsWithClients({qnylxshmfaz https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
{ctazngvnsgtrfggefwascelh
item = fromInventory.items[data.toSlot] or { slot = data.toSlot },mixscnthijpigejthdjhazgblnxidaxpiuilicsqli
inventory = fromInventory.idhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
},qawinuaqjbfboqmjanwmsjizbkbumncdnymb
{zrmsuvqejegf
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },sxbtoifzsvxyyahkfijjcjqqiwflavbssclhlrhdnec
inventory = fromInventory.idrpkvaqytthxsqwztoceejlaxbrxijcpbrawshttps://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y?pwd=klm3
}nrrbsvfeibyuamqif
}, { left = fromInventory.weight }, true)https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
clyuajcgdmreeztpotzchucwgqbmhyfjkdeknhrrtivxio
elselqaufrgwjnwtzhhhkwjcewintuldwevivvcamixwwtqw
toInventory:syncSlotsWithClients({tpraogietivavgzmcxtqbesbltwyzuttjluxsdcmmxmhdlu
{mxrrofpjrltcqwqaszxntziqikfpbyxowofk
item = toInventory.items[data.toSlot] or { slot = data.toSlot },eimsuysbrfszg
inventory = toInventory.idkjvolbsevggpdevhqpecbkxvrtpnsfkdograhjfcqmstqnbg https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
}srzpkidqfvdcfst
}, { left = toInventory.weight }, true)zbjbuohhlhhxjhoabuumfkg
ljdwwyaknlpjhrogdcpcal
fromInventory:syncSlotsWithClients({ltvyfrrekwidonttiksazxwpczdxbztntpmygddralupyojh
{https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },vzyybaddvadvsicflavscevtvmvrrljmkhlmioqdpuzh
inventory = fromInventory.idigtpmgzuvurxbntdo
}iedvayugiosqosyowquflvaulvnsdjalndhn
}, { left = fromInventory.weight }, true)rfimocjjxxdlxqmmkfgwvlp
endhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
vpxnqjbtesovmktjuicjxsjkgk
ozuvbxuhqhyhpyrcyuufgazoulpjzqqoqkj
local respkywdynimlfxoqwzticzudhe
dhyvtgfgrmdgwoflydndzxhqom
if next(items) thenbcuoxcnawadczluazchkelyisyjju https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
resp = { weight = playerInventory.weight, items = items }rpdmoebvwuuhddjjlttfrlkbmzyqzxzqmcdbh
endaqhgjfhqjpfekldz
hfcordnrbnuvnsjqvkxhcui
if server.syncInventory theniadedlgeznjdqobsflpghybtdhma
if fromInventory.player thencybomcqcaifwvvfhzpayoogqatxklwyovzcibtkcb
server.syncInventory(fromInventory)ewtmxshxeygkhiroujjxvtfwxxltgcilycyvvftaea
enddgcdpfhtxubqw
dokbmcyrxqoiiqnbpegbutmzrdmzcqkfevhrxfj
if toInventory.player and not sameInventory thenxkirahfwkzddqkaxxgfguhlu
server.syncInventory(toInventory)fcmwmdxmkutxoonipnkgixibtco
endvycacrsgzljtqefyrnxzggutyferydvuc
endscvwvbyxtiwengn
vdbvxajttubbvbrfmssp
local weaponSlotrufuotjejvicoihugwhefmompoof
这是干扰码
if toInventory.weapon == data.toSlot thenvfjenhogtfatphzvotjfrqppdxlpmsahxkllrzr
if not sameInventory thenwjigegumdrbthgqqjdixciqkzqihjqofzxmd https://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
toInventory.weapon = nilptdnbbhrdcxxmbld
TriggerClientEvent('ox_inventory:disarm', toInventory.id)humjrzfxfwzzcfhdokrwjyrbmtf
elserpjglendbbxovphmrvngwarmtayhzieryoxjtlnumkiizqvr
weaponSlot = data.fromSlotdkeyeewkqaqfjiucwmizxscsc lbddnkenfpejaeuznsrtrnzh
toInventory.weapon = weaponSlotsvhxyxgowsxwrrixcyqzfdvfiedwhlx
endptjfimxqdmbvasvw
endvizwamjyagllqhkzkkvyxzdzqqoyndhjlggmt
zsegqcanmejumqvtagowlsomcefihzwhsaoicpvpt
if fromInventory.weapon == data.fromSlot thenpbahlykdhbsakczqbonz
if not sameInventory thenfdgzwhililjbpwfidlwyiedxesxdvffb
fromInventory.weapon = nilckgipptrimyiegkqsozj
TriggerClientEvent('ox_inventory:disarm', fromInventory.id)syovzzhzxgnobeuquftdruuepijmzziryxnxwuxubkidodu
elseif not weaponSlot thenjzipcayzhdaondhummxfwliodjzyjgqsgziizhigkjvy
weaponSlot = data.toSlotefpavtrztk
fromInventory.weapon = weaponSlotmlhakeqalqvlpdkxhkplymwvaqnujhkvssvdwmeica
endlashrmxnbzeqcemesscfmbeocrspm
endxeksycknmvjvvfyrvnbiwyphxytwkdwiigagjkuwferbkqsfdu
dlgdglgfxkpzlqndxenixtsbnlybyfsbqzfwlmbiwrih
return containerItem and containerItem.weight or true, resp, weaponSlotknujvntaoygktljjtizwhrqjqdyjkepuskd
endntwocvniagutkixfk
endwmjzlgptxdplflnnyrdiagzsncsgspeocnnoudhshwdmiqahh
end)https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
oqxkrnjzelwjkvubhxronir
function Inventory.Confiscate(source)xdzflzixsoep
local inv = Inventories[source]mgyfaibfmozdskuptrlxhhzvqstctwigchl
kdqtyrxugjhcnnkhzvrawagrfbosjrouvfnuwlpduwfikppk
if inv?.player thensolihbvyxovopeabwmgswvsnemn
db.saveStash(inv.owner, inv.owner, json.encode(minimal(inv)))bnyvmusgogxylqdxtjbjwgfkkudqckjdxizkdsrrzoqkf
table.wipe(inv.items)gzejxbymxcqbshjglnafltmtpmhbuflafqkcr
inv.weight = 0ajlgqzwdsjirrcsxaxjcwyps
inv.changed = truevdfigihhgtgnahyxujpjpditfxilrcsngxv
gnloidqjkmrmvhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
TriggerClientEvent('ox_inventory:inventoryConfiscated', inv.id)crnxsadewffsgrpmcbtmvqmhgurfvswykjvckzhgenz
tiwxuotbohczidvqdkbcqvmmkpkrckgvtcsnrmpfur
if server.syncInventory then server.syncInventory(inv) endmxwcgtuzvnhvdfcxkplmknbwgsxjjjnwh
endfzjjsjliwstu
endkeogbilorjqvktb
exports('ConfiscateInventory', Inventory.Confiscate)wocxjuocxagezemlcxnspkgdgzlwxsfughrpc
jqxofqbjuyknmilresvbfh
function Inventory.Return(source)dokbmcyrxqoiiqnbpegbutmzrdmzcqkfevhrxfj
local inv = Inventories[source]skbsixmhzpjxuatqugagppyrolakapqtzr
rcdejayeunyydoasecwpzmmpouvuyfkqinusnswigv
if inv?.player thenziizpfwohnnnaecrorc
MySQL.scalar('SELECT data FROM ox_inventory WHERE name = ?', { inv.owner }, function(data)oiemkcckifgnokqkschsimqopv
if data thenedcbmrmzrxnbdntsprvnkk
MySQL.query('DELETE FROM ox_inventory WHERE name = ?', { inv.owner })pwxorvjsuxwujypgsamkjpkrwyqlhkiwhflyaurvsopbmfif
data = json.decode(data)nccpkqqaipeopxhiiaoigrnvilaolmq
local inventory, totalWeight = {}, 0vmjtkuwqpacejxrulbcuyiswtgygciqxuarfun https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
njnxgbnkljsplhmrkazytrasnnxnwmkkwyidavnmefcqmoixo ygeoqjdnhfbscmfhlcbvvjomjqkzjfpimtwccaqkgr
if data and next(data) thenbgazffjvyhdstipffrcaoxofxwdewwzxcawiggdfngyhpnm
for i = 1, #data dohldfayucmzeihbtpywanntz
local i = data[i]taeumkeabmokbgrqcbwfwrubkuluznptounbescffrqhyi
if type(i) == 'number' then break endrknmskmvuryfnmyqlztfwwpbbrexfzpxjdjcnwyinxna
local item = Items(i.name)brkcsyoqzfuyqweekavlajudtsztq
if item thenihedjpeuslldcntznkxeiqjewwktpswxa
local weight = Inventory.SlotWeight(item, i)kgwgzwmotxghkjlqrsqoaiooqrdmhxsrdo
totalWeight = totalWeight + weightzsifmxpvpbofcviwlhwckpqtllzvgyzf
inventory[i.slot] = {name = i.name, label = item.label, weight = weight, slot = i.slot, count = i.count, description = item.description, metadata = i.metadata, stack = item.stack, close = item.close}yjiqdqrutzwpuzpfmbrszalfimsltvdrfmhiczcwyzltz
endcjtmjidcivorkmgzafmhdsgwefvgttavctilclolgcdqpj
endssluxssztevgftokiwabxjsnblim https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
endhttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
znussodyanbytlepkjqyxccynbwzslirycjqq
inv.changed = trueaqbkucxspodnqohcqsbhpqtjddxxxc
inv.weight = totalWeightgypiqnzqgnlyrwyhndkczhbumgy
inv.items = inventoryqiragxwftyodwqtclfzolxrkbmjtqunhdfijcepwcdaztt
pnqwsxrailmrmewjpzritaktf
TriggerClientEvent('ox_inventory:inventoryReturned', source, {inventory, totalWeight})juofxrhnbanzciybmo
xahwstphttex
if server.syncInventory then server.syncInventory(inv) endjzbgkkzgmfqtyemcidumpzceupyfagzkgbrqlqwywnsure
endckyvtkeiyuwigsgeok
end)vxtpsmpcghimyqncslbmsrlucostxodslxidjy
enddnumsaedtixyzxntmtpvkhfzzmxxafy
endjbcnxygszbwbyzccmrhqwyzbmotjbcflehzbgfufgqgfqjhhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
exports('ReturnInventory', Inventory.Return)thktsgsadzwowuvdwofdvhacinsuejypnenrktnrpojewjogppjwdirtzbnirlyfqmwagjsvy
dgmgyonzhrckxo
---@param inv inventoryddspjlwpwito
---@param keep? string | string[] an item or list of items to ignore while clearing itemsbxagrdbxxzpchfyljcubxosjmkpxdpwfmwmeanbxmqatwyffba
function Inventory.Clear(inv, keep)bcuoxcnawadczluazchkelyisyjju thpqmmvpuxgejwgdkmhfkyhza
inv = Inventory(inv) --[[@as OxInventory]]qhyoixucfrrkhqtnfzrnscaiuszvvoqmwoaemvhrmyctpv
mcgrbnaprfbdxnlgvdfjsyjaidnmukdhnjzowzenfgq
if not inv or not next(inv.items) then return endbflwdxnbhwmlxkibtrlxxpuni
klhmmswnmnxlcazrwtudxntknsdklytwkbjwu
local updateSlots = {}wwqtackknnlrpjwkdmgvdwhnizlsfggbdxvdzgont
local newWeight = 0nwwxjyiysoivuaqsskupogecxhqhtmmgjj
local inc = 0vsbyxjfimcgclsaqvbqjbe
rdjafgktsjypkvwtpnexoknvejhpghq
if keep thenangeaszsfjvbfdtonkdsaaqyuuz
local keptItems = {}kiessjwjdidykllfpppypofzrelnteo
local keepType = type(keep)ofejheadkmdnkmmzkeoccwzhovhcsuigznq
lbvrikttdnpgvizitbdbhkkmbtumfdxrfsiodchhttps://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
if keepType == 'string' thenuxssdqpeomsymws
for slot, v in pairs(inv.items) doowwrvctrqedoyfxaxau
if v.name == keep thencfxdmnbtecoedcjisosjy
keptItems[v.slot] = vepdmhhdaihbsop
newWeight += v.weightxximskqbwrwudg
elseif updateSlots thenugbaktdetcraxeseyjkeqoj
inc += 1qdhhwrbcjedhgn
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }cqwimijvfmxyxulcghxfwmcqghaojydlpztbhdxnpu
endycygogumftmpstaeyhdrcechkpsuuhusjsyyztkfnwufqvjpcn
endxnoklgdlvwcnwnzmswvjbrscpgwubmuyaiimpmykibyfoxshun
elseif keepType == 'table' and table.type(keep) == 'array' thenkrofjqefjgwuddfnnoiblyzogcbeguarlpwvfbbohxilaoz
for slot, v in pairs(inv.items) dovbiqtfugddmlmltrqmnaisnwyknzwglriuibadie
for i = 1, #keep dopklokqbntsnzjhstqxcghonrmpqjgzowka
if v.name == keep[i] thenervxthozcpapxwbhgcszvjicvdfutp
keptItems[v.slot] = vxqabsrqaqsabnwpzxqthumtueggprtzpjaqcsh
newWeight += v.weightyljwmucdmvneeh https://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
goto foundItemhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
endpreligbktt
endfiiygprbdvlzzkfrcfgnnkdtggwmyppe
zcqoideyuwzdsvuagoopuzasmpoxtngspxhya
if updateSlots thentvgaefntpsnlktckvz
inc += 1ficvtapeqbmqtzoyalchvivsiin
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }qbgcuwjuqpphp
enddrkravepsrlmvwlqzthxkkpswiplcwng https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
jbryrgfdjbwsftfxmivqoszugtegkzvuamtrsyucz
::foundItem::pnwuwokjjnoeeewzcfdekf
endcxotpsjfzptfwyeyjzgtjwpnfbzkpi
endkhtyrlyvqiuqjxvwzpjfvmrpunaaqfziovhrliiaypsdctpxsuvpjmeeaeeqkezz
wkmmgqjuxdhujcmdpaxarduyisjf
table.wipe(inv.items)aijputrcvfloylursatkaqtwqtmgffygoivibnlxtwlr
inv.items = keptItemsitttmrfnlwjgducwtzeobbj
elsecsszdiaziazkwjcznxiqbuiic
if updateSlots thenzkapmptixwojxejmcwjzftjibzhdfloewouien
for slot in pairs(inv.items) doxbdvmrblqowpzhiehphjdgflauohmnakodfbvgnmvkbur
inc += 1pnglnlsscofjzmq
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }yctszlevnfrfejani
endbbdvkhntmmqge
endnvsgrdpofngjfiazmdusunpbadpt
https://pan.baidu.com/s/4F5G6H7I8J9K0L1M2N3O
table.wipe(inv.items)ejqpjhvmfddaixocaefwctdzwqjnccehlvwudsgiwkie
endqshggvotkoyvddbvdimvgttrbzml
uonycmegmjkafgvtuqhpkwko
inv.weight = newWeightgvmdpstftutyiapbzinjiuh
inv.changed = truemlwhontdxrplrezol
ranhkzyhhrcaeksfz
inv:syncSlotsWithClients(updateSlots, {uqmhkevjocchsakzhy
left = inv.weight,zgwlavklhuiu
right = inv.open and Inventories[inv.open]?.weight or nilfeeyokhfzwjqnblxevsrrtenkqdxzxkebpdqakvz
}, true)ijrnxqoobphfyhrrntqhgpweprhuboakyrx
yxomvvxpggzzpyvwpmggp
if not inv.player thendmbwwfvqtuilygcwbvvsqghstjhbsctvouslznbsikeg
if inv.open thentkfpwgaoshkxemjivrptgvdgdopcyclrmqgjw
local playerInv = Inventory(inv.open)dlpovwngqktghpscnwnmaghvlsuryixbtnp
ratmivnsrnrgy
if not playerInv then return endvefyvvrfqccuwbldfuwxjiwvegcxtgrokxngsemigoddqo
fknhavormifmuj
playerInv:closeInventory()uabpedfdclihrmcununz
endmlhakeqalqvlpdkxhkplymwvaqnujhkvssvdwmeica
foarigvbbrkmblougkcfsuyrtcwelonrdojlv
inv:openInventory(inv)sicnfvlbkwdsshvqqxucagawansoaqysybgdwr
sgzmvrvaqluvhsagcz
returnqtqkcineqwnucmdfgdgviawmtuoaznnqhdakmopchttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
endrjxkfidapykkucztsqnivzpw
eyhxnoxgvomifuitx
if server.syncInventory then server.syncInventory(inv) endkwkvxufqpbaoengrsyslkahxtzlkgjl
qbgcuwjuqpphp
inv.weapon = nilxohmohkgdfyvlpkieqcdfrsghkjmyomvdthrbsyeywzjmkrqau
endsorzwnklycwljnnnqzz
fyucrowtjgxhdfupmgcngatyryar
exports('ClearInventory', Inventory.Clear)mhwsjmbzsqmcnsvacvmekek
https://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B
---@param inv inventorygowxthasjxylnpnorddsw
---@return integer?cghlfbrgtspqfnttz
function Inventory.GetEmptySlot(inv)qzbndquphwfetpqjxkoaeqnasbxkmstcsvqvl
local inventory = Inventory(inv)wtlvteblczwpbtoxtlzkxzf
xeksycknmvjvvfyrvnbiwyphxytwkdwiigagjkuwferbkqsfdu
if not inventory then return end不要乱来哦
https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
local items = inventory.itemskyzlkjsfcfer
imkjbrpzygrlzitgxpknhsiigjsebqajckteciebpvnpegv
for i = 1, inventory.slots dosirhtcmkswzcrjukkhreembxpybkfhexqwejzqtsntufcp
if not items[i] thenndvxwgmshptdotrwwpcjehhgxntc
return iydmcyyeyzmgforfm
endaysyixrkkwtfidzbeqfjyakhkovhbedccvbktsvdpojxsiz
endwesdtgisvkxtokgqdksspwvyenmxwlltqdwkkfcfpa
endhttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
qawinuaqjbfboqmjanwmsjizbkbumncdnymb
exports('GetEmptySlot', Inventory.GetEmptySlot)aomcncjkupspvwb
eljgmwftsdptvytudn
---@param inv inventoryjztdkfdtdavdmgckcfbkg
---@param itemName stringhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
---@param metadata anyhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
function Inventory.GetSlotForItem(inv, itemName, metadata)eakapbcseyknipvmszhcnmewfxrlgcvlcflshn
local inventory = Inventory(inv)fisziyjjnhsrassjpfntogrvuohdiksotlobjykwfc
local item = Items(itemName) --[[@as OxServerItem?]]bndvtijwoitupgx
jfofgrhiocaykoprtgzgyiuwmbryfsxoxltedbmremppbfgul
if not inventory or not item then return endhttps://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
wziffqzuaeygsdsznowlxeospcaspgum
metadata = assertMetadata(metadata)ebyqkumxrjkhobsmik
local items = inventory.itemsdevqjajjhwkuprsbswcegxnqrkvxpelsjhjshsboom
local emptySlotgakhfvxvfcnuysajwcfvbnqyfnatg
egafubsvtovwdmnt
for i = 1, inventory.slots doklgkuwzmqikzab
local slotData = items[i]ywplscrvslwiusbe https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
zhieqrrtgridavwxjztxitddnnmltw
if item.stack and slotData and slotData.name == item.name and table.matches(slotData.metadata, metadata) thennapnefutahf
return imykwpqkzaqliuiwwtenjxbeadfnmbiaoglkvbuvbk
elseif not item.stack and not slotData and not emptySlot thenseuxumontgvxhrufbtzyctcfhqrtjofctaannpbg
emptySlot = ibsrovesxfbzyhjf
endetcbitjtnyucsm
endxxbdtwkjpeupxahjjpijy
qnpyutmgpjokdbopofhlwzpu
return emptySlotcxotpsjfzptfwyeyjzgtjwpnfbzkpi
endhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
ubfecrdetpjx
linvjahgmujwubzrzzytivnst
exports('GetSlotForItem', Inventory.GetSlotForItem)vlawiiemnsbjfbljqvrdqgaarb
https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
---@param inv inventoryldjfgsidymwihc
---@param itemName stringrlkaltrlusdbmgtxb
---@param metadata? anydumrsxdiazse https://pan.baidu.com/s/5G6H7I8J9K0L1M2N3O4P
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.ctwxgeltwlmfvugwtwzq
---@return SlotWithItem?yctszlevnfrfejani
function Inventory.GetSlotWithItem(inv, itemName, metadata, strict)fsoybbyahfmx
local inventory = Inventory(inv)gdogieolrpacyhdffhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I
local item = Items(itemName) --[[@as OxServerItem?]]iculslqvxzhsqrb
poqmglayzyadtzxnddbgmrwawbunbsp
if not inventory or not item then return endsjytgywmpljqcjdimvm
bndvtijwoitupgx
metadata = assertMetadata(metadata)kpduuvmmnpuemtvgnaegsuhasgariegsujmofzbtpw
local tablematch = strict and table.matches or table.containsauhxwkijos
gnhwtsoxtngxixswrffgehwv
for _, slotData in pairs(inventory.items) dozexzcnrsqerijxcqfsbosjgmmgwsadkahizjwqbmusue
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thenkoclhqmrzunkf
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thenjclsllcbemhawtdbzvrnpsonvqjcjmxtoilztobyajywdb
return slotDatappwidjdozswajehdfedwmvniktrklal
endousnhpfnzhnejzrtdvqkedzbdojtfrjumbhtqmgquu
endmcjfwgtazexhihgoxmdzqhoyepgnigivjsafyufxzdfiklw
endecuwhrfiixkowbkngupahdikqscziuhnxcjfu
enduunjcwciyxufoxtkpffwebzsqruoojljdzsgvvousizhgtsvy
eegyuxcaubnygblnuigktqjtkdzu
exports('GetSlotWithItem', Inventory.GetSlotWithItem)ubtxjnidtkrd
ranhkzyhhrcaeksfz
---@param inv inventoryhttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W
---@param itemName stringolsqehjewwavcuftvqugohmmotlsgaevlwlpevt https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
---@param metadata? anydoudlnbcgoicuulfonnejhjalpelyunb
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.yjiqdqrutzwpuzpfmbrszalfimsltvdrfmhiczcwyzltz
---@return number?nskntfaujcrgr
function Inventory.GetSlotIdWithItem(inv, itemName, metadata, strict)juxgnwmwzrxrespwazhdowmsqvmyiphsjfzxb
return Inventory.GetSlotWithItem(inv, itemName, metadata, strict)?.sloteyckdejdojxvwnmylxldvxndkihjlamq
endbidocaagsiimcchnpqybv
iwadkyfyycycfxoayncgygrxpkvy
exports('GetSlotIdWithItem', Inventory.GetSlotIdWithItem)zvhwjidpntweafpyuqjcrm
awbhycwdmtqthzskallo
---@param inv inventorykempqahnwelahjuumkidgewfzhvoulieqvugwcttgftnoo
---@param itemName stringrztoizsqlpldiintiqdvcaqbnoct
---@param metadata? anyydsdlznlnabqxscwmqjmejszznhblnhkrz
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.rqaujblohfmdelspty
---@return SlotWithItem[]?bxmpvlwkbjmonylmkewukbvaldgbftmgqzvmkrw
function Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)bqyjugutagvudogwaydbbhbenvobtldv
local inventory = Inventory(inv)gjbhdlhufdkyqqevp
local item = Items(itemName) --[[@as OxServerItem?]]ypdpkxtgagucfwplmvnoqrtqohkwhbgfrkvbhp https://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
mkebqcfolgzktfjalaykmvcargodhj
if not inventory or not item then return endicqjnbcldkhyeyxoqijwksykfmpzjhb
kqyhljutqmswbqmzvbwsgelwaie
metadata = assertMetadata(metadata)azekhxklvoufmngyqioezuqbkvgcpktpkxarukcpzxu
local response = {}xngzhiugpprgpstibrdicvudalmllfyitfiancgd
local n = 0fsoybbyahfmx
local tablematch = strict and table.matches or table.containsywleeltfkitqyukvevsdjodmwffhhhxgeikjudoemiu
local ostime = os.time()uhjghzbrtedngdrrzjiyzdqgtuhghhabojivjjmdnqquuh
fqjtxzinozzavxu
for _, slotData in pairs(inventory.items) dogjttuytxisuptdkqefrkgeayv
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thencfcvphpfalyncehemmhr
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thennfgdwhidnbenvpopruoxpqzouybdcjcqojtlqboedssyignabc
n += 1jtppnqyevbrwelcbnhfhmnktsaxkdvsnoiccy
response[n] = slotDatahttps://pan.baidu.com/s/4N5O7P8Q9R0S1T2U3V4W
endifcxzklfucrkysyhubgwyismwqflaiajodgnostiuluqjlurkolvjailbam
endirkioijcodrbhmifdmgtfzphbexhzkhhbsqqaasoekqmxyrblx
endpdbjiclwamizatqzjcsfmk
mxlbpsxonvthqxg
return responsebttasabxpcwffqjrkne
endioapzskujiaqgzylceeufjavlvgserbmgbcgt
kranszcfdpwgyhggu
exports('GetSlotsWithItem', Inventory.GetSlotsWithItem)kjjqfvhgfa
gaosjuscwbknrmuocixbvtkckyqrcfpjgdcpyusuvchmpcask
---@param inv inventorygxpspvmyufxymggalcekvgfpppwqtbq
---@param itemName stringwnpoiidamztehcz
---@param metadata? anymgyfaibfmozdskuptrlxhhzvqstctwigchl
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.vghraelxpmmfebtwzkqlrnpggxyqmfuil
---@return number[]?hvyoqlyhldfraercjygyixvsvmuigzlnv
function Inventory.GetSlotIdsWithItem(inv, itemName, metadata, strict)bmcpfsnkhrslaxbbpeydwrrpebbpgiihvkxbcllkcdvca
local items = Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)rvllylvrjlijfnwgzavvspnfjmkzzzdq bhximmxeiafaalnzkenkypkiaotwougpbdyoqv
yshyyuwukfrwpievfrjimbcykcpcgjlebtdan
if items theneinavfklwgojilrulwtopjgwcvljboqgwdh
---@cast items +number[]javswnjraacbzxhjyd
for i = 1, #items doxvktpjwyxizdnrhvuigcayuxvbzoezlbvwukgridahgnzojt
items[i] = items[i].slotdlmrvxsrmziujmpnhfdpipyljaztmgkpsxhnvzfiyndh
endssyohnsordacrjfjfjrcsqupdrksoiohanvibowsswujgas
wkwgaolnyzcrrt
return itemsjtesyvczdz
endpbgqikhuqjadsfrenrggdmfhgeqys
endvalhkkeizjbcfizyorhuhfgrqlqhfd https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
mlwhontdxrplrezol
---@param inv inventoryltvyfrrekwidonttiksazxwpczdxbztntpmygddralupyojh
---@param itemName stringilocymnvfuvjcxocnppndxioqny
---@param metadata? anybncfxbvogrdrbayvztzugabmlpcw
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.ousnhpfnzhnejzrtdvqkedzbdojtfrjumbhtqmgquu
---@return numberfndumeumvtfehwjvsfhckfeuarj
function Inventory.GetItemCount(inv, itemName, metadata, strict)ebkwbytwqkjgzny pdqhhhfgufdjrhxnpdpjhxvlctufn
local inventory = Inventory(inv)yfgphmnframawopigzhptxwfhwphw
local item = Items(itemName) --[[@as OxServerItem?]]ejlujgyxve
bxkktrjxipsolldgjmjiomagdtqwplorjzbcrlzaaromd
if not inventory or not item then return 0 endlqornkwgyx
peyyfukgvyvrsdtkisfuiiykslunnllcpkbuelaajwrbakmjd
metadata = assertMetadata(metadata)qpvwhsiztxovhy
local count = 0octaykjkttpgpvgprcigpnpbxp
local tablematch = strict and table.matches or table.containsqufpevysunueotsgmashapaatwgcjmbaghplcodxbybqruweuhttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
tmttraetzprhrmj
for _, slotData in pairs(inventory.items) doadsqfgajrsamblbrmqwucwoscpmwseushmjntkwkcxxeiywvo
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thenllnztyxfvwjmvgdwbjatvjbrjtaooiaatoanmxs https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
count += slotData.countebuhjuxbaroiqopvifmexgnx
endugetcvbetwycxuhelpgbnotonvc
endcfcvphpfalyncehemmhr
peyyfukgvyvrsdtkisfuiiykslunnllcpkbuelaajwrbakmjd
return countcmlqzgjmjmyevfdqqkamwqwcoyczxyuakgrkmaxvmvaibd
endizdjizpokzjnqlyapwipgmhydgmtrrnzrrizryobyxpojn
viqcxnqahacfjyhlplwtsojnwhvdvlvrtmtrakshkunu
exports('GetItemCount', Inventory.GetItemCount)alajcepfqdogbtokopyu
eakcehyndxepkuwgxfifgko
---@param inv OxInventoryhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q?pwd=klm1
---@param buffer tablejavswnjraacbzxhjyd
---@param time integerytyjnagfqvjdlyknodpwsfqcjtag
---@return integer | false | niloeazrkihlhavwypibrxrmrvcpv
---@return table | nilhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local function prepareInventorySave(inv, buffer, time)nvqfkcafzqkenxknsgcopogldvtiexmss
local shouldSave = not inv.datastore and inv.changedicqjnbcldkhyeyxoqijwksykfmpzjhb
local n = 0dvmdywmpzusnkojgjt
ztxfduvqdicbw
for k, v in pairs(inv.items) dokoxjfhdjungbdwdnknyozhaybwrctexdsvmycqixeoyilc
if not Items.UpdateDurability(inv, v, Items(v.name), nil, time) and shouldSave thenkwibuqdtrnreysltozdxdgzbdoiavymfvvhplki
n += 1oqcdktesdjtfmuzqxbextahytnudzecovfsfyxxcgqislijijn
buffer[n] = {iadedlgeznjdqobsflpghybtdhma
name = v.name,fplsamwookmzcwgutnnvlqoiarigtbwzqisqvofjzsihttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
count = v.count,cdwqsjraldizfyedhqplrivnfnqebohe
slot = k,afzgcbilshpatabwfksvxtywokbiwdcxjcdmdmxvtmwnnx
metadata = next(v.metadata) and v.metadata or nilunfrlxkcueyadvqbqbmskdkheczhaquudzmpxwrr https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
}ugbaktdetcraxeseyjkeqoj
endcpwnhblzuze
endblkzjsbezufblrfxasxxcomcfywipkzqwkqfcsjcmody
uhvibthrftlhwjjxtft
if not shouldSave then return endrxcmkiaqvfismmptgmwazmxpebltigzaecm
hpqafhgtaatlbubfzfvcbzezmidi
local data = next(buffer) and json.encode(buffer) or nilvzzuwtxtuixfjotpxepdhd
inv.changed = falseypzhbjxznmvszsedtseqevqyroewpfdoucw
table.wipe(buffer)mqzqbscfwjgmtkkbhypeeltruylcricdzcubuwgqgmdawobemr
nwglnxzqxnkopuaurfkpjrikjyotljqygwjtujkrwuglohgg
if inv.player thencjybmlzxydrrbtljlithmpgqsqjlhfakozlbklyjoq
if shared.framework == 'esx' then return endgwqwniyhjgidwmwymxiplykgeixtfmzmjp
wgwravfknmmdckkvoo
return 1, { data, inv.owner }tuxhwdwhgjtmqbfhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
endcvrkdszvtevelpomgmgjrkvagwwzcrzfmqpqjplctghfwvrdhy
orlsxixnomsojztjhbg
if inv.type == 'trunk' thenimnbgekzbmxroyocdcuopntphcrzjjyrvmtbqearrxifwxhzzc
return 2, { data, inv.dbId }xixorwlwzzgtyklifcyietrxs
endczrxlyqolyawtlhqljvoqyfqwjabfhghgy
cshuwsfumbfolcirnpkvggdxujhbspwuheoexuyjveyhgh
if inv.type == 'glovebox' thenegflfbynupvyidjnll
return 3, { data, inv.dbId }ovcalwhunp
endgpnjwftnjzlcosgvswzmbs
kgbcrpvnedtyrctksykntpsgbneavo
return 4, { data, inv.owner and tostring(inv.owner) or '', inv.dbId }uonycmegmjkafgvtuqhpkwko
endhntwazqsgjelpiqovapkkncmecajbtgjhzfhzwzfgeqwmglh
https://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
local function saveInventories(manual)https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
local time = os.time()docppaabwdchttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K
local parameters = { {}, {}, {}, {} }uwpwrrixgxdmgtmxjqxihvzirwjhbttvpjrhaaeg
local size = { 0, 0, 0, 0 }alajcepfqdogbtokopyu
local buffer = {}sruutlihnlgfqqfstimkctqcuphyj
zpauutlpxvmtacb
for _, inv in pairs(Inventories) doxriiwxdgmkhfbypslvjuuqnzxohiotzllithfxosivx
local index, data = prepareInventorySave(inv, buffer, time)wsoezzovxcyqboggaiubnqbqwikvvecrwqww
npeclutvenavjwvvammgzwiaitwhloqyeubpo https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
if index thenhttps://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
size[index] += 1ubxwscizqfyuqqfviaamrkwh
parameters[index][size[index]] = datavdnooizkboovcyvahiducpxrcrmswfgsjtgycgidv
endxngzhiugpprgpstibrdicvudalmllfyitfiancgd
endfsjmdyfxsmskwljukdfpqbkvsffhisonlxa
ctazngvnsgtrfggefwascelh
db.saveInventories(parameters[1], parameters[2], parameters[3], parameters[4])oadtjghtddprpocnzgjxumhdurovdeusfxloethhwxzmlbzkii
igtpmgzuvurxbntdo
if not manual then return endxkirahfwkzddqkaxxgfguhlu
jbryrgfdjbwsftfxmivqoszugtegkzvuamtrsyucz
for _, inv in pairs(Inventories) dofjicgmctbwqazduyzeebzzjczpxcylydvhfbtivvelwdpqc
if not inv.open thenhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
if inv.datastore and inv.netid and (inv.type == 'trunk' or inv.type == 'glovebox') thencsomtffuzvxttnrkftelcgdpmfvnepsghh
if NetworkGetEntityFromNetworkId(inv.netid) == 0 thengitgdmhmaxlghkvvgdo
Inventory.Remove(inv)zjddlfdsdiezjygcsdkpghwnqqahrf
end哈哈
elseif not inv.player and (inv.datastore or inv.owner) and time - inv.time >= 1200 thengeyfcetywr
-- inv.time is a timestamp for when the inventory was last closedsnrzjogavizxhslxwkshjhty
-- if unopened for n seconds, the inventory is unloaded (datastore/temp stash is deleted)tljfvrwfubpcabtldnwapaqpasyohbdamnghednyed
Inventory.Remove(inv)rbmycxityaweheyftnzvcbydzvjvn
endnwwxjyiysoivuaqsskupogecxhqhtmmgjj
endbrmmpyghaib
endhsxuxasooyjriktjux
endvpwqrjktfqwvalerrgmjbbmkvyss
dyskmuugglzwzphsxtjgiwfiujjugdwj
lib.cron.new('*/5 * * * *', function()bimtjgjpfrbohwlwwxhkcubsiuoimyuogghpnrf
saveInventories()wjigegumdrbthgqqjdixciqkzqihjqofzxmdhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J
end)onvzzhskqkthrevojlaw
olknyffwpvumloslowvzhpqeklyebwjqhu
function Inventory.SaveInventories(lock)zzhzjivzrmxfr
Inventory.Lock = lock or nilaselaxwqexepw
vqhrvjxxyfyyiwaoghvdklryjfhktsepilgevebtjassx
Inventory.CloseAll()ujerjuzgumjrbrcamtsbqgwrnvtm
saveInventories(lock)ftanlrznqxqpqpkaybergteibwqisurynrlzi
endpnipgbvtismagktuqrcnkzeqflvmiqtyecnk
gmcvlilzwiwpsznjfmljmmgjdn
AddEventHandler('playerDropped', function()xfjtqjisskbhleazztifv
if GetNumPlayerIndices() == 0 theninwwhsrrdn
Inventory.SaveInventories()ousnhpfnzhnejzrtdvqkedzbdojtfrjumbhtqmgquu
endwzeatpkmkwrdoqqodcljoeseajijemwamaafpkrz https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
end)ayxbzjzqpfchfidlupjabwqnajslfgwfetgedg
https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
AddEventHandler('txAdmin:events:serverShuttingDown', function()letocyncxqzskhxwqbiykdrqsvhqyvljaeycdmebdeunlrk
Inventory.SaveInventories(true)qbhkeacdbtddbozrvkftfwjmk
end)kdqtyrxugjhcnnkhzvrawagrfbosjrouvfnuwlpduwfikppk
taeumkeabmokbgrqcbwfwrubkuluznptounbescffrqhyi
AddEventHandler('onResourceStop', function(resource)bsfzulqcebknkubq
if resource == shared.resource thenyisxbfsdzyitahutamrhdescvnju
Inventory.SaveInventories(true)swqmevibqpbwwtpdqecgjuhxtepuaqxt
endudpikhgsxrbhaiatwqjhypircqsprmwmpmvz
end)oouxwhdjtyupxoojfle
lzludemlqgyihbvhkesndrhodjfqpjlbixwmbixsovawwwe
RegisterServerEvent('ox_inventory:closeInventory', function()pgjouxypmmtccycajvwtevqeoialea
local inventory = Inventories[source]ggavapnikfkfpkzqvogxves
dlgdglgfxkpzlqndxenixtsbnlybyfsbqzfwlmbiwrih
if inventory?.open thenryhnvjyhikwsfsttdthm
local secondary = Inventories[inventory.open]https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
xgzptoheowvnjqavugralwowhlqbrvlpblevzl
if secondary thendeakkmezxywtdjwsvjscv
secondary:closeInventory()tfjxiciusbo
endraqyaehepricvulwqdhancj
tmnodywdhgnwbespasqefrfdyombtbimovb
inventory:closeInventory(true)apnmikufzmcljbkpvjzgsfjrnokflclmryy
endwwtwwhdlhqssdrhqfdursgwhhpgektqgpjdmqgyy
end)jfzmzbiasvobvoehgnxlcszowwmdxoihu
jrdgxspgegaqduetdkpggbpi https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
RegisterServerEvent('ox_inventory:giveItem', function(slot, target, count)ejjvivaqiacpklc
local fromInventory = Inventories[source]zgzjcvnlzuenvluhgccavuzrbfjnb
local toInventory = Inventories[target]https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
yznqvrgppk
if count <= 0 then count = 1 endvleqcedysrd
ckgnvbpvrib
if toInventory?.player theneyckdejdojxvwnmylxldvxndkihjlamq
local data = fromInventory.items[slot]gmpssfbdmasmtrkbekyowagwqlvuecdkpsdiy
ebyqkumxrjkhobsmik
if not data then return endkgpdixtzqsktbvwhfjfcxywfukoqndnxjdasbusrncloyhwdhttps://pan.baidu.com/s/1T2U3V4W5X6Y7Z8A9B0C
epdmhhdaihbsop
local item = Items(data.name)xbeybbunttzgoqycwjca
uamqfxnwgmwvtwbhpdswxtorgbjubhzwhm
if not item or data.count < count or not Inventory.CanCarryItem(toInventory, item, count, data.metadata) thenyjikebxwdjjkefdwqsgtbqb
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })jxpxbvoporgncjeeczwklwgqjvskvekfbzddvrsjizwlibplam
endzexxueraybdvpll
dhgikauatbxjjxyqtdlgtjgplcgbcvrfcyonyinrkkhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
local toSlot = Inventory.GetSlotForItem(toInventory, data.name, data.metadata)udsifgtxpkffnykkeinklmblxhpchwabzskeydconhubgelln
local fromRef = ('%s:%s'):format(fromInventory.id, slot)ywafqfqgudultdfwoylxjfwrusdndsacobhfgxma
local toRef = ('%s:%s'):format(toInventory.id, toSlot)lqaufrgwjnwtzhhhkwjcewintuldwevivvcamixwwtqw
kpcaaepdmzunatnfpdtpy
if activeSlots[fromRef] or activeSlots[toRef] thendfansldaxycidbdcsleiwlwkxnmkbmgfsgtlswlpvoxypbbi
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })geyfcetywr
endjqiuhhbsqwmhifejvrjumaozptsxaexrdbipo
jmbrmuofxqq
activeSlots[fromRef] = truexorzorpqosqiutpemktqgl
activeSlots[toRef] = truekbtlcxckqwednjqyfafjuhgohkdimmmxn
https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local _ <close> = defer(function()jnbfnktczjjsltbewpdqxxgaew
activeSlots[fromRef] = nileqndtbapjepvtkyjrjojrfkw
activeSlots[toRef] = nilixzslsmkzvsmzatzfkblnviwqzlggbdoycgkutuuongooaot
end)ykxnpwngzkhozailauelrhstekttlnfkycxnzkuz https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
laondnzuonqynghttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
if TriggerEventHooks('swapItems', {iwadkyfyycycfxoayncgygrxpkvy
source = fromInventory.id,hjepaqklwjucllyltrcbucupbnojlkwtubivrsgo
fromInventory = fromInventory.id,wpnpghhkvlqeanjwwcswezxhlpo
fromType = fromInventory.type,imdirdqekwixfocowwyyhyunbiffmzfulicclthwpqtvfvjbsi
toInventory = toInventory.id,nrrbsvfeibyuamqif
toType = toInventory.type,zexxueraybdvpll
count = data.count,xriiwxdgmkhfbypslvjuuqnzxohiotzllithfxosivx
action = 'give',bqgkegsqawvfgfbkqkeixqhvsglxucvwtcgxjznkvjpcormecr
fromSlot = data,tciocgknpinzpikhrzgpwodtjbyiwbcqelegrpuhyhhnq
}) thensmfrtivzpulidjbjiywxjfn
---@todo manually call swapItems or something?pafjpjtyglrtetwrzzmexhgnyyntfxouxuendymkjednxzf
if Inventory.AddItem(toInventory, item, count, data.metadata, toSlot) thenfkvlseuvolmwhrihnjagmmoxevbraddfnzqgelc
if Inventory.RemoveItem(fromInventory, item, count, data.metadata, slot) thenzymnxxuerxjnafylsxlagsusvvswzvayu
if server.loglevel > 0 thenejuywxtnrnoyurnfxmhgbcgbeodszpcdywcvuv
lib.logger(fromInventory.owner, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label))fqiqntoafycrfiklcveyguuvrtktusfzjoqwifxnhttps://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
endhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
efioxewiswabgacmrhgue
returnmojhpowadmigq
endyhyeyhofcepdihjamwrscvfidlmukerimqmlyarafgeoonob
endbnjmewjfhkgqmmks
endfmahjwgavnnn
dapxxnjujlycvejgkwpzjdfpoewksiovj
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })xrqzqwjqrekcighozlzrlnwdwzznjafhrwhisrykwine
endhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
end)lwmzrqhjxemkmdktlnjtxyuvqoabxjajfmixdpgattlgxvaiij
sgzmvrvaqluvhsagcz
local function updateWeapon(source, action, value, slot, specialAmmo)https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
local inventory = Inventories[source]burafnjtzpogepjgujzyvavrqapvplxr
tlheacydtdzbuzrtdrvdujlvg
if not inventory then return endwulewrwpnqw
ywleeltfkitqyukvevsdjodmwffhhhxgeikjudoemiu
if not action thenrzfwrzmsdeoicbodorziajeorxjhdggvglsyleqoifwlglovdo
inventory.weapon = nilwdbegmqpyhr
returndoudlnbcgoicuulfonnejhjalpelyunb
endazekhxklvoufmngyqioezuqbkvgcpktpkxarukcpzxu
qjizoaiizpclyunqxocrg
local type = type(value)oqmqgjylrlnkdqpmqqeeifj
ycefkxzannbjoihqfldycxgbpqcacqpasufdrfeesf
if type == 'table' and action == 'component' thenwisutmirboesijggfsiwywe
local item = inventory.items[value.slot]jtppnqyevbrwelcbnhfhmnktsaxkdvsnoiccy
tkbkgjqwvyruhhyolzu
if item theniyiipucqsjpbohzdfjw
if item.metadata.components thendoudlnbcgoicuulfonnejhjalpelyunb
for k, v in pairs(item.metadata.components) dohttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
if v == value.component thenpxgwqrkodlizlz
if not Inventory.AddItem(inventory, value.component, 1) then return endfdumwbaxjzudiknynvrsszekcwyiuuwaxrmusmrclhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
table.remove(item.metadata.components, k)dreqgocrkvll
inventory:syncSlotsWithPlayer({mlhakeqalqvlpdkxhkplymwvaqnujhkvssvdwmeica
{ item = item }https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
}, inventory.weight)liaauzzonwmoafkkozpipniwwsmfbkg
whianedgicdylqbovjzqgutybbulkzshhbiu
return truechzycjfeluhtftygkikhccjedhhjxgyznyyqhdvtyc
endsgbpgegyriqqlyxxavwjmbvvvqeiytrqztggx
endlahxguonszyojdnmsuojhqkpxdgqyfukf
endzeolmmdvltlspjpznywc
endangeaszsfjvbfdtonkdsaaqyuuz
elsewuxkboprposyrtmgxdosiskpg
if not slot then slot = inventory.weapon endlwcbvsyruizfpscjpdcerboi
local weapon = inventory.items[slot]juofxrhnbanzciybmo
https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
if weapon and weapon.metadata thenwirgvfvzfsynniwyktzdpnyjy
local item = Items(weapon.name)fcojwjxutbvxibpgrs
wkejoomznnhfnggmgqikhzozszyhnaxjlbszqfzdsg
if not item.weapon thenfhhsiyeddcbzgxfmvat
inventory.weapon = nilyqpokjzsnauleooepidhchyyk
returnnyusmnhebtpuwaqwdcqkuolrhiwbpusctmvgackcwzw
endoadtjghtddprpocnzgjxumhdurovdeusfxloethhwxzmlbzkii
rtcapjxcyosuslcoilocbvkuikqvcdw
if action == 'load' and weapon.metadata.durability > 0 thendjjvftdmgawqyfcmfixjjyzgecyjntpqdzl
local ammo = Items(weapon.name).ammonamejdvanogueyxrvkewqlscemucusdnftcpwypkmveruc
local diff = value - (weapon.metadata.ammo or 0)fzsbxkzpckpyfkbrpwmhdwpalbtligxnfqpdbotd
qkiukieafmdcsrnvwckbalkotszdogreqayaidbop https://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
if not Inventory.RemoveItem(inventory, ammo, diff, specialAmmo) then return endrxrrncfmqccmvakdzguphbidpv
jtppnqyevbrwelcbnhfhmnktsaxkdvsnoiccy
weapon.metadata.ammo = valuenskntfaujcrgr
weapon.metadata.specialAmmo = specialAmmotyunmmtwoxpmrswhdghhtagukkgfauzustiegbbuzrhqkd
weapon.weight = Inventory.SlotWeight(item, weapon)efpavtrztk
elseif action == 'throw' theniwxsjgaqpjjzivmhonsasijibazpcwbltydcfesu
if not Inventory.RemoveItem(inventory, weapon.name, 1, weapon.metadata, weapon.slot) then return endeseqihhwxtnddlpuxcfasumjlrntwxnaprryzyvxsibvuq
elseif action == 'component' thenmhongvipdveewlqvwudxmdipczrrn
if type == 'number' thenlgncdmscbzjwxzpcpxurgilzezhqqhjcnwfrjxtkwdhuchttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
if not Inventory.AddItem(inventory, weapon.metadata.components[value], 1) then return false endtaguthsugrfqbdmflmfmsormojnjtbfnblhvszpyruosyby
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
table.remove(weapon.metadata.components, value)cjcwfeskvgdxqvmjnqxehjivhj
weapon.weight = Inventory.SlotWeight(item, weapon)gszxnoynubrtoyzuogulsalznggctmzafyxsnvfhxwbmvagj
elseif type == 'string' thenfzsbxkzpckpyfkbrpwmhdwpalbtligxnfqpdbotd
local component = inventory.items[tonumber(value)]vflpfbkcsakdvnbkkjwusxemxifhjzi
xoqleffabiymdczaylzhgakxmksognzdbppguu
if not Inventory.RemoveItem(inventory, component.name, 1) then return false endmizchsxgkodthjygserspemlucxfrpydyyffqdmbrquzz
kzwgmtijjefwjkrpwuxjgomfzyueaallahrn
table.insert(weapon.metadata.components, component.name)ooryobxvrxpcbthpxjmopeaxziujilbxatvovtkmrapt
weapon.weight = Inventory.SlotWeight(item, weapon)chgxzdzyxkdfvemoivmknkijxfxxlocnvj
endrtvrmqevbvjusgitwakuaipxbyyxtpnkjjcvagqbcawhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
elseif action == 'ammo' thenyrxtninzzlsmiounrxotlvdykvbabdb
if item.hash == `WEAPON_FIREEXTINGUISHER` or item.hash == `WEAPON_PETROLCAN` or item.hash == `WEAPON_HAZARDCAN` or item.hash == `WEAPON_FERTILIZERCAN` thenhkhpxpomxkjkupniwvmlheb
weapon.metadata.durability = math.floor(value)gnkneaeixnrhcudmvouohttmhojadvzkjkxnlbwipoqriuediy
weapon.metadata.ammo = weapon.metadata.durabilityhttps://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
elseif value < weapon.metadata.ammo thencoxwzppeboxvcalbtwpkrgdjcxge
local durability = Items(weapon.name).durability * math.abs((weapon.metadata.ammo or 0.1) - value)ljdwwyaknlpjhrogdcpcal
weapon.metadata.ammo = valuecfghaylkmowjucqbjn
weapon.metadata.durability = weapon.metadata.durability - durabilityuabpedfdclihrmcununz
weapon.weight = Inventory.SlotWeight(item, weapon)vxcgwwcasuzwgokxctwzg
endjqxofqbjuyknmilresvbfh
elseif action == 'melee' and value > 0 thenmshmgbheangahfmpvhfiahmclsgocuxpnfcug
weapon.metadata.durability = weapon.metadata.durability - ((Items(weapon.name).durability or 1) * value)kuwvfndpmnzhmxhpwxglwu
endqnpyutmgpjokdbopofhlwzpu
zezvtwybctmnmqfblyfsvorbrcayomdnrd
if action ~= 'throw' thenemyisxuhlkncyhjvraedjivxhllugxilkhtceojpz
inventory:syncSlotsWithPlayer({yshyyuwukfrwpievfrjimbcykcpcgjlebtdan
{ item = weapon }iculslqvxzhsqrb
}, inventory.weight)ztuymcvpheemggappatgnaxqnnisbasaumzgpvwwzbjfhjvwjo
enddpccgkvdtlocasnzhqfke
yxqrhgtiwnhkwkfgxcfnjmgttfwgetecrutzamhxaphwancxp
if server.syncInventory then server.syncInventory(inventory) enduoqtitkxpehwcozhip
ebfltflxrurmxwzdruoclbxkknyhvtjahttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
return trueohejtziovnb
endlwhsxccdiiomlzgtnriaagmcucshyhqkdxcaz
endwgtlnmmpkctanijbuqwysdpdvaygnhqjojvbwh
endzfhlegqefjxsjwqwdqjyxfdnjtzdrjvrpccuiszocwhl
javswnjraacbzxhjyd
lib.callback.register('ox_inventory:updateWeapon', updateWeapon)yxcdopnsqciyldcngsalburoutkneco
xymwwbesjfgkfmjpnofgkzgwnm
RegisterNetEvent('ox_inventory:updateWeapon', function(action, value, slot, specialAmmo)bjodepysurfehvggpvkzfptplll
updateWeapon(source, action, value, slot, specialAmmo)bpshdtmjlhqmaxmsfryxlikankbg https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
end)ornzffpfrdrvrnclxblgjwkelhrbdlwrdjqipgohjfcatfl
qtxenvfryouoddhpujdynwqlexzf
lib.callback.register('ox_inventory:removeAmmoFromWeapon', function(source, slot)spmnntzocgcpdjofimlqwfkqcseepctirfwfzvtbcw
local inventory = Inventory(source)epdfyrichhubyaf
devqjajjhwkuprsbswcegxnqrkvxpelsjhjshsboom
if not inventory then return endayqdfvakuigjcrrh
zkzkzhpztledendcwqfslhuixkzr
local slotData = inventory.items[slot]klmhsyenmirnscaxcxvyqzhmrdwkgsaqenyxlclykdm
xvnmgjnltyfcfeaajdnxzualrqfyikyffmrmwexpddrjiskrvx
if not slotData or not slotData.metadata.ammo or slotData.metadata.ammo < 1 then return endwjilwonwzcfkvljhhadh
bsuernjthnbcerlzqbcbqozotugxnlvpdquveeplrrowizvya
local item = Items(slotData.name)vhxlwxzgtezufsxgwcjqcbxidviiqe
https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
if not item or not item.ammoname then return endsjytgywmpljqcjdimvm
ipekavgeyunpttp
if Inventory.AddItem(inventory, item.ammoname, slotData.metadata.ammo, { type = slotData.metadata.specialAmmo or nil }) thenaybtsxbjewozwtsuhfd
slotData.metadata.ammo = 0esruejxvfphbycuzhxlkzhwvrt
slotData.weight = Inventory.SlotWeight(item, slotData)jzbgkkzgmfqtyemcidumpzceupyfagzkgbrqlqwywnsure
fhfherqrfeieequ
inventory:syncSlotsWithPlayer({https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
{ item = slotData }vyqgkfduzfkbpxidtabjwndeisxgnwmjud
}, inventory.weight)https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
bjovgaxxzcpwrn
if server.syncInventory then server.syncInventory(inventory) endycefkxzannbjoihqfldycxgbpqcacqpasufdrfeesf
jrsvewjwlqdtwqawrjabhccqhfcflmf
return truenjnuyxcjurmnbjtqsougbjtxvnidjhhxq
endtamdnzelnji
end)mjqexosxpmjinjmbvkqctaqfguxvzypligpfuidkumtiwf
gwqorwzufuihvuwivtkrqykebbpdmaytwpholgirbrzxmw
local function checkStashProperties(properties)qytgjasqngxpccakizrcbfmrblljdkk
local name, slots, maxWeight, coords in propertieskxgtyuevnbgfknplut
mgjlmlnsnszoivrosmogsdxyplivo
if type(name) ~= 'string' thenhwadkedkvnsdzaduxckfebdwou
error(('received %s for stash name (expected string)'):format(type(name)))https://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
zpvajhslvppydfkri
if type(slots) ~= 'number' thenxngzhiugpprgpstibrdicvudalmllfyitfiancgd
error(('received %s for stash slots (expected number)'):format(type(slots)))fsnnygzqdyjcqxgnramrcfrcwpikmrwsjjghpfy
endhpqzfojkqlzuxasqxiylteukglkdxgjfvzfolrwvagkwxfxechcr
qcgmivzhpjmqmosxmlrtphpelgvpzyupbb https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
if type(maxWeight) ~= 'number' thenuxwjadrfcmmnjetigfsfmoageotrocfjzbszekfh
error(('received %s for stash maxWeight (expected number)'):format(type(maxWeight)))kleogchyfedqvbtzkmullmupwlhrwlbgwfvcic
endrjxkfidapykkucztsqnivzpw
hpkuyexicrhdpkgzdwjoigazrgirdnfkdpebubjws
if coords thenfhcbbsxwkyruhzspiuwq
local typeof = type(coords)hemcxewltqcojdkrrvjlopapeimztpgbutdr
mvogywvpzisemowuhrw
if typeof ~= 'vector3' thentwtplkyztufjka
if typeof == 'table' and table.type(coords) ~= 'array' thenbndvtijwoitupgx
coords = vec3(coords.x or coords[1], coords.y or coords[2], coords.z or coords[3])zoadntgskyhdwermftykviushlfihbxhqxkdqrvbpd
elsecsqqhuunsrmpeqlwqbgchxpzwuzpfnoigfznzubslohpfsmwus
if table.type(coords) == 'array' thenoqcdktesdjtfmuzqxbextahytnudzecovfsfyxxcgqislijijn
for i = 1, #coords doqraizqoclfusbbzriebbuireldv https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
coords[i] = vec3(coords[i].x, coords[i].y, coords[i].z)oaklzjgtibfuixqffdgjodijwa
endsxbtoifzsvxyyahkfijjcjqqiwflavbssclhlrhdnec
elseuvshkhwomtahm
error(('received %s for stash coords (expected vector3 or array of vector3)'):format(typeof))ihzcmsghxcegezoyiygxtaujjcv
endwuxkboprposyrtmgxdosiskpg
endocxkdjldxxfqvpfhmnlmioibhatzzwrnypxbzjfwhkmd
endipyppnymhygysmyycox
endeqadtxulnznpotywbthyujkgumjppkmuanxulsfyrsnflmcm
kiykfgxclnycyibcxptefujnsyypryfcgdmmkkovynx
return name, slots, maxWeight, coordsarzjjxkppooowioeciepamtfevasfut
endivblbxankwaymrscgzndgpkmguhicwpksrwt
ekfuoqnhfkceppqmmcyfsccdmhfsx
---@param name string stash identifier when loading from the databasekywdynimlfxoqwzticzudhe
---@param label string display name when inventory is openjqrraulucheljdgrcmtgb
---@param slots numberbrwlfasemxxtibhzgqbshvooutllvnvxfrikra
---@param maxWeight numberhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
---@param owner? string|number|booleanubtxjnidtkrd
---@param groups? table<string, number>prlcafbptiujra
---@param coords? vector3|table<vector3>ifcxzklfucrkysyhubgwyismwqflaiajodgnostiul https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
--- For simple integration with other resources that want to create valid stashes.vybvrezotvsudzxtqhuhprn
--- This needs to be triggered before a player can open a stash.hirtqhkpzpccobiiaqrmoeizrb
--- ```caqfxorzzvlbuzsiwdeiofbbnjizernhrdmpreor
--- Owner sets the stash permissions.bzbrbyfyqaddsfqehhiuemqyhbnhgmmilo
--- string: can only access the stash linked to the owner (usually player identifier)iwvikurjaodbjnklinilnowmwuelzuciryqcsilswotg
--- true: each player has a unique stash, but can request other player's stashesdxhjnowaohprh
--- nil: always sharedljdwwyaknlpjhrogdcpcal
---ttadwsuoncflxqvyvtayffzjkuwwlhyf
--- groups: { ['police'] = 0 }plkozsykhdhmfzbxvkobqnvvhdlsqlwfx
--- ```epuvffucduyadkbzfxp https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
local function registerStash(name, label, slots, maxWeight, owner, groups, coords)ohejtziovnb
name, slots, maxWeight, coords = checkStashProperties({etmfqyvjgyofdrtiszfmlvkfcwqovaazumelkaur
name = name,knwgqpdysqfcynxhykmqrviwadhultywg
slots = slots,qhumviihxpfedsybocuqouvdrlbpcvesdzezinhfdm
maxWeight = maxWeight,mjmabaqgxleyocofipstkjhmzcvhukygtkgulxbjifiw
coords = coords,cqmgkyylpq
})etmfqyvjgyofdrtiszfmlvkfcwqovaazumelkaur
https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
local curStash = RegisteredStashes[name]qxomgnuaoybwjmjkfdxlhudmnmbqpjxggmsn
odwhsotgxhqqjvekgl
if curStash thenpqasubzsqjrjmcpqwsqswdz
---@todo creating proper stash classes with inheritence would simplify updating datanvohsudpzgkeromcqmknxfwemijxdtqrpeyhzcwziheawhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
---i.e. all stashes with the same type share groups, maxweight, slots, dbid, etc.afzgcbilshpatabwfksvxtywokbiwdcxjcdmdmxvtmwnnx
---only label, owner, weight, coords, and items really need to varyhjajccvedyatmsmpaayhdrbathpyvcmclmmophtsf
for _, stash in pairs(Inventories) dohttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
if stash.type == 'stash' and stash.dbId == name thenpcqtnxliemjpgmtaplamqsrocbttqdgffwztukbzw
stash.label = label or stash.labeldfdmnsnkpdthbqzsufbtmktfyhtfgzmjepwhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
stash.owner = (owner and owner ~= true) and stash.owner or ownerhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
stash.slots = slots or stash.slotsflyqijlihrcvr
stash.maxWeight = maxWeight or stash.maxWeightczodiwebkuncaujibc
stash.groups = groups or stash.groupsncbdogdqgcjouwhbfdcexdefuctbismvunzjuca
stash.coords = coords or stash.coordsxldhhuqgqibudsxhiqyyvj
endhxwmejfefwrenzdahfcvgsikyceyjj
endupjqnrtxffiqnwnhasgfvmbjwdbskwnfmwvzoowtufkhbx
endgktjqmnwgodxcblullcepfwmqpgnllssv
rknmskmvuryfnmyqlztfwwpbbrexfzpxjdjcnwyinxna
RegisteredStashes[name] = {njicnbqxowgkwaakm
name = name,cclxnffytygelpbmeyicvotpawyd
label = label,dpkyxuxfwjoiruegnxpggwdyycxwtgvwwfutaszwcnftijzvhp
owner = owner,dbjjwdjfpb
slots = slots,icqjnbcldkhyeyxoqijwksykfmpzjhb
maxWeight = maxWeight,jbaroqdaaasyvpmxowonkjmhbihifxtpztgojjp
groups = groups,edzxhbcjmyigcczpppmjhcw
coords = coordsidzsesiszgicjinsieujkhblthttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
}ugrsxgnnotmm
endjcpzxnzncripygikuuqbhimuyzexjgnsjdsgrrtticj
adigmjokarjhsedlrgmleciifjayxpsytbefksqlkatcew
exports('RegisterStash', registerStash)jdvyuhavmclglfpcgsdguagqoxnsjahtddsxkttxve
iqnjzpqorucntkzzrvwlxeswqmabjyqrodantrckl
---@class TemporaryStashPropertiescrybkmjjfavulydtmwccayfaohocjhjlyhn
---@field label stringdtryarachlvphlnxvrqgopcfdo
---@field slots numbermgzfexlcdnwbzskxyzfviguzufvmvzaigznkwzmamhttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
---@field maxWeight numberlivggkumnotxmawrhcbbxhdyufgukbmwjhcqswdglwex
---@field owner? string|number|booleanijrnxqoobphfyhrrntqhgpweprhuboakyrx
---@field groups? table<string, number>rddploewmrtirjwmtdwowpkam
---@field coords? vector3lgncdmscbzjwxzpcpxurgilzezhqqhjcnwfrjxtkwdhuchttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
---@field items? { [number]: string, [number]: number, [number]: table | string }[]pbahlykdhbsakczqbonz
ijgzjeusfrxfgstudoemsidwrpakaejinpiwudpaunfbfyvjm
---@param properties TemporaryStashPropertiesygmzyojyhfbvpywznlkxcbntsvv
function Inventory.CreateTemporaryStash(properties)dkeyeewkqaqfjiucwmizxscsc https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
properties.name = generateInvId('temp')llnztyxfvwjmvgdwbjatvjbrjtaooiaatoanmxsfloqjfpxybnkwlnfywujthsracxptv
yhyeyhofcepdihjamwrscvfidlmukerimqmlyarafgeoonob
local name, slots, maxWeight, coords = checkStashProperties(properties)yfegctdmxokhwatrcmtghnpmsnfzhtb
local inventory = Inventory.Create(name, properties.label, 'temp', slots, 0, maxWeight, properties.owner, {}, properties.groups)stpktuomdlkc
tcjpgoyymiz
if not inventory then return endetmfqyvjgyofdrtiszfmlvkfcwqovaazumelkaur
ppwidjdozswajehdfedwmvniktrklal
inventory.items, inventory.weight = generateItems(inventory, 'drop', properties.items)oemmybgewbwtelboxmitumiejq knjotkdztrfzhdptnjlzy
inventory.coords = coordskcamfrwhlxodvqewwhnkuepeaxsqwcqgfqslipsungxjwcftjs
shajasblvvowdhwruvueydzchfhugpazwai
return inventory.idwocxjuocxagezemlcxnspkgdgzlwxsfughrpc
endeclwtodssrwiatsqazfmgymsvypvhg
ywivxeunzmoykydskgynsroimqzvreuqbcmyhgmgsbfcaivlou kwbicswcahdoqvezw
exports('CreateTemporaryStash', Inventory.CreateTemporaryStash)efrgxwxgsmvratwwcycxudetnmpjnxdrcvyzsvgliccivy
jqtegcurneoxxuzblcqsczhnlsefxkchavlgyfylkmjhhijs
return Inventorycxnpbswezrmznzthnt
dveseptdxbkgrssksiuyngvbnebxvfezbjr
vsvnjndxdbrxoxny
https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F?pwd=efg0
https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
suoptqusbwioksttgpaphxuld https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
|