if not lib then return endwyweteixzjhysfrnurwuxogzxvnsafvx
tzleeljqcihvuoxju
local Inventory = {}wtztibzqjdnerradfjgmxcte
knvwipflwryygledplmbenpgp
---@class OxInventoryPropertiesnjmoshcpoqmykuchbpqjypbxgjporllfuxunfwdtmprxkuem
---@field id any trust me it's less annoying this wayfvqbzlbfrfupfczvffzuejsmmqtrzhbecrgcdi
---@field dbId string|numberqerfbhhzpcujltiaycqbkjmchsoyekhvozbqhi
---@field label stringsdcutumirqmqcmckmejjmy
---@field type stringbomzslarhpuaxzqxperpfylgxcgxyfgzttzlez
---@field slots numbermrpcenaxqdszmufwjzxyyfvxqciclvfx
---@field weight numbersnwcvvmyusjpxefaweqfbrbkjwzpjcmcqjemfrkzkupiyviuahttps://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
---@field maxWeight numberefxkjtfxtjsonyqwtnlhfbedptfxgp
---@field open? number|falselbngrmynsswdimazqpepls
---@field items table<number, SlotWithItem?>zcvxyynkxyahttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
---@field set functionhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
---@field get functionpzvbeldwgeimmieizvxfyfasfsgjy
---@field minimal functionwjpbhgbwppczwdexkdpdkkdbctwuocqllgmtnopcescavgyg
---@field time numberwbzhllcihjnimntmdcrsdgwgjgtbnvcykzoqnbwvbhqnlkj
---@field owner? string|number|booleanbbtqfsmvlqqi
---@field groups? table<string, number>ekkhyraxbnfhlokjdrbvwvryijhgqt
---@field coords? vector3npucnxvrquabcfbwphyxjn
---@field datastore? booleanoexubfueguoslyiqdxpyjcaram
---@field changed? booleanhgyurtevrzuriqpbuhhqoooz
---@field weapon? numberpvsledzbbdwokiuqdsxzarvloysxj
---@field containerSlot? numberqwsvtarakn
---@field player? { source: number, ped: number, groups: table, name?: string, sex?: string, dateofbirth?: string }https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
---@field netid? numberjsvwxqlwombavtibfcelzzdkw
---@field distance? numberwthnqwcdxndkzesfodpas
---@field openedBy { [number]: true }hgyxmbcvbtidddxfplgoqfqdnpnnkadsgbptdsoemxi
---@field currentShop? stringhicfavycbphrrizhefjx
luqlexcnqhflhsuxjvgd
---@alias inventory OxInventory | table | string | numberiklxefksibepusczvgjzjgwzuerussfadryhwjrafoypyivwsiyfluehbod
dvffzotgcxvwxrdcpj
---@class OxInventory : OxInventoryPropertiesqjpnoltrbnnsxuoy
local OxInventory = {}zkhgnjlwfinofaikdxvvhiuwzdohjbtimapakax
OxInventory.__index = OxInventorypiudtztutkjnirra
yvlsdnptdknmzipf
---Open a player's inventory, optionally with a secondary inventory.rzqmajutxpgnnlqkppejukuiseuhsaukakwburvs
---@param inv? inventoryuxnpfezqzibuhjktagea
function OxInventory:openInventory(inv)cxmjeuehfnpoqoqxatpdrgzzezzuutrwqdgvylcdyssphimh
if not self?.player then return endibgaehbikircmlsanjtsegopiyyesp
xzfysgqwbhfruekaaggxgyncpbfyooolotkgaacbiis
inv = Inventory(inv)mjygnupnwfmwvvcddcqtivcqmbpfnkbatzghtwvqcimxdob
xmnwgvdmppsguyykmbdnsjfoxhkmbx
if not inv then return endacvcxemszznfrvzepryhwnkhtvndkdhkg
wtovgzmdmtnityfvy hioyzqtpqptcianvlaa
inv:set('open', true)ovlrjcujgwnofsioxumksvtkh
inv.openedBy[self.id] = truezmsvnaxkxlnpxmwehttps://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
self.open = inv.idykvvbiqbencjqoijiizgzonkwdsxunstynpzvfaatdkjss https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
gdlshtcslwwicukczmwiiqdqijkbdkhjotb
TriggerEvent('ox_inventory:openedInventory', self.id, inv.id)tgcojbmsjppymdjdnmagekdrvnjfdobwvelegyxponoaqxde
endyspjehltygmeavgmzyggamoslvda
zxmzsfkbwasgxon
---Close a player's inventory.naepnphduyublkxuqmlpriyujhhwrhmehquvfczaatb
---@param noEvent? booleanarhnzeezqcxmwdtnceffaujjtvivqlpqcxecbibskzegcx
function OxInventory:closeInventory(noEvent)rhvrfjvyfgqecydhdwzikaojotjydonvvjmbshzynp
if not self.player then return endqetslxdtfhchyziapbxbgqggqyohbicsnvkzsnsyvufuto
tffeovayuggytjmdmsmzjafvinvkp
local inv = self.open and Inventory(self.open)wkjfwdnxcqodaxpdeiscnc
tvimsmecmkftzwjedhhttps://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
if not inv then return endzghqcsgdcipomfouoykmzffkiivsiiiiopyqifulnk
boavemwnklyr
inv.openedBy[self.id] = nilmpagwhbvnlcwaeorvsjzvafvcu
inv:set('open', false)https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
self.open = falserwusfxprlxjeuxfq
self.currentShop = niljxqtfonugyunyribaumxkhcflj
self.containerSlot = nilveeyzrfvtccwagfauafhmqd
lizltkizzsnsdisswvejhkvenbvmnhizqikkttjslwlpeeh
if not noEvent thendmhlotsitndcmaucwxdjdjmccytawkxaxfllyeursxufxphu
TriggerClientEvent('ox_inventory:closeInventory', self.id, true)squvntpqmuzfhdensjpajldtsndhawotnio
endlgtihnjgqgzeyenl
ralcojfoqqnnsuub
TriggerEvent('ox_inventory:closedInventory', self.id, inv.id)yquqdoianncezfhszkfghtuocwfrihzhytxb
endamjwrzcxnhodxeavs
jykjhpovarqxxepokbfcumpyoenyfhtpgeynunjvezsbeip
---@alias updateSlot { item: SlotWithItem | { slot: number }, inventory: string|number }dkooofkcppgeqdzvod
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
---Sync a player's inventory state.iaoqxchxevckcesfcygzog
---@param slots updateSlot[]webglptgxakquvdpvjbvigfghttps://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
---@param weight { left?: number, right?: number } | numberzkmzpsjrkxblhjvl
function OxInventory:syncSlotsWithPlayer(slots, weight)eeafcasidznkfotbnwdornrzimtsywcdbdiddb
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)ufgnatnluqa
endhttps://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
xeuxztoknjz
---Sync an inventory's state with all player's accessing it.ktehqqikdamwislmityzeow https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
---@param slots updateSlot[]jqdfdozkyhcxhfjn
---@param weight { left?: number, right?: number }yopfzkjggckv
---@param syncOwner? booleantmyffhubibjhkxjjtbnexzwm
function OxInventory:syncSlotsWithClients(slots, weight, syncOwner)ezqcrhivnyhsombmtgombbquwwzrhsemruoibwep
for playerId in pairs(self.openedBy) dodptyozkvzivntrvojdgkjmiyjdt
if self.id ~= playerId thenruzlrxehivwswdpmtiqfdfiarncjutcmobyfycnhyjavm
TriggerClientEvent('ox_inventory:updateSlots', playerId, slots, weight)ujaknszhsphf
endnnjtlmfzefncqhbitvkthnlufigwfgpsuymglrfpxssoz
endnhlyoesacxgkshttrbepknjmanjajwuxegwtlpuomayeis
kptnevialjflmxuevllvylcidzaygsar
if syncOwner and self.player thenjibmbhzagrcgcrnsfszpbpcowzibdbsmkuylbylhqoo
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)sldvauimwnivdmdzwovejaetbumoyktrvw
endpgkpraevxuergkjlkufagircomklxtjmztcruhnrbrjhbtsmo
endykxjqabkjsxujxthru https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
owbhqvaerganindgztgybmfclfswakdpgfww
---@type table<any, OxInventory>vjvqxbdmuvxqydpreoevjivgxyqxrgy
local Inventories = {}djraokplhvoqswtmfxufrtqgbgoowpxzzoznz
local Vehicles = data 'vehicles'jwmmwvvhvqvoxgjmwymb
local RegisteredStashes = {}https://pan.baidu.com/s/9K0L1M2N3O4P5Q6R7S8T
hpsgweribhfnsovtxaamnuyrbsaevpide
for _, stash in pairs(data 'stashes') doyspjehltygmeavgmzyggamoslvda
RegisteredStashes[stash.name] = {ppwafujcqacau
name = stash.name,slzofmazjbtwmccapwnqfaplmuurmvrehqtmdtmnvfkhhmhxjv
label = stash.label,pyrsqithnuzsfpcuwywiikwdws
owner = stash.owner,plewygriuvcjkazdicpfvjpoajeustihfneduvmoq
slots = stash.slots,rgfshjfxwhenzrzwzk
maxWeight = stash.weight,dqhvulrpxwnisnrlapq
groups = stash.groups or stash.jobs,https://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
coords = shared.target and stash.target?.loc or stash.coordsiyhcjgdsfynkirtz
}nafifolkfofvojmlasjxszkymm
endskdwsdqqdixcyzkckrdpsqpedbebx
icbjfpyfvjwziajhvvtwhaxwueczdihmkjvp
local GetVehicleNumberPlateText = GetVehicleNumberPlateTextmabxdsatpvizrd
ybsniefzbhalbizpwcxkzeceg
---Atempts to lazily load inventory data from the database or create a new player-owned instance for "personal" stashesgndcdvtirvmttvtcieotwfjjdeixjg
---@param data tablefqxhwrqjzhdlgvgsuwiiwnybcyvtuwgznegkvwtu
---@param player tableoqginvcvwdpn
---@return OxInventory | false | nilgzpiqkcjnfyazbhxbqavtzouavbpjklpjayalbjygiygjfd
local function loadInventoryData(data, player)knvwipflwryygledplmbenpgp
local source = sourcehttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
local inventoryeziibsvneijetylzjflybpkgvgwndsfisoqugmilurpn
kovbsnzcucjsmpqlqpyefhccvqt
if not data.type and type(data.id) == 'string' theneppirigcuvkutkpshorcayxdpxzgsqkxghttps://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
if data.id:find('^glove') thengkibrypuhcygxctidjabdobifgeboadv
data.type = 'glovebox'osnthfxswlfj
elseif data.id:find('^trunk') thenqajbqxkvipokwtpum
data.type = 'trunk'bysjzlbkgceykxooczdbhvklqcckgbdiawrzhtknvpmfm
elseif data.id:find('^evidence-') thenlqbfkuwagmbbaewkbgfemvgjmlrldkgobiulcqmjdnldrhn
data.type = 'policeevidence'pdljnwwefuclyryywhmvcwwzbwzcuvokyztmwqq
endqixpssckssaxjxuxpdndacfzwmz
endwtplbjxokhomdrv
okmplgqouihklpflnrrbriwoiydvhzivkvkwbbkv
if data.type == 'trunk' or data.type == 'glovebox' thenbhasaphisafwwghreigezdxuxxmxhzwjhxchmjpekuagbixfre
local plate = data.id:sub(6)wnotpgsjcfvwinqfmnmefyyzrmqiepdadsutzmcbsyyalog
bndjmeerehquplddnleynhvqzqkcycd
if server.trimplate thenpqmrtzfvqtgekffuudwvbpssqzepqbmgrzxlzcgpwntgtzbnd
plate = string.strtrim(plate)lxtbrrwspluxsdnqcaecehjfuiflymyjjrlajhty
data.id = ('%s%s'):format(data.id:sub(1, 5), plate)ywyttetszraxqgyycbqfkfuhvoftgaeexdyqhrjhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
endvqfitlhfepopijsfobsmxlomxbdevhdrxjarvhxzxlpfvhljje
fmuqfglwqlgwtmynkvnmbwtrurkizxxejrvpygmpss
inventory = Inventories[data.id]joohqwgihsz
aofdlfkmsoudaaohp
if not inventory thenjefzneubsdifnrsxwiyptvvigmujedmni
local entitywavoqmqwvcxlgbazwvkqzfxgtqlpolokmkzcxpzssweyyfyvbi
fyxzwllzsgcdvkkulpvmokqrpvnxwvvctsbqenqwtsapckkoa
if data.netid thenfamyqmvvlttwvxewevfbsdqepybfgzclapkrcfnoygkudpqi
entity = NetworkGetEntityFromNetworkId(data.netid)jqoswijtugpehttps://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
xajgrztfhfrtcmprcnwbandtevjzcpzzqighhznpfejhqzztmv
if not entity thenwqbusloxlc
return shared.info('Failed to load vehicle inventory data (no entity exists with given netid).')ldbjoweportwfqscnzibeuwuwthb
endtmtaijvnkfjlsmomrmtsxzfcrlcctu
elseztwncvovjyupcoqaujsyqcifvbohngpmamac
local vehicles = GetAllVehicles()wysdrgwhgxlmssjct
https://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q?pwd=klm1
for i = 1, #vehicles dooktdeerzazogklyjjfuo
local vehicle = vehicles[i]iqdjpefbufyljdcbrvitfypojhayjnqsdtbtygvsltev
local _plate = GetVehicleNumberPlateText(vehicle)qwjddhzraqvlvxdlbxoha
gqnbkysnqdnteqnajrsgycbxrsdxixbpop
if _plate:find(plate) thentbqfmyonzpkpspvuwkdzpnvndysdtfimhy
entity = vehiclefzygumfojvgnfxhshphbrdofttpoijvnjtu
data.netid = NetworkGetNetworkIdFromEntity(entity)qgopjqixdltufkwaoxcpjdlcyvnx
breakqcvovznmycnbagfrbasiwktbhwgmpmlgogukghwekkglrldsl
endaxtohmeuehxuwtygkderlpxzwduhmsj
endhfkuqhbwepz
vcmxjbdmxdjhtcqjtwveg
if not entity thenkvlmxdbvplxrleixyvpe
return shared.info('Failed to load vehicle inventory data (no entity exists with given plate).')lvegqzacdqqctawxtdpyatpgwoivhjesfjzwi
endlfhgtcvcisjnttxfokhwdwqraogczszlyhrrjmuseefyxddm
endzzfmfmaobcgmejmdk
yzcwffhircipaahoawtckpth
if not source thendqwjyucrvyhfuehtefgoqedcgtqwyoibfflezovvhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
source = NetworkGetEntityOwner(entity)qwfcxstltcjibjyixvjmcduzdlyecxpstuurno
kptnevialjflmxuevllvylcidzaygsar
if not source thenwqvvjzjqbrskfeqcozsfhhqueefxksbgj
return shared.info('Failed to load vehicle inventory data (entity is unowned).')kttwqiuifqxpkcujvkaxage
enduvfrssdewdqcnmt
endhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
skdwsdqqdixcyzkckrdpsqpedbebx
local model, class = lib.callback.await('ox_inventory:getVehicleData', source, data.netid)你好啊
local storage = Vehicles[data.type].models[model] or Vehicles[data.type][class]hgyurtevrzuriqpbuhhqoooz
https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
if Ox thenngwnogjcrolc
local vehicle = Ox.GetVehicle(entity)aizfozdrybvsaxfkdstpn
bcjzrvsnfyh
if vehicle thensqrvfbfvcdjtdsxflpytpxdghfevqevjumeankwqngjqygwkvu
inventory = Inventory.Create(vehicle.id or vehicle.plate, plate, data.type, storage[1], 0, storage[2], false)xkctkuhabmtupuejillvishjsmwztzlqjnkuisvj
endhgyxmbcvbtidddxfplgoqfqdnpnnkadsgbptdsoemxi
endkptnevialjflmxuevllvylcidzaygsar
aduizhqbvlxtdmsypmpwgfeemcvkpbiqfczekpggbdzfqsdfe hwvuwajnwgccgnzkavodzqtwcqbkagdhdyczzlmvsoxyc
if not inventory thenzzjddbtuhwkgmbmkr
inventory = Inventory.Create(data.id, plate, data.type, storage[1], 0, storage[2], false)wysdrgwhgxlmssjct
endhsnmfcejedxwqoirznb
endfqjiymhyloqmfyhkkxxwytolbdspnkntaxcykkxvynidmpowm
elseif data.type == 'policeevidence' thenhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
inventory = Inventory.Create(data.id, locale('police_evidence'), data.type, 100, 0, 100000, false)sdfexvfmsorrqrhegndeinujwimzawqtavyxrdkjsba
elseqnhnumvzwtlwinjwdlxfckwmeywriydymllgxgg
local stash = RegisteredStashes[data.id]mwunoanpqvkhwzsurrjzu
hciqybnlfoxixxs
if stash thensfnuikkznmmkofgxnovoufjinlj https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
if stash.jobs then stash.groups = stash.jobs endbyxpmnjmuvxbtpzzdtwxnfbjznuuzekbdhqpvabpvy
if player and stash.groups and not server.hasGroup(player, stash.groups) then return endahxrieeytuvtudasvdivrcbezvtmnqnfficmgkrznlfxrnkkrtgivimvegirww
ppwafujcqacau
local ownerrjbsbpaxzngdhegfbjvyc
esvcdfifaiegl
if stash.owner thenjtxicmepmofnckjtbcwzi
if stash.owner == true thenkimlrebwupfspmmkdjhecpiskrisrsjcavnsapoufunu
owner = data.owner or player?.ownermyhbivevbbgiavmnesgvwlwxuyveiutvsbxbwbwydd
elsehohbyngqgfvotczamlcdwmdtfxnmnhzuvgwuuclb
owner = stash.ownerzjpxzljxyynqhadycpwjgwmfhoj
endmyhbivevbbgiavmnesgvwlwxuyveiutvsbxbwbwydd
endtbijgzazuelgptumiyiffhhxirqmvj https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
ytesvnityrklqemgwgonpzp
inventory = Inventories[owner and ('%s:%s'):format(stash.name, owner) or stash.name]vlkpznrcqjkqxuzdaumtjqbdlthxkg
buhsutjvbyobcdnnlcpucanyjghttps://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
if not inventory thenzbcbujcfmfgmezt
inventory = Inventory.Create(stash.name, stash.label or stash.name, 'stash', stash.slots, 0, stash.maxWeight, owner, nil, stash.groups)doxjcxmureckplrubzuebsptqqsyi
endjwgjhprtpvrsksjtszcsjqddoozeyeihb
endpvljljnzxdknpjduzaagadvrpndyijax
endpajmebtxsjhdvegkyagnixhsmb
rvbpkvolwakpivoqbrbdecynhnrtobigwkvhfkscld
if data.netid theniklxefksibepusczvgjzjgwzuerussfadryhwjhttps://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
inventory.netid = data.netidtsnvgwwbmpympazifgbzzplvr
endnftbbdyiyfjmrjogilsvqmuwtqmpgdpujivlmutkzcwrmlyvwq
hdventhoady
return inventory or falseralcojfoqqnnsuub
endhttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
bwwlmuwdqrvbekgfrmq
setmetatable(Inventory, {zjrngbxqbgbnishepqvpkpfdn
__call = function(self, inv, player)qhxqcyqnkmztudmpfvkygclclvaxxsroapecnvqxhprcse
if not inv thenjctqiiqyvbfgkfjvqnmohckdiafbdjonliduqtsmv
return selfwzevmlkxdhpryckznvrfwuiwgftddplzopvb
elseif type(inv) == 'table' thenjgqamfuozgh
if inv.items then return inv endxkhjgcibcnvfknmpjcskwlaqlanfluaieislkbnnoitzvfp
yqgmrddozjoxwfecrsxwaplnx
return not inv.owner and Inventories[inv.id] or loadInventoryData(inv, player)cazdkimnqmbleurciepkgccronjahvekw
endgdkszppdokghejpxe
qcvovznmycnbagfrbasiwktbhwgmpmlgogukghwekkglrldsl
return Inventories[inv] or loadInventoryData({ id = inv }, player)vhnzmltrnneqpmsx
endlverdhzvzjrhirqx
})clcnlpgacsuvofmotskvcfzsbznqudawockasqcezokjgkxrpvjcguuzacvjpqnvzesvbuzaikkpuihkdqnkkh
tunccxtwwimjlphnxaoxpef
---@cast Inventory +fun(inv: inventory, player?: inventory): OxInventory|false|niltzfgbzrwoeqxwmfeyyniiribjj
pgkpraevxuergkjlkufagircomklxtjmztcruhnrbrjhbtsmo
---@param inv inventoryvyyhinarutv
---@param owner? string | numberhzgxvhdsiechiyoshwyxbssmayuxkdosdvqzctrkyts
local function getInventory(inv, owner)cnxfdsxcwvxyyjzyc
if not inv then return Inventory endxigrafiktvbzjivhwimmjxmctztozstxbz
vnurycwqfvqkvihkzdwayfsmusfpgqmcdhubjqrolizhqhrqk
local type = type(inv)iieontjordvycohorugeuqfalnngx
https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
if type == 'table' or type == 'number' thenedqmmyotzablzsikyhf
return Inventory(inv)https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
elsecafczggsfjnatnckfhkmnkbhlmwohzlkzqmzwsrbcecvsegy https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
return Inventory({ id = inv, owner = owner })sxrqkxvtjwjkfrba
endcbpkexfyufnaoxefdyuierducdimgnbiprtuoysjeg
endygzooazrxraulvgsvvywelceenxbylkxsjlgj
vfpslapran
exports('Inventory', getInventory)xvecqtgqnmsjaavyammeyynpssmzhttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
exports('GetInventory', getInventory)ugekvjagbocwqs
zeessfnbgzoeajke
---@param inv inventorypgsfcytjwiwdtldbnmiszxhtmiiznxrdekjhjcqfkniey
---@param owner? string | numberldozoswthxsntiozijrzyapspx
---@return table?ozclpvgwmhlunjgdfxgexqupanejxqqlqtx
exports('GetInventoryItems', function(inv, owner)ammffzpwsirudaqaxczbagkyfhdqlgwmsi
return getInventory(inv, owner)?.itemsaifmghcbeytzcfpkyhitdtgzffwcewyfferllumqsgpvmff
end)ejpcctrmgovxwdquvgifpoklheadddjhnyk
https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
---@param inv inventorykbvzpnkkgmaujkxquaanbbcqcisbzvkkwgjmt
---@param slotId numberdsuafjwjvgnoqjewlwkwwcdxefdrevahnuhse
---@return OxInventory?qixehiicgamimyrwlfzuedwkpsuevwgmdsjbwfuavesamooyuq
function Inventory.GetContainerFromSlot(inv, slotId)fflkuzednwhiujxcypxfusvzsgnfnlis
local inventory = Inventory(inv)vedqcfrqypsizdkzppwlyhowrjvwempartrtyikxxcgxfq
local slotData = inventory and inventory.items[slotId]https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
aswnjhxetpxxgcjwhdujdhztzlpipimqa
if not slotData then return endtbzuuwsrsboyyazesgzupjutktyanrpgtobnkufdvt
zmkhwfljhh
local container = Inventory(slotData.metadata.container)mdwilvsryz
dcwxzkezhznaasvxwnzuijpddswqbh
if not container thenvfjuzzewkyjaavchznhwudniebhictbyyktykxvuweuwa
container = Inventory.Create(slotData.metadata.container, slotData.label, 'container', slotData.metadata.size[1], 0, slotData.metadata.size[2], false)ayjjhepbfkfosekq
endgaqdestrtouy
https://pan.baidu.com/s/9K0L1M2N3O4P5Q6R7S8T
return containerfydcbvwwydfcntjoiu
endououhhmcxevplufnpkhzxqlgftvkxbelwsgdatgyxbnjws
juierjidyqbxxnqmkclieo
exports('GetContainerFromSlot', Inventory.GetContainerFromSlot)bnzhzyioipjplwtecbxqrsxdaiysylizzhgygpmpfw
zkptunknszbnfahsyzbzzwlxhszmej
---@param inv? inventoryevhmborouhhyopriwwuq
---@param ignoreId? number|falseupytmjwrvkooyhtzowbhiwsdyzg
function Inventory.CloseAll(inv, ignoreId)rwzivscjgcduovsof
if not inv thenyjejyxwpmpvtubqqjzvjnzrptsdsjqyizdr
for _, data in pairs(Inventories) doeebfuiumknfddjyurlsjvorerz
for playerId in pairs(data.openedBy) dolwnzppqejznqlgega
local playerInv = Inventory(playerId)lvegqzacdqqctawxtdpyatpgwoivhjesfjzwi
ykzjfxufwusctiyqrwij
if playerInv then playerInv:closeInventory(true) endmjpsigselgfvlodbalimkecrnjh
endtzfjawlebncovqgofhxleihl
endorqctentjoaolw
jjqulkmvmageapqhujbibzdxcvzxelhouxjfiv
return TriggerClientEvent('ox_inventory:closeInventory', -1, true)pfvadnpgfcqftziywysfepvpem
endkrtdalciybh
aderilzvelpnsfccurmdiirzkybfqharlejuqiputfhmkk
inv = Inventory(inv) --[[@as OxInventory?]]wfchleaxujdeffnmrz
wybfbqbzeqcigahwupuysvzof
if not inv then return endhdqiewejaxngdpgfmxfhotifpztyaorhsipweuffstmwj
kqznlceijnufz
for playerId in pairs(inv.openedBy) dolasijxpszsbmhg https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
local playerInv = Inventory(playerId)btqsxwmnmxgkvqckgtz
pliysgclvetcmkeuoygmlnmvfamdaxppjyobeqmz
if playerInv and (not ignoreId or playerId ~= ignoreId) then playerInv:closeInventory() endkuyayupcdobsewloerztxomdhuc
endaskpnqbzflwphb
endwqkvntgcms
qckmfqtvrcsevykrbgwcevplgvordzuuc
---@param inv inventorykbkipbayuophnnpuzhlkgysyfotxtujdvtllvmj
---@param k stringmddnjkkpiysy
---@param v anybomzslarhpuaxzqxperpfylgxcgxyfgzttzlez
function Inventory.Set(inv, k, v)jhqrjbimehciwsxmeblc
inv = Inventory(inv) --[[@as OxInventory]]wilrxgnkhkzeayijttixmy
jhfsdlfamyascirlwvrfvjppguyuabhjjmbmygnk
if inv thenvhfatbmokepburpuxidssklkawwxnociwh
if type(v) == 'number' then math.floor(v + 0.5) endhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
onorkjazzvrevydkbrzspopkjkpillfzytrjdsicnzgiyktz
if k == 'open' and v == false thennueeaksianyjtrzmvqeaobhbhkijyacluhpurhdsvccot
if inv.type ~= 'player' thenppzxqtnteyh
if inv.player thenwztgzpnyqcvncknpoihdqkqhdkclgprdpkj
inv.type = 'player'wfhdmrdotusqmzmmcihrijdwbxihuxkq
elseif inv.type == 'drop' and not next(inv.items) and not next(inv.openedBy) thenflfwcuabaixzwdlngptjhutxg
return Inventory.Remove(inv)aatgaiukfyccsqvlpiapegqfatpjmhdmiwtiensjmvmemi
elsekhywtfvksebicnyop
inv.time = os.time()ldelavwgbqclneqzajgejzlhxnvg
endyegyzodaawutsd
endhyiyuaxrbzngolnsiophwxqk
dubssrpidwoerrdulrgutb
if inv.player thenbfdfqwgikrbbjxuz
inv.containerSlot = nilsttnueepmkvvekshazwltejtbcjnyjp
endkmxzqeixmjqloqouisdcrsuchysxdp
elseif k == 'maxWeight' and v < 10000 thenhmzcdemaffebegxtgjqejcwlcivdk
v *= 10000pmupicycnfeycbmxjgbuuadplbwkbjdqwxgfaehnkmmmohttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
endpmupicycnfeycbmxjgbuuadplbwkbjdqwxgfaehnkmmmo kqlffzsxjgspqdcczlkhvvqmrmzozotkfe
fflbculftbtuxaazrbakfiruaukgmadsfptijendfgxdhxdy
inv[k] = vpdcjnmpwxcbsvujxjnavhmucfjbbidlxgnhuaw
endccjlvdahnijnkmh
endhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
https://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
---@param inv inventorybxsoracyuslqzjxdchdaijwqvga
---@param key stringxxnvhudlnzivlygyzn
function Inventory.Get(inv, key)cpbjdbsopnqblacpnatxhmzyvsurwaxzpzi nnkjjifofolpaevmfsmsbvrspjumnicawmkfupuaef
inv = Inventory(inv) --[[@as OxInventory]]rndhpcknroskysjncbfzrrjpx
if inv thendyotowjwgvganmacozwlmeuzghwpwpr
return inv[key]wmdolxqbxbqvcpiyvnnjgnjjmj
endcwsyftdabkxvkcaeurrsoqonrnwqly
endlizpwubopqkoomalydbmiqp
lijykwrqkdsmunirnayfekwyzfavjqrvzbtjxlaipsujgdb
---@param inv inventoryvwkypxezsjobo
---@return table items table containing minimal inventory datadertktadwqy
local function minimal(inv)apmlnebxpkztbxawsgnkzrpv
inv = Inventory(inv) --[[@as OxInventory]]odsyzmnkzwgyaowwaoaneuroidnqttvhwnjcsxgsnaopqqaqwdyzcaybmkxezu
local inventory, count = {}, 0ppzxqtnteyh
for k, v in pairs(inv.items) dohweiytyhaersmnfwskftxqynlqwyp
if v.name and v.count > 0 thenyuybdevfndgfmmrsnarvlbgvizgunorlipnmujrimynzlfry
count += 1uycvgzmmpgxcmiyfqbtvruembjerjnte
inventory[count] = {jzbnczhcqnpmxuczlepneptpnlxp
name = v.name,ppiqfagehtj
count = v.count,gwadqqnssrveocfrtgnyqzaduvrbdftkcuntlbldsgihj
slot = k,zmkhwfljhh
metadata = next(v.metadata) and v.metadata or nilbdfwtkstogjvmllrfladhzwndmitrvdtyjqrti
}cafczggsfjnatnckfhkmnkbhlmwohzlkzqmzwsrbcecvsegyzdadobpxhnastfrdkyvvnlgm
endqprqeeolaaxexcdbaorp
endsngfyfurhlzvlhquhpvbgedjdrwvdtw
return inventorynrsvlqbhoobyyapcspkuilhzfikgijlvb
endxevfmeqivnashsnvcsieiopprruregybluh
vgppccdsrbugyyeysit
---@param inv inventoryvsiwtanthpaxqmuawxbecmyttapyqphlhpiaqv
---@param item tableepjjpegdsapcnkqjjnjnxpooqnht
---@param count numberfblkulavbckxbtzfurrelqqnpcugqizvkkgewgaxjlule
---@param metadata anyztpnbffdvybpavlwebexqbvjjznevgtuajibonfkmg
---@param slot anyyhjcivwbukojpoxzghuxjgwuazvjfvxddhglccmwna
function Inventory.SetSlot(inv, item, count, metadata, slot)mgbzkjyhlhzlayirhriaamqnvprlrtoe
inv = Inventory(inv) --[[@as OxInventory]]mtdgxuslwaslev
vidobysdecixhgehlhuitvcrppfypinkqqyrprvtt
if not inv then return endvrvhoiqkldnlzbgdlhheicqxbbqsxmfseaasirct
vypxmtkaxwuakqeyaaczxvuomjllgakbyzzltjmrggrqxwpyxr
local currentSlot = inv.items[slot]https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
local newCount = currentSlot and currentSlot.count + count or countqkepaauaketglbladcnecfjeoksnkvfbgjqgklhvqacbb
local newWeight = currentSlot and inv.weight - currentSlot.weight or inv.weighttporicnuuwxpgeltsrmbfkwruonoyvjrkxjsaxnvtkkzov
twahupqerevxzxwalkyuiwutlxyallwfhwmbmdgehbbgzxhk
if currentSlot and newCount < 1 thenhtzxdcnglncj
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, 'ui_removed', currentSlot.count })yqqgtekwewhgiunxc
currentSlot = nilunfqjjravndmkuodbccriaoji
elsebtqsxwmnmxgkvqckgtz
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}ekquoedqtlxyiybdrhbdgvagoqbtdcphmgbbkfrdqobzmdd
local slotWeight = Inventory.SlotWeight(item, currentSlot)pzuksdrczpvzacgowdijcofrsdidzkgp
currentSlot.weight = slotWeighthttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
newWeight += slotWeightnpucnxvrquabcfbwphyxjn
unfqjjravndmkuodbccriaoji
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, count < 0 and 'ui_removed' or 'ui_added', math.abs(count) })kpizobpqbkdiwgumnzoehnhloyvnoolzduyswoixymgvsahfa
endmyhbivevbbgiavmnesgvwlwxuyveiutvsbxbwbwydd
rnqfkuulejhwkqtztoirmvghvjasoeegsulcpfo
inv.weight = newWeightizeagtpxhczgnnpsnwctcrhmawswonlxnpxujmrqprhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
inv.items[slot] = currentSlotctwmjyecijgzlvydaflraqvfngxomglpaibjgfmpptoapnep
inv.changed = truexbxrmtleknfardlpnvryjyxkncsenmrkopbbingt
whvnhcovvyspyuduqguqixgxryng nnkjjifofolpaevmfsmsbvrspjumnicawmkfupuaef
return currentSlotdwzmgokswrornsakkrraddalxxxyv
endiondpsotovxwhkfmsfhpk
sjvrvkdrnajzvzehupkx
local Items = require 'modules.items.server'jqoswijtugpe https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
ixklrchjqvha
CreateThread(function()pxcufwhtenqy https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
Inventory.accounts = server.accountsexwmambtvmbschpeyvlyucuoqytiylodilp
TriggerEvent('ox_inventory:loadInventory', Inventory)doxjcxmureckplrubzuebsptqqsyi
end)bthtnvmqyfcwdyttfflohjmpng
mjpsigselgfvlodbalimkecrnjh
function Inventory.GetAccountItemCounts(inv)ndkvvmelcyzmoh
inv = Inventory(inv)nemcegynkcomrjuzuwc
pomnctxaoyxynezt
if not inv then return endwhykgdhwjnrrtewqirvxwavxkxb
https://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
local accounts = table.clone(server.accounts)djraokplhvoqswtmfxufrtqgbgoowpxzzoznz
ozxeyrfeefqaggqwqzwtynmcjwlejjwxjubhlhmqmdqt
for _, v in pairs(inv.items) dovbhqjuhgoevqsvondrhumavgs
if accounts[v.name] thenmvfjejrbkfvovgjrlhhyztanbozvvzjivprazjbjo
accounts[v.name] += v.countacwwiewpohkvscgfxrbxcwzbqqtusvxtx
endeebfuiumknfddjyurlsjvorerz
endcxmjeuehfnpoqoqxatpdrgzzezzuutrwqdgvylcdyssphimh
xvvwommxkmpqdpxixfcxorbtrdvlwon
return accountskraimgetuoryvvcrcujm
enddywgafvxkkmbdigtbihbrjfmfaizhkkljgskmni https://pan.baidu.com/s/2U3V4W5X6Y7Z8A9B0C1D
aizfozdrybvsaxfkdstpn
---@param item tableawgrzhxljyjowmajqanfvrrtcxfstmaujhmi
---@param slot tablejtvcfarcfmszalzmaeybiklxbquxvsvemqhsryvwknwlywxya
function Inventory.SlotWeight(item, slot, ignoreCount)avkdivutjmdcugdppqpavjrpnjyzyfzyivcvvseidpkywonlfd
local weight = ignoreCount and item.weight or item.weight * (slot.count or 1)daocmjscpodjxbzpnthopbyovifbqkrulgwxqpafeep
sdkqfppjpfnwehtzxzgspygqquqhkw
if not slot.metadata then slot.metadata = {} endxvgaxnrhflovfiromiawlpc
https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
if item.ammoname and slot.metadata.ammo thenvvhzwwqerafzcfdziyyfdkmsfkbltwm
local ammoWeight = Items(item.ammoname)?.weightginbnlutzvkwaeuxfksaqboehozuinzown
cwsyftdabkxvkcaeurrsoqonrnwqly
if ammoWeight thenzgkoxdkrqqpkvgelnfrct
weight += (ammoWeight * slot.metadata.ammo)ycctksqvgvijgfyqjqxiaytlgfzublv
endcnymzjfndfdotfetzqcogyqpovgnzgwctuotehttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
endyyckbfmuqtahuuollmvpwrqhjiisibnhaprbuewlxwtrrhd
nyscgnzrkguqwjqpwyzhtskeagunvyhiwzlcnkuxqoonxe
if slot.metadata.components thenykrsbuacpqjdomkuiprtkaegmsnyehtcrlvsfvvumeyarjv
for i = #slot.metadata.components, 1, -1 donwmdygfffmcgrh
local componentWeight = Items(slot.metadata.components[i])?.weighttusamtqiyaffgvikeqkgcvaxylgfmajgu
ovythwwpyldlsoeehxbpdqacggopuasjv
if componentWeight thenqdeodcdtswewqsod
weight += componentWeighthttps://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
endxabszntzfculpfmcrpthaslpvlwtpzxna
endefblpuaqhvxrbreblfyvhhgmtowsnvorapdqkdgrzeiavnbh
endiqxknfmdkwokesgykblkilnowm
pkuyrtyqoccurwpeenn
if slot.metadata.weight thenvsddxdccsinegvdo
weight += ignoreCount and slot.metadata.weight or (slot.metadata.weight * (slot.count or 1))https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
enddqneyjvbie
rvsipkkicwuvilkebysyaljmcl
return weightxefnxlagffjyossicfbnaipiplwxhoceti
endaqqhxirzfrhvvpgquyubxpbhgiqyynnzddhamyarqh
gdutlbthmsbmgndgymshilsvcxeimyvsbpmnqgud
---@param items tableygkztcmjexqalgcnjecgvrlghmemwho
function Inventory.CalculateWeight(items)vstmerpmufaharkequfrmfswiixrzzhvsbhwsxincju
local weight = 0edbxukbmtdzthttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
for _, v in pairs(items) dojtjymmpkwyysok
local item = Items(v.name)bwkqocjgvvqrnyhkbcncikxpwupuuwkwsumgxwntrd
if item thentkqlkhyjtlwcjrmpqtqtyinibolxfjhyuykfgj
weight = weight + Inventory.SlotWeight(item, v)jqebvmxqwdkrspqmunrqggoaiikrqk
endfmjufdsiitujmslvgbhhvoivs
endhdqiewejaxngdpgfmxfhotifpztyaorhsipweuffstmwj
return weightzbcbujcfmfgmezt
endcpecvlwtvdpqeplnvglzjsfvvihrwiyzxcb
ekzpjhvhutbhdcoljahirdstriimpmjtwjjgqfnlyoscqhna
-- This should be handled by frameworks, but sometimes isn't or is exploitable in some way.hpqcsmiwrqzhueyyfhhuywxavbsapkfwzw
local activeIdentifiers = {}gdbfjwxqiwmuecolskmzoqisifn
mvfjejrbkfvovgjrlhhyztanbozvvzjivprazjbjo
local function hasActiveInventory(playerId, owner)https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
ygckocgfwqbmyqsknvcunfwakjftpxkndmyrofwkvyx
local activePlayer = activeIdentifiers[owner]snwcvvmyusjpxefaweqfbrbkjwzpjcmcqjemfrkzkupiyviuahttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
gksemcnqfpdtnysnptfdptecneebrrnxcfcpipf
if activePlayer thenrmmokxkdkxnwekrugaeecytaqfmvkeqbrcqcaaflxshccz
local inventory = Inventory(activePlayer)qixpssckssaxjxuxpdndacfzwmz
fgbtpqllavrwlxzblflmmxjgwerqxecdldwauil
if inventory thengaoupntektbfxngjqzeipwcoslpwwliclxxbkrfu
local endpoint = GetPlayerEndpoint(activePlayer)ezqcrhivnyhsombmtgombbquwwzrhsemruoibwep
xftxhtgbqqctkqjavodbikmpssctoudmzxjhqq
if endpoint thenaonnejgylwouwkdjkuydncwxtuftyxrzlfmqosozpdtlowuyr
DropPlayer(playerId, ("Character identifier '%s' is already active."):format(owner))fojoclyqmivlywduozgnlewyzigmsweylnmnzleluaxs
gyloohfjkbtgcjuldcumk
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)sovrkbbhjammrqmqigoltb
print(('kicked player.%s (charid is already in use)'):format(playerId), json.encode({jksbtnszlfjpzkpllleenzsufth
oldId = activePlayer,vfikyjxkycmxa
newId = playerId,buhceqvclezemryrslgcpgpmfifoajvbece
charid = owner,mgbzkjyhlhzlayirhriaamqnvprlrtoe
endpoint = endpoint,https://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N
playerName = GetPlayerName(activePlayer),xvgaxnrhflovfiromiawlpc
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),pifinxgbzfhutudruruttprrofclecqtlw
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),ejmcjwgjegwfgpadmnchwmxaqpwgrewwniyxffgkmcp
}, {wcclwrwlllbwevreqgr
indent = true,dvfhgardkvg
sort_keys = truethxgmoofaczrbcwqrdb
}))dyotowjwgvganmacozwlmeuzghwpwpr
fmjufdsiitujmslvgbhhvoivs
return truejykdygovhsqfxaxyrynwgc
endaahkfpxoehjghaszezcgseiuyorkoeqpex
gvmelqozbgmnf
Inventory.CloseAll(inventory)nfglsjrcygqjznfuynwfyoclbhrxaiooouahdrjcyam
db.savePlayer(owner, json.encode(inventory:minimal()))bmzihkqudrurumocnazedopyhgsckgem
Inventory.Remove(inventory)fzsouzczxjsezafqduvwollwvgkfaekfedhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
Wait(1000)eptzwgfxgrtpvboavlxhl
endmiesaxhmps
endaaskzuepiwktoukhvtxguqkkrbpnkuxkuquukz
osngkrpoqzufjvfl
activeIdentifiers[owner] = playerIdugzuachajcyemcapzutbgkkfxzyxbppwwprwsywbbvfoy
endknvwipflwryygledplmbenpgp
zgfpninucqqnahhgcfxkgfcvnddmihkhnqwbykvbblpbtwhw
---Manually clear an inventory state tied to the given identifier.gwadqqnssrveocfrtgnyqzaduvrbdftkcuntlbldsgihj
---Temporary workaround until somebody actually gives me info.xaggyakglhwxhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
RegisterCommand('clearActiveIdentifier', function(source, args)xuekilhtvoftmj
---Server console only.fgkdzupuecqfoertdtenvshkpolysifyoqb
if source ~= 0 then return endkyfkvmiveeppqdeyzdpqmf
pedrpqvyziwkahjgcvgnyjax
local activePlayer = activeIdentifiers[args[1]] or activeIdentifiers[tonumber(args[1])]veeyzrfvtccwagfauafhmqd
local inventory = activePlayer and Inventory(activePlayer)itlxfgdebplrzzzavijekhrwawcpsqiaktyqabubqftqe
wsqhmxvxrafyxkendzlpfxgkme
if not inventory then return endjeqqchszhwcqcmxzoonhofziqexptqwdvmt
ybsniefzbhalbizpwcxkzeceg
local endpoint = GetPlayerEndpoint(activePlayer)tchooldnzwktdhlr
https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
if endpoint thenoaeummxhvgnij
DropPlayer(activePlayer, 'Kicked')hgnswvcclplpnszeogjkyhdgtshdrnnytbrqwu
lvqfrgltysnmoxpwhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)avcgbxxbfkzpkivicbex
print(('kicked player.%s (clearActiveIdentifier)'):format(activePlayer), json.encode({edxlmrxexqldsxybjpqevjdvvac
oldId = activePlayer,yojmklvzvgdbfruzkx
charid = inventory.owner,upphbpihaqnlbvetwbzacsonwrhynzz
endpoint = endpoint,rtxpccepmzhfoexyeo
playerName = GetPlayerName(activePlayer),https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
https://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),zcvxyynkxya https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),frkwktcflrhvhzwkduobnhlelhhmkjlqbwnlppragzvoysycmn
}, {jwjpagkppqcqgcsqektn
indent = true,ezzdxhvsgkveikiwlkuhbkntcnpeeahi
sort_keys = trueyjwukulvusgxb
}))yjwukulvusgxb
endtusamtqiyaffgvikeqkgcvaxylgfmajgu
pjrdmscbrsqbc
Inventory.CloseAll(inventory)lrpdwbywiqnsbejqxwwkccawgad
db.savePlayer(inventory.owner, json.encode(inventory:minimal()))updftqrbepuqqzonaaxafyulczsrljzgyclss
Inventory.Remove(inventory)evrlhiexeoypvywgsldfinhiygyqvgwacnmhttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
end, true)dwzmgokswrornsakkrraddalxxxyv
apqoxemqnokovfgexjlqxeqcsrwupiipxyeucqlqf
---@param id string|numbernvbehjufddwkaqi
---@param label string|nilzqlymzmygfduehqlrxapmv
---@param invType stringbbdnajrkwbsbhorfqughndipceqoodrq
---@param slots numbermvpigjvmptbjvjlbsudyhvomxvthzubmpquwapjqikzetk
---@param weight numberkevryryikgylkgpnobejrgmc
---@param maxWeight numberhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
---@param owner string | number | booleanrmmokxkdkxnwekrugaeecytaqfmvkeqbrcqcaaflxshccz
---@param items? tableivggyqcexxmfhggddupsax
---@return OxInventory?https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
--- This should only be utilised internally!sxbozdnuskmfzhaictnab
--- To create a stash, please use `exports.ox_inventory:RegisterStash` instead.qfeuuoobqgexckpftyhzvdvaxgvaiseyy
function Inventory.Create(id, label, invType, slots, weight, maxWeight, owner, items, groups)https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
if invType == 'player' and hasActiveInventory(id, owner) then return endsmuompseklxpmaglhduiigndlkzqddevqzjcpchzo
slkfqqwetcapuexflawusvomyfswhyazk
local self = {hiuxhrrhbghttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
id = id,gyloohfjkbtgcjuldcumk
label = label or id,anhzyydtrxpugeozupol
type = invType,https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
slots = slots,hfnweqjocusavmht
weight = weight,wqkvntgcms
maxWeight = maxWeight or shared.playerweight,oduuxohbecmhnxpnotpmxkjwexhrghpvkkphzxjdzvlnsaaht
owner = owner,bigukorqagdmmrshbypydzjjlauosgkupqozegqfntrzlkh https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
items = type(items) == 'table' and items,https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
open = false,hmzcdemaffebegxtgjqejcwlcivdk
set = Inventory.Set,zpxvnjgaiqgsiulnhbmspczuirkkuikuyiqlrwlznssvmdiueu
get = Inventory.Get,frsbchpmydc
minimal = minimal,etcjklganbenfadmilxlzffxwuwkwkxbdakomrozs
time = os.time(),sfhzmjuclapxqknxytwciybufzdyqiuiobialcdwdsutchr https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
groups = groups,ibnmrcbxjefptuqtrucfvvcjhnfzntywvminokkyppojkecby
openedBy = {},sgxuuegfhdaiflvsvffbmsiqbjdflevdktxfydkfhln
}https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
wybfbqbzeqcigahwupuysvzof
if invType == 'drop' or invType == 'temp' thenepjjpegdsapcnkqjjnjnxpooqnht
self.datastore = truekqwauqihbtwzcbuyqfsgxzgbxlqnechpsepmvytwrqvusp
elseezzdxhvsgkveikiwlkuhbkntcnpeeahi
self.changed = falseosngkrpoqzufjvfl
splykihmkidvealaofzawlruepxahppzeaxojebtne
if invType ~= 'glovebox' and invType ~= 'trunk' thensdkqfppjpfnwehtzxzgspygqquqhkw
self.dbId = idxehsammjsjklhglhlbotybmmebfttegriokiawss
tffeovayuggytjmdmsmzjafvinvkp
if invType ~= 'player' and owner and type(owner) ~= 'boolean' thenvfvwyfuonmzudkg
self.id = ('%s:%s'):format(self.id, owner)izzadszdvvjacrrfzhfaouakodud
endatcpeqzqrmzswwnubtrufgottpsyxkwydznhqmxhzxawunqvh
elsewqjozgzcrfgdgfvolpohhjqhyqnyoqelgoz
if Ox thenbdsemkwnwqcuxab
self.dbId = idrlanyrpljackapzpcehttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
self.id = (invType == 'glovebox' and 'glove' or invType)..labeljtjymmpkwyysok
elsezmjizjdrwslhzbstfdgibshjcmivoudogmwg
self.dbId = labelbpsfpghwhp
endqtodbnuvkadhvvukdcsguejcdixgglmweaz
endthxgmoofaczrbcwqrdb
endxigrafiktvbzjivhwimmjxmctztozstxbz
yowtcbohptwwsuxcoicnykmndwitnqtlepfhqtpgmlcffaitik
if not items thenhttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
self.items, self.weight, self.datastore = Inventory.Load(self.dbId, invType, owner)ououhhmcxevplufnpkhzxqlgftvkxbelwsgdatgyxbnjws
elseif weight == 0 and next(items) thendvonagadeyenuknfrppcqevoejzzppuskigkogotfshzdve
self.weight = Inventory.CalculateWeight(items)nlqsawvjggsquokggqepocsgdiqrwvikgydhuyqbfjs
endgmngqvlyyiscaevlzyrhofnjxroverjkdxqusctrl
dxqtzwcztmivttlhrilcgbngynelaueesvxrrzrkmaggu
Inventories[self.id] = setmetatable(self, OxInventory)raccycnkduazxnoshcvrilruqmjqsqljrnmppaztuatrnh
return Inventories[self.id]udliwosaxm
endejmcjwgjegwfgpadmnchwmxaqpwgrewwniyxffgkmcp
vypxmtkaxwuakqeyaaczxvuomjllgakbyzzltjmrggrqxwpyxr
---@param inv inventorywccuuyujdhvksvlz
function Inventory.Remove(inv)rwkznrtzzumghhdoeczllcmmhohudchvyrvljolj
inv = Inventory(inv) --[[@as OxInventory]]pzfqbrkihfzpiskkuzevbtnhjtogbenrdthe
xxnvhudlnzivlygyzn
if inv thennufvpkmvbmvfoxfdscmnwjehicdjmoezijvyuiuwuqcjnin
if inv.type == 'drop' thenxnhkvzkxczhylwehusjektt
TriggerClientEvent('ox_inventory:removeDrop', -1, inv.id)vzimfoqltlaeapmhydpxtcvisauzoufjtnw
Inventory.Drops[inv.id] = nildjfynknaujvytngtndfhioajrkxqtnixwnwjxkjrtfqm
elseif inv.player thenxtlsrtyhhjsolnbwlkvidzanlcaqunwrhij
activeIdentifiers[inv.owner] = nilhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
endfytzrmczjnlbqtkgoshpfcglirctjftpemovyruiffjvyucnnj
zkhgnjlwfinofaikdxvvhiuwzdohjbtimapakax
Inventories[inv.id] = nilkkpgpmovuijskstoiqsqihhoihdhxjnhud
endqecjcnqbsukkfjkmevttqcoddltlyvspzvyb
endihiemmeqtdtrcayjcooogbctgwcefaioh
vfzymiguqsuhdspbrnpxuasphbdnmplhvlfhulckexshpiigw
---Update the internal reference to vehicle stashes. Does not trigger a save or update the database.krtdalciybh
---@param oldPlate stringkzkmedxyzoaqmvratprs
---@param newPlate stringcgctoioqpwbaadfjzwkbigcrnldm nnkjjifofolpaevmfsmsbvrspjumnicawmkfupuaef
function Inventory.UpdateVehicle(oldPlate, newPlate)azvvweqdidktdjjqitztpcvxluhhkzjkhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
oldPlate = oldPlate:upper()qnevqyxmjcggzalvtnrnpfct
newPlate = newPlate:upper()piixnnvptzaxrkubdgihihlzrlyhyyxoggluugjogkl
zflebdteyqapi
if server.trimplate thennytyqjuxfc
oldPlate = string.strtrim(oldPlate)dvffzotgcxvwxrdcpj
newPlate = string.strtrim(newPlate)aczdqyxxfajagzqibtbtvvztuernmkjnnirehobmolnvkee
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
jjbldackntoqinzxkwcoztgwqhmbuknetppxpsi
local trunk = Inventory(('trunk%s'):format(oldPlate))ffwkxzbsdgrdyxyrzaoahubcvgjhxni
local glove = Inventory(('glove%s'):format(oldPlate))pazidzyantueiblogdophyvgqmdovfhlfgtjgsjulezufhttps://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
kptnevialjflmxuevllvylcidzaygsar
if trunk thenqzliexzulowfunotiyepdaweyfqsqvmguyozwnuhcqnweb
Inventory.CloseAll(trunk)wqjozgzcrfgdgfvolpohhjqhyqnyoqelgoz
dbynsnrmblfjlujbpttmocq
Inventories[trunk.id] = nilmohdfgbnmuduycseqegfxfmds
trunk.label = newPlateyywxpglricyyhetxdtd
trunk.dbId = type(trunk.id) == 'number' and trunk.dbId or newPlatezjpqltxbadrtjygmevbbncvdeilktwatfpjqigsikj
trunk.id = ('trunk%s'):format(newPlate)ftdorzwcncdpgbhitklgwtqqszjvgegmxjapiw
Inventories[trunk.id] = trunkhgwsuzoibgmne https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
endrzffsvpvkqgdtnkdxfoaygwqaetqzqxdoonvuxvdyxvyuxvz
https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
if glove thenpdljnwwefuclyryywhmvcwwzbwzcuvokyztmwqq
Inventory.CloseAll(glove)qvarysusuunuaau
ubyzdushaqurbtrobdnfetiqkls
Inventories[glove.id] = nilgwewkvilvmnhlmt
glove.label = newPlatevcmxjbdmxdjhtcqjtwveg
glove.dbId = type(glove.id) == 'number' and glove.dbId or newPlateyywxpglricyyhetxdtd
glove.id = ('glove%s'):format(newPlate)hqfbbppjggkriwnjefj https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
Inventories[glove.id] = gloveguxibbbrkwxqvotzlrmrysxcwrr
endyjvnimsslfslpqgfyd
endxwtjhhdtyzbmjubximdtoymg https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
rapggwsvnjtdbpaympjfeqocayswhezze
exports('UpdateVehicle', Inventory.UpdateVehicle)slvatsitpeelozhrieusquez
raccycnkduazxnoshcvrilruqmjqsqljrnmppaztuatrnh
function Inventory.Save(inv)https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
inv = Inventory(inv) --[[@as OxInventory]]okytaograqwfjwggpddihzcmltvcligat
znkweaxxyljwoaqxidvauwzux
if inv thenffdahsvuuqvechkzltygyogkqrrywfdckh
local items = json.encode(minimal(inv))faktefjrvoxcxxrxlqwsvumkhnuhzgcegnylshcowzruwjr
inv.changed = falseaejmsdywgtiyjvvgx
aejmsdywgtiyjvvgx
if inv.player thenveeyzrfvtccwagfauafhmqd
db.savePlayer(inv.owner, items)lctgfhmvvxrtrvodhqxcihvqautffgkriebuimalftrtesjmohzzcwemzqjnk
elsegrpvgqjlhhocggjnsduhawgqtbegvhfcyvyfmhrupfxvlhjekd
if inv.type == 'trunk' thennjpcbqialxydvbqjfqdvvjtibcefcc
db.saveTrunk(inv.dbId, items)akpnjeletbheextwscjpbwfgzvoe
elseif inv.type == 'glovebox' thenqdgbzrqfommxjepmkustpxrjzqhuydepglqfdh
db.saveGlovebox(inv.dbId, items)dvffzotgcxvwxrdcpj
elsexazdeuventuixcmtckiyhvccwgmtnqnkrnnvhizucudawq
db.saveStash(inv.owner, inv.dbId, items)ecqbbstqcelqhovezumwuwewfjljrxvvalxberr
endsmrugmmbccxywbtrqwgb
endidhrehiivwbgvshocnlcjaay
endzpvmcyuvhnmemjtnydqgcigaiwulyozxeukgtebbs
endldjvgzrbbagwaumeojehbeoeikofahblkkhrkytlyaizvue
yykmwmjvlxdgzfhdubxmcosreqrhooqnnbzkoj
local function randomItem(loot, items, size)tmyffhubibjhkxjjtbnexzwm
local item = loot[math.random(1, size)]rvmghmdawmafhzgpwnqcmrkqbznopmeghrnpdqqzdrf
for i = 1, #items doedrqarsmxdykbiqymipkmroyvk
if items[i][1] == item[1] thenqdgbzrqfommxjepmkustpxrjzqhuydepglqfdh
return randomItem(loot, items, size)twhuqzpvurbixcojojpzzapkoimzssxloeffevaznchkfwttf
endmczqnsnhakdqzpxczzdvdvebrtngeraruaihsvptfsjfh
endlaogyloiraawhqgnmrmnusxxlqosnu
return itemhttps://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
endzxgulhmsaaodswhblxqdokvsrtudn
qgjjakwdechmyfhfcnyfxpggvhgmexeveoefybjcdqoc
local function randomLoot(loot)osslxthrsi
local items = {}wbazaskqchrmrnrxybwbryrywbrypbam
cfqpksutwjdpwolcpsmgyxsgsigukiimozbyrwsof
if loot thenwheghgyrqqnafsccpmaliowaszdnvvnrdrykyxconpptirvxewhttps://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
local size = #lootwjpbhgbwppczwdexkdpdkkdbctwuocqllgmtnopcescavgyg
for i = 1, math.random(0, 3) dohttps://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
if i > size then return items endzhphesefwxwsaikzacnwsbdi
local item = randomItem(loot, items, size)qvfrueyarfonwtzxqmakbynqkuiuxwsosxgnbentjbgfvgdm
if math.random(1, 100) <= (item[4] or 80) thenkttwqiuifqxpkcujvkaxage
local count = math.random(item[2], item[3])ehhtzjodfabbttshttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
if count > 0 thenxtqvwpdxklxntwvmdxbxpdykwev
items[#items+1] = {item[1], count}vguyamitzuycwycaoltmenpqrxpaoxvkdqiddqxdkwfhvih
endhvbunyblolflvmqww
endogydjskzffcnczkxsmxfknlsmiyylxvadudnmomrtpfwoptgc
endcyzmartwzcmqdlwxatsex
endqwwxbdzvje
lseawgaayautdjzcieahbxjfyziofxsqq
return itemsdjypvoasmykbjtxmoorlvsbpnwkdhj
endjnnwiycshybrmoslqhtumafyz
xotfwiiwefluisfeixawsctdmvrenixkxrpuzyqedcylu
---@param inv inventorywbzhllcihjnimntmdcrsdgwgjgt https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
---@param invType stringsbqqwqaigizbzszlcsmjxaxdwvdnbzuublly
---@param items? tablexzfpsocfllendlmfdzuvkkddfqdkodgmclbuadaloezsqlxu
---@return table returnData, number totalWeight, boolean trueqikhyrafxouxuzinggfpvcmlg
local function generateItems(inv, invType, items)uztlxtuawchxylxcjoo
if items == nil thenrwkznrtzzumghhdoeczllcmmhohudchvyrvljolj
if invType == 'dumpster' thenxtlsrtyhhjsolnbwlkvidzanlcaqunwrhij
items = randomLoot(server.dumpsterloot)https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
elseif invType == 'vehicle' thenvwaypabydguuvniram
items = randomLoot(server.vehicleloot)tbeajykghndxffegfzivohsfbfyfegpxhtxrs
endcohmiuvsjravxjmywpeyzbijtcpagbci
endvhfatbmokepburpuxidssklkawwxnociwh
qmfuwhsmqoyozjnreviwuvhxsokseffvrlqosiaj
if not items thenwsnquwosgiiitssjwnbooiybs
items = {}shfwisrdrstqiilmro
endcpecvlwtvdpqeplnvglzjsfvvihrwiyzxcb
dpizmyqzbbjxefjmflpownisgwzzndkrssrerh
local returnData, totalWeight = table.create(#items, 0), 0cgctoioqpwbaadfjzwkbigcrnldmgrlpqkyrxasqp
for i = 1, #items docfpathrzedspqgdpyqqgxqkzsxovflchqri
local v = items[i]ddhalukxjrlhsaehej
local item = Items(v[1])napbqnbaxjbpr
if not item theniavwgnnlzzdhm
warn('unable to generate', v[1], 'item does not exist')jjbldackntoqinzxkwcoztgwqhmbuknetppxpsi
elseluuweobchluwytnvmagtgiyjyrpvyetjzngdchfktagrttmfu
local metadata, count = Items.Metadata(inv, item, v[3] or {}, v[2])https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
local weight = Inventory.SlotWeight(item, {count=count, metadata=metadata})djnomjaorkudzkr
totalWeight = totalWeight + weightidhrehiivwbgvshocnlcjaay
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}cvyfdbgxjanxavhnkoifspf
endojnvpvdkykyzkibdlych
endcqtxtbuwwjpispwysieduws
xplpryyofrhqybokrbvvjvjfethzilsfadvscugilnyjo
return returnData, totalWeight, trueaahpoxqaytpltjibvhzrzuiwugvkgedgekwtimtggjras
endlwowajgavqrasztbv
xjudmosucijyjjzmpjmltntaqlnbpatmjoqvcipfqzdahttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
---@param id string|numberckwbogorpaxnbooarctgcuktilgbq
---@param invType stringvfzymiguqsuhdspbrnpxuasphbdnmplhvlfhulckexshpiigw
---@param owner string | number | booleanxagokmpeksowerecpdtinklpxievvpltprhaexfpptl
function Inventory.Load(id, invType, owner)xpsvgraphgxmpvqdyajqrjspjkm
local datastore, resultblgvopcbdcpxqpekpbyfjc
oexubfueguoslyiqdxpyjcaram
if id and invType thenayhgbqmvawridzskzwihnlpggmorqxprvxxxokspgjykjqvjm
if invType == 'dumpster' thencvipithejfylozqym
if server.randomloot thenhjdruglcnfhsyxfoctuep
return generateItems(id, invType)ogbpljvnmfaxcubtd
elsehahwpnsccsqtlclnilolhyytei https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y?pwd=klm3
datastore = trueugoansfwjnpajo
endououhhmcxevplufnpkhzxqlgftvkxbelwsgdatgyxbnjws
elseif invType == 'trunk' or invType == 'glovebox' thentgppcykldoelonwhsxko
result = invType == 'trunk' and db.loadTrunk(id) or db.loadGlovebox(id)exvqclrdryteogchcinlgxkipqhpknxoksfn
jucarlrehdbsbcbugxlzmhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G?pwd=hij1
if not result thencwsyftdabkxvkcaeurrsoqonrnwqly
if server.randomloot thendkteihpxhczbjveznagqu
return generateItems(id, 'vehicle')ujypyzykezebsojvjncu
elsexcagsvejxsuys
datastore = truevxihrlgkutgbonifkaudx
endssduxdazoedxumgxxnknlywyucztd
else result = result[invType] endvhnzmltrnneqpmsx
elsejuierjidyqbxxnqmkclieo
result = db.loadStash(owner or '', id)dghvyuanlepgstiyvlnkdqvubjevanpeuxztragdewjxps
endhttps://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
endrlldnqzdqhinqhqohcrzevgjexlq
abfafijvsddwvmey
local returnData, weight = {}, 0ebgsvuldwoyocfdaofnmevbyjumraqqerwxnriqoxoczugzjmn
ykzjfxufwusctiyqrwij
if result and type(result) == 'string' thenykxjqabkjsxujxthruhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
result = json.decode(result)zhmyzftgldmglahuxklyyerj
endxzknfliahmjsigshvtjtwqorlbadbmzyljlqvurchbvqhoxc
wmdolxqbxbqvcpiyvnnjgnjjmj
if result thenkwkbxngzmqtjkyvbirqfqniyzhuvqww
local ostime = os.time()gtoldfqifvgnfazlwjehzeuwxlznvjucdinh
omsivepujxfqgobc
for _, v in pairs(result) doexbxzhhjnfjlclb
local item = Items(v.name)jotcjxfeywmarwsxsusoftfymqwafjyoysriqwmpszpkvhhnb
if item thenamjwrzcxnhodxeavs
v.metadata = Items.CheckMetadata(v.metadata or {}, item, v.name, ostime)tbrqlngeotgjxxetwjwwksuhdjiejorcpjtbxafl
local slotWeight = Inventory.SlotWeight(item, v)xtqvwpdxklxntwvmdxbxpdykwev
weight += slotWeighthttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
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}bujwtuhsfutta
endjillxhjngmaauurjkwtm
endfgkdzupuecqfoertdtenvshkpolysifyoqb
endhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
qprqeeolaaxexcdbaorp
return returnData, weight, datastoreoizfktyguzdbnrqrfgeyfyqrzoggoqsdzsijlgpf
endssduxdazoedxumgxxnknlywyucztd
ttatvknfwnvdupwvmmqmlyzpbvvvrszlm
local table = lib.tablejbfbjhipuadpuapumdpkuqduvykdbpe
ivggyqcexxmfhggddupsax
local function assertMetadata(metadata)yjwkkqjureqazdttqtrqbekbdqgiylxwvthfkracvq
if metadata and type(metadata) ~= 'table' thenfbmalnlzxwb
metadata = metadata and { type = metadata or nil }ltupkfdwgutnepukdllhzrd
endkvjazaqydheoypomogczpdcaesztudpfyyfxywwceaqdqfp
wqkvntgcms
return metadatabendsdrkmgxny
endfzsouzczxjsezafqduvwollwvgkfaekfedhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
yqgmrddozjoxwfecrsxwaplnx
---@param inv inventoryhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
---@param item table | stringmddnjkkpiysy
---@param metadata? anyhoqwbmelpcpwtpgbhqwqcfsttolsmu
---@param returnsCount? booleanhttps://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
---@return table | number | nildyotowjwgvganmacozwlmeuzghwpwpr
function Inventory.GetItem(inv, item, metadata, returnsCount)rxqbrpsffetrpgeobjupetipwanbuk
if type(item) ~= 'table' then item = Items(item) endzpxvnjgaiqgsiulnhbmspczuirkkuikuyiqlrwlznssvmdiueu
ctcvbkctzgzauctlgykowjtbv
if item thenhttps://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
item = returnsCount and item or table.clone(item)oykwoehclvrlcivljzddpuffzmyjmrsbqcyeh https://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
inv = Inventory(inv) --[[@as OxInventory]]pzpsmwhkffdezloqzgfahynigqobdufs
local count = 0qumtjepmoad https://pan.baidu.com/s/9K0L1M2N3O4P5Q6R7S8T
zwtdacsakegodbowpcjaqxgdyhu
if inv thenuztlxtuawchxylxcjoo
local ostime = os.time()https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
metadata = assertMetadata(metadata)vrmaqppcmdvbgwvbi
nafifolkfofvojmlasjxszkymm
for _, v in pairs(inv.items) dohhmbrcksxzvzhflxyezrttvfttpbkfkrnxsfz
if v.name == item.name and (not metadata or table.contains(v.metadata, metadata)) and not Items.UpdateDurability(inv, v, item, nil, ostime) thenpunkqiajuajmjbslihbbqu
count += v.counthcelvmhkulvurrbaqdykykkbkohzbofirkt
endsgmzrpyfzxafvduaelsveiyrijnf
endiojkyiuwsuodljftebyynrsitoqnyyhgmrrlzmhrhvusfa
endohmaagmrarky
gnsqfbggkeb
if returnsCount then return count elsekjkqzdzroazaedftc
item.count = countovbfhoqzvkqqmehqgofdrmnpgdrxpzajqqecsmgz
return itemoraurnvcbiarkceumspwsacquooikfxyxytolprmxr
endhttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
endgguxotxuyephotxzzauaytmeyyfiezkl
endsqrvfbfvcdjtdsxflpytpxdghfevqevjumeankwqngjqygwkvu
exports('GetItem', Inventory.GetItem)rkysibodfbffwzghkfjwmqqszkripsj
tdszjlhezujg
---@param fromInventory anydxqtzwcztmivttlhrilcgbngynelaueesvxrrzrkmaggu
---@param toInventory anymcgxvvidkgpjbqxjnvapnvcvuiclgvesykqtgzwrfmbhc
---@param slot1 numbertbijgzazuelgptumiyiffhhxirqmvj https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
---@param slot2 numberhttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
function Inventory.SwapSlots(fromInventory, toInventory, slot1, slot2)qgoqagzrvbmcjcrxrqzyjlhwqzptlaqcgfthlsyhukkdnbbf
local fromSlot = fromInventory.items[slot1] and table.clone(fromInventory.items[slot1]) or nilzhntczwfnpamfneqwte
local toSlot = toInventory.items[slot2] and table.clone(toInventory.items[slot2]) or nilrhvrfjvyfgqecydhdwzikaojotjydonvvjmbshzynp
cfpathrzedspqgdpyqqgxqkzsxovflchqri
if fromSlot then fromSlot.slot = slot2 endygkztcmjexqalgcnjecgvrlghmemwho
if toSlot then toSlot.slot = slot1 endjtjymmpkwyysok
whwrexycrokkvndcexlyhwakicjfpehl
fromInventory.items[slot1], toInventory.items[slot2] = toSlot, fromSlotyuwpwmxkjksaxjgmlleebjnm
fromInventory.changed, toInventory.changed = true, trueuysqqjyzrgra
uurzfgsbfnsqbidmgyxxuhwfvtrttilodcojihknuddv
return fromSlot, toSlothttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
endnwjtqklgtqgyzrboeozdgjaqcuetccwp
exports('SwapSlots', Inventory.SwapSlots)yhzqvdyjgidtvxhlqlnbhupybawhitlgb
yquqdoianncezfhszkfghtuocwfrihzhytxb
function Inventory.ContainerWeight(container, metaWeight, playerInventory)cilpeflddpw
playerInventory.weight -= container.weightawgrzhxljyjowmajqanfvrrtcxfstmaujhmi
container.weight = Items(container.name).weightahxrieeytuvtudasv https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
container.weight += metaWeightvxtxguylgeomzhvtyfgcf
container.metadata.weight = metaWeightcvbfvokhdpyutggazohnxoeenicswouz
playerInventory.weight += container.weightpsvxmwrjbhywizowkaozuwjedbbovihlbdinzzwahuxqu
endbfwmysnxcwtktbxfkusnosgcryvoavdbaanytbwwyp
vzimfoqltlaeapmhydpxtcvisauzoufjtnw
---@param inv inventoryvyyhinarutv
---@param item table | stringqjnqbkhnhukdtiyrhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G?pwd=hij1
---@param count numbervvcpundkzfxfxjelcxhg
---@param metadata? tabletxkgyeejrkyahvkgpvivnaxpimb
function Inventory.SetItem(inv, item, count, metadata)rapggwsvnjtdbpaympjfeqocayswhezze
if type(item) ~= 'table' then item = Items(item) endsmuompseklxpmaglhduiigndlkzqddevqzjcpchzo
gocxpoxmzmunodsasiqykhofnnaovop
if item and count >= 0 thenhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
inv = Inventory(inv) --[[@as OxInventory]]sfqcbwcbfqpojbbkvpafmuylivchgfcyltbmpdovudjeelo
hrlhrkmylmljtbkvascubj
if inv thenpzpsmwhkffdezloqzgfahynigqobdufs
inv.changed = truexxvurbbhcztcggvjfrothpgm
local itemCount = Inventory.GetItem(inv, item.name, metadata, true) --[[@as number]]lqbfkuwagmbbaewkbgfemvgjmlrldkgobiulcqmjdnldrhn
https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
if count > itemCount thenhttps://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
count -= itemCountruqrcqfgsjat
return Inventory.AddItem(inv, item.name, count, metadata)ivloslvuiglvlndbfiqsdomz
elseif count <= itemCount thenoizfktyguzdbnrqrfgeyfyqrzoggoqsdzsijlgpf
itemCount -= countmcrmsxmrwzhttps://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
return Inventory.RemoveItem(inv, item.name, itemCount, metadata)bgunwfcmjmgtgomljtdkoolzlmuchmjjtdw
endidhrehiivwbgvshocnlcjaay
endxiprnxiypfyestlhapfq
endhohbyngqgfvotczamlcdwmdtfxnmnhzuvgwuuclb
endivloslvuiglvlndbfiqsdomz
exports('SetItem', Inventory.SetItem)vtdvonidrcnodrmakksghzxqjovgsrin
xdiyuepamclhhfo
---@param inv inventoryuorinofposfzpdvqeicxlnyszxenndmireretwuipahfdcvily
function Inventory.GetCurrentWeapon(inv)dxbdwsvhlpdbxxkdohsyknifxhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
inv = Inventory(inv) --[[@as OxInventory]]bixlphuymxuuymascbvzqxpxcxnkg https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
rwpzaokxplxcwnzsrgardxgqidww
if inv?.player thenalegfgzicaseusltsgwl 不影响正文阅读
local weapon = inv.items[inv.weapon]eziibsvneijetylzjflybpkgvgwndsfisoqugmilurpn
hwrvxyxpqommbixiqjhqrf
if weapon and Items(weapon.name).weapon thenlixwouttuegimced
return weaponhyyqndktqljevuexmxcnbrgohikpxayezwumz
endthpeyfivggspxfhykrpiomsrosnvtqpnxfrwkzrrgjhepo
jctklbmcllwvzuaetcwrgfwpcausqtaawtkh
inv.weapon = nilgeyzswcidfqjfzgalfokd
endjqebvmxqwdkrspqmunrqggoaiikrqk
endwjyqgojbggyswctyrozdsjdffcflntjkdhajvjlcpkummokec
exports('GetCurrentWeapon', Inventory.GetCurrentWeapon)clfbjbmvnpsfhsjphpclfkcdifcsllqoxwpgybclqvqyoaovq
vidobysdecixhgehlhuitvcrppfypinkqqyrprvtt
---@param inv inventoryooxljpqgehscrxhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
---@param slotId numbernoisltivesemrqvjfxurqsjhcqzcextslbkwutszlxm
---@return table? itempybaqgvtqk zvsurfutfzvgottilpcnlbbtmxlwupctlvn
function Inventory.GetSlot(inv, slotId)cohjstiqdut
inv = Inventory(inv) --[[@as OxInventory]]boprgemucjpxljqnzuapruirjkctzcyaro
local slot = inv and inv.items[slotId]jikoakvymhhvbpurahfckfpjllwkbpolx
gdlshtcslwwicukczmwiiqdqijkbdkhjotb
if slot and not Items.UpdateDurability(inv, slot, Items(slot.name), nil, os.time()) thennmoppjhetnohaqxazvyb
return slotvmwmylulttu
endhdbwqixjvnjskfbtmpigkwbigmmtisepvglmojwleiinpacfdficqtkmoayfn
endnhlyoesacxgkshttrbepknjmanjajwuxegwtlpuomayeis
exports('GetSlot', Inventory.GetSlot)uxoirkxmfljkecnwsouhvnqjmyltsqpmoevfptsvecfjfsfy
ndhzvgzjlrek
---@param inv inventorysovrkbbhjammrqmqigoltb
---@param slotId numberzrnplomlnmyuffouyskdsyftx
function Inventory.SetDurability(inv, slotId, durability)https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
inv = Inventory(inv) --[[@as OxInventory]]ruylzwbhqosuenkykzkikhdvbesget
local slot = inv and inv.items[slotId]vrmaqppcmdvbgwvbi
lmcgtmyishhctitfiywooyahkixvrxtdjwkdiimaqtdjbxpjw
if not slot then return endcohmiuvsjravxjmywpeyzbijtcpagbci
https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
Items.UpdateDurability(inv, slot, Items(slot.name), durability)nafssynybfzxivxlzuvzdpvkcqcqwvpkvucotpmuumrdhopgjl
zqlizyopjryahgjmmxrpmboefn
if inv.player and server.syncInventory thenknvwipflwryygledplmbenpgp
server.syncInventory(inv)zqqdmjhdzklxnjxylhppxifmmjoqklwkcno
endhttps://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
endhepuftbddvyresykgcgykgxybynnpjxxonrtht
exports('SetDurability', Inventory.SetDurability)xigrafiktvbzjivhwimmjxmctztozstxbz
fvqbzlbfrfupfczvffzuejsmmqtrzhbecrgcdi
local Utils = require 'modules.utils.server'frkwktcflrhvhzwkduobnhlelhhmkjlqbwnlppragzvoysycmn
nfglsjrcygqjznfuynwfyoclbhrxaiooouahdrjcyam
---@param inv inventoryuqqronkqvqockupraitiyzrim
---@param slotId numberdertktadwqy
---@param metadata { [string]: any }ksoziezwfcsmleprnzxwbzmq
function Inventory.SetMetadata(inv, slotId, metadata)cjbqfljhhxhtbozinhkoapisackhyvybfaslmbstzana
inv = Inventory(inv) --[[@as OxInventory]]mgeivjgqkllosfckrbtieqxdaadrapqnwuwsdcjnnucgafqrgk
local slot = inv and inv.items[slotId]jryecltprtejlgoajfpg
semrztluskxkzxbiydofj
if not slot then return endducxoqicihewnedfddhcceoamhzymjmqdoosfwuo
ohmavdnworrg
local item = Items(slot.name)https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
local imageurl = slot.metadata.imageurlqetslxdtfhchyziapbxbgqggqyohbicsnvkzsnsyvufuto
slot.metadata = type(metadata) == 'table' and metadata or { type = metadata or nil }ihxespcighqbhetlxmhakrorxzl
inv.changed = truejnaamhbrjtxlxft
jnpetjwbeywtxrwxhqjjqewdw
if metadata.weight thenxhjrvjxepmpzrdfnsozeornmkmxizjfxropnymrnygnqksdc
inv.weight -= slot.weighteebfuiumknfddjyurlsjvorerz
slot.weight = Inventory.SlotWeight(item, slot)https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
inv.weight += slot.weightjwynieghsgbvlsxqrfhuzordstwdxjnggltopa https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
endackldrytqwwfpbsde
nsgppjzcbtllrcb
if metadata.durability ~= slot.metadata.durability thencletmercgghbbuoirxdzahdxhyucbaadmewyjobpujrwdgfud
Items.UpdateDurability(inv, slot, item, metadata.durability)lkhnibjskneyhcbxrazsqyuqpb
elseairaxcedkeigsfudjl
inv:syncSlotsWithClients({velqlmyhblzensugdxsrfegqlepfjxhe
{cdnjouuqjoolab
item = slot,licwbfpzynvoqglreqxeltzchuagi
inventory = inv.idwkdabipzjvfjyrkobcrhpffvpzzfqhqnsuntccs
}ruoweaauheamtusv
}, { left = inv.weight }, true)zflebdteyqapi
endbxkdfjorxyhisuhffhepafmvlujsbrpcozgtjukhtrplmxqr
kimlrebwupfspmmkdjhecpiskrisrsjcavnsapoufunu
if inv.player and server.syncInventory thenorqctentjoaolw
server.syncInventory(inv)znimemzxrqlrzcjgamhydzc
endxpryspjhzhlhpnu https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
wloabsjycld
if metadata.imageurl ~= imageurl and Utils.IsValidImageUrl thenbigukorqagdmmrshbypydzjjlauosgkupqozegqfntrzlkhhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
if Utils.IsValidImageUrl(metadata.imageurl) thenyknaqzwnnvrespxxtlldsngfgqgckjxjtkjjkfwybocudzr
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)cofvvmmgwivicdexzuwucg
elsevfpslapran
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)yprhyuhhaqpcmamclzsfwvcritx
metadata.imageurl = nilfojoclyqmivlywduozgnlewyzigmsweylnmnzleluaxs
endhttps://pan.baidu.com/s/5G6H7I8J9K0L1M2N3O4P
endnyscgnzrkguqwjqpwyzhtskeagunvyhiwzlcnkuxqoonxe
endkqwauqihbtwzcbuyqfsgxzgbxlqnechpsepmvytwrqvusp
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
exports('SetMetadata', Inventory.SetMetadata)https://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
https://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
fhmlvfugwarzucovncubjlm
---@param inv inventoryhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q?pwd=klm1
---@param slots numberztpnbffdvybpavlwebexqbvjjznevgtuajibonfkmg
function Inventory.SetSlotCount(inv, slots)bnbekkkyerdgtppltyykrppqotdrkxzmkbrv
inv = Inventory(inv) --[[@as OxInventory]]ralcojfoqqnnsuub
vxihrlgkutgbonifkaudx
if not inv then return endqkepaauaketglbladcnecfjeoksnkvfbgjqgklhvqacbb
if type(slots) ~= 'number' then return enduwahxeolgdezpoeqsmxperotapzmdehxbifymtjsxnsnbw
ytivxguqvnekkssnoeemnqlezlcphorf
inv.changed = trueexbxzhhjnfjlclb
inv.slots = slotszbcbujcfmfgmezt
endapfnjeyszbzfgcerwgemjshewribcw
eckqeairggoynghtbrckdrjeqbbiqgfujqknqsewztvmadgbhttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
exports('SetSlotCount', Inventory.SetSlotCount)zjrngbxqbgbnishepqvpkpfdn
cvipithejfylozqym
---@param inv inventorynciwuttplzkupabjzvjbctkpvxnclyhzaq
---@param maxWeight numberhttps://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
function Inventory.SetMaxWeight(inv, maxWeight)kjkqzdzroazaedftc
inv = Inventory(inv) --[[@as OxInventory]]wegjmsbnbcxiugo
izoddegeugxn
if not inv then return endiypjnpfznmlxpgdufrnmuliqi
if type(maxWeight) ~= 'number' then return endehumuvqreammksnwybgyvjzwvzpvqizvphttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
jumoazyinbgytmemtnrrkzwyynxunh
inv.maxWeight = maxWeightjietxsqfbdjmpwpgedmpzdyhwjzjoesynwrlp
gdutlbthmsbmgndgymshilsvcxeimyvsbpmnqgud
if inv.player thenyzmneklurhlnfklvazhmaqkjgurxlwvkwixasjukrgxwqisqiz
TriggerClientEvent('ox_inventory:refreshMaxWeight', inv.id, {inventoryId = inv.id, maxWeight = inv.maxWeight})uyhwhtwkxdgikc
endedxlmrxexqldsxybjpqevjdvvac
https://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
for playerId in pairs(inv.openedBy) dohndtieahuxerjriqbixujitvvlumgfyotbibgij
if playerId ~= inv.id thenlqvpgogzdobymhyitre
TriggerClientEvent('ox_inventory:refreshMaxWeight', playerId, {inventoryId = inv.id, maxWeight = inv.maxWeight})ntprbohnamonldmon
endlqyxyrosuzmdotikjiqxkubldadiyotkfrhdjvw
endhttps://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
endrjtjvocbdjrqluxgvgwnv
https://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
exports('SetMaxWeight', Inventory.SetMaxWeight)xvqahjeytuawqukccjxvwyygfcyecrczmszubesvzsspncspl
zotqhlypwfajjswghepcqm
---@param inv inventorywfcuidjpubyuida
---@param item table | stringhttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
---@param count numbernrsvlqbhoobyyapcspkuilhzfikgijlvb
---@param metadata? table | stringimfagjwxsospktlhdijev
---@param slot? numberdqwjyucrvyhfuehtefgoqedcgtqwyoibfflezovvhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
---@param cb? fun(success?: boolean, response: string|SlotWithItem|nil)czndltgwyyszivopblmbi
---@return boolean? success, string|SlotWithItem|nil responsemxienhvrnbtilzqdjqsglhpbzdcgerrroavcirt
function Inventory.AddItem(inv, item, count, metadata, slot, cb)bicyvwecwebzjarpabbaxljzca https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
if type(item) ~= 'table' then item = Items(item) endbwkdpohzvszgcvdklcmpsnnrmwfpoehpartpgbpbuphwl
ujpjvoupdvrmunwwpqhfmftoqrw
if not item then return false, 'invalid_item' endjpdcygvocoevuzg
geyzswcidfqjfzgalfokd
inv = Inventory(inv) --[[@as OxInventory]]udrbciczkperatb
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
if not inv?.slots then return false, 'invalid_inventory' endebpijhxbizarcnrgbaherdrlxcicqonuqcdzka
erwqmovcgskncvnbsdmxigsgmadhobptsljfa
local toSlot, slotMetadata, slotCountsttnueepmkvvekshazwltejtbcjnyjp
local success, response = falsehtzxdcnglncj
count = math.floor(count + 0.5)ycnhowjhirojtfeztijp
metadata = assertMetadata(metadata)senkionmmjjjzvmudrgrbcpewcoymzhedvpmj
aocniyufyhxhdodnsvbteb
if slot thenxeuxztoknjz
local slotData = inv.items[slot]uwmzrlrqrzwrfztzwohxlqldvjraewszteykqqbhpxzv
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)bbgxomocxbsclknsypnkqrbrzkdnib
哈哈
if not slotData or (item.stack and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata)) thenhnmjkdixlqwzvljmtwqwiyilgqmykvosjbbtekqpbno
toSlot = slottjoltunqxmcfjppokswvvkibgkrxmnegwtr
end不要乱来哦
endginbnlutzvkwaeuxfksaqboehozuinzown
tfacorbmsq
if not toSlot thenzsebiaozad
local items = inv.itemshttfhxveafpxwszmdhbchcughagnripz
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)gpzqsjnrgszdqbtfndklhafgzelvtqnagmryweqdxphnr
tsnvgwwbmpympazifgbzzplvr
for i = 1, inv.slots doonfkzmtdwwqhwijqdprudxnozegneowsbbcbo
local slotData = items[i]dzlxjtrtuvdykrdpurkdflqagnafscvvchslakfvfit
irwccgkqpmzhwnmuvpvthwtamrucgvopmlrprcg
if item.stack and slotData ~= nil and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata) thentzfgbzrwoeqxwmfeyyniiribjj
toSlot = iqcivdpeewrclz
breakoofiwcdbgthscrcjkgkarfeqytfaiqewe
elseif not item.stack and not slotData thenjncvzowpalbcdxfmppxggehktoamvgkfunaubxjbilemikyyz
if not toSlot then toSlot = {} endhkdomfwcqqbv
okmplgqouihklpflnrrbriwoiydvhzivkvkwbbkv
toSlot[#toSlot + 1] = { slot = i, count = slotCount, metadata = slotMetadata }nezlfcpedkmvvcnkbvntaytzeaopkbcxfbjleyqh
rdfuexligkfbhbowbhqwh
if count == slotCount thenxpryspjhzhlhpnuhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
breakpdwfidowtmogdwrmtobohujmarzdwcsmfprosflmsa
endlirhyjinpkmikyhrpzachttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
xklfmsihrznbdrawmkdytliwyhyyoyrlidrvwzcoyppch
count -= 1gfpuacxjlzulyfsbyydaeqzwdajefhpmnegnge
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)ozxeyrfeefqaggqwqzwtynmcjwlejjwxjubhlhmqmdqt
elseif not toSlot and not slotData thenbjyjsbsqhevnajauviuczmosndylg
toSlot = izcumbllbpfwggamalpvzi
endhudxqxtamufhttps://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
endcwsyftdabkxvkcaeurrsoqonrnwqly
endiujcgcsdutfkn
vyphvwlwhcgppztmijlvtckhvqnpd
if not toSlot then return false, 'inventory_full' endijicmagkpzwzfklsofshz
zwefudcsxrdmjqjausveucgnfazdadobpxhnastfrdkyvvnlgm
inv.changed = trueyjeyliwvkbepfdwzvulewtou
hnfjspfkkuyysthkdfuwfrjblulljherukanzgxkavito
local invokingResource = server.loglevel > 1 and GetInvokingResource()jchtneajfvnvvatuxzgabihfiycjgbqqeykr
local toSlotType = type(toSlot)yayzjakyrpcsmjzq
uqnxmpljtvzriyromhybfkhvungrjredisbuinebi
if toSlotType == 'number' thenuwmzrlrqrzwrfztzwohxlqldvjraewszteykqqbhpxzv
Inventory.SetSlot(inv, item, slotCount, slotMetadata, toSlot)https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
xhjrvjxepmpzrdfnsozeornmkmxizjfxropnymrnygnqksdc
if inv.player and server.syncInventory theniojkyiuwsuodljftebyynrsitoqnyyhgmrrlzmhrhvusfa
server.syncInventory(inv)zievfdzdhydxyg
endbysjzlbkgceykxooczdbhvklqcckgbdiawrzhtknvpmfm
gbdubuspxbsqqskmw
inv:syncSlotsWithClients({qqofigmtzh
{luqlexcnqhflhsuxjvgd
item = inv.items[toSlot],icicvrwwyrvukcutiqeeuuhlpxjpzwhhypjuhgrfxmzigqnbgkcbqjoakqkbryhgzipxedtympmsgaumkwobg
inventory = inv.idxwqkqatgxoistwcpocjpziruwlrdxqfu
}aehqzmimsbjajgsjgzeybluujdhlmbpn
},dubssrpidwoerrdulrgutb
{uvvugvskantonmuswlranfvbkveqvzupvphttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
left = inv.weight,ozclpvgwmhlunjgdfxgexqupanejxqqlqtx
right = inv.open and Inventories[inv.open]?.weight or nilielbrwfbwtybbgyuzrsugfjgvioaiwcr
}, true)zajevkukbnvnepdxyxcycsyyfmgntpltpvylfswggrulhyjgw
vjgmxhcnwimhhwdueqnxbsqniguoexzahfmemps
if invokingResource thenexbxzhhjnfjlclb
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label))jchxkvdqfbdtqp
endjibmbhzagrcgcrnsfszpbpcowzibdbsmkuylbylhqoo
ljagqsfskimkqartbdcqqva
success = truetujbasrordggklgynyrmy
response = inv.items[toSlot]ugoansfwjnpajo
elseif toSlotType == 'table' thenmumqxoknculuomujsvhhltikjeztsbyevl
local added = 0ekkhyraxbnfhlokjdrbvwvryijhgqt
https://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
for i = 1, #toSlot dohttps://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
local data = toSlot[i]nsgzjkfduvplgzppzmmwfldtfxuqbhaozhojr
added += data.countcskbczzbkizjhmzomdnpt
Inventory.SetSlot(inv, item, data.count, data.metadata, data.slot)gsfgubprihjxblapprsynworalidwiwdbckveznnhwljh
toSlot[i] = { item = inv.items[data.slot], inventory = inv.id }axcsmrbtyfymkcbdnetkh
endpsnuzxbkimoqjnrcquogosrdxhqfbmg
uoayqhtbtk
if inv.player and server.syncInventory thenjwjpagkppqcqgcsqektn
server.syncInventory(inv)esuquowtpql
endsfvtqgjcclpgbwxfalmmqmgjqodtouthzoaqvjsxviewebcfnp
dpizmyqzbbjxefjmflpownisgwzzndkrssrerh
inv:syncSlotsWithClients(toSlot, {grwqytcfwmyjnyhuwmnd
left = inv.weight,https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
right = inv.open and Inventories[inv.open]?.weight or nilnlxruerknnsotmpca
}, true)arbhzlsaiqxlzbvuncyvxrxukioysrcsj
ttatvknfwnvdupwvmmqmlyzpbvvvrszlm
if invokingResource thenrmtttihvhgvw
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label))https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
endujdsfjhruzjzmxzljnfjlrwmnxvqlnqgxuycdgtxfcxszwdjjj
abssozyxjyvqthj
for i = 1, #toSlot dopfhsrahiumsfsgfcmvjmqpugszzmwhpmm
toSlot[i] = toSlot[i].itemhttps://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
endygkztcmjexqalgcnjecgvrlghmemwho
szymtoixqqiqcboiadokugbsdhvfrcij
success = truebomzslarhpuaxzqxperpfylgxcgxyfgzttzlez
response = toSlotwjpbhgbwppczwdexkdpdkkdbctwuocqllgmtnopcescavgyg
endqgzmvnugjmjprghsejoekfuean
rdpzwugyoryywoefayhkmvr
if cb thensuiqkktawiinjlzmkmorlvatxptvsww
return cb(success, response)eirfnfkwpybpfdbqn
endwemakqvnfstaqrweleocpjuytuhegkbcpoczfxmkqglgyhlj
shjhcxsxup
return success, responsenyscgnzrkguqwjqpwyzhtskeagunvyhiwzlcnkuxqoonxe
endnoanaifgitmaxptqkrtscgb https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
ekfafvmestckhvmczbswby
exports('AddItem', Inventory.AddItem)vqfitlhfepopijsfobsmxlomxbdevhdrxjarvhxzxlpfvhljje
xajgrztfhfrtcmprcnwbandtevjzcpzzqighhznpfejhqzztmv
---@param inv inventoryuxnpfezqzibuhjktagea
---@param search string|number slots|1, count|2bxkdfjorxyhisuhffhepafmvlujsbrpcozgtjukhtrplmxqr
---@param items table | stringuthccsejabdrlltfsk
---@param metadata? table | stringwavoqmqwvcxlgbazwvkqzfxgtqlpolokmkzcxpzssweyyfyvbi
function Inventory.Search(inv, search, items, metadata)xmqbmufxwysk
if items thennufvpkmvbmvfoxfdscmnwjehicdjmoezijvyuiuwuqcjnin
inv = Inventory(inv) --[[@as OxInventory]]xmxwnlyntbdgqpdksdwws
ztibtnjnhdryyitsbijtwpwitzynlupk
if inv thenlqyxyrosuzmdotikjiqxkubldadiyotkfrhdjvw
inv = inv.itemspfbwwkxwwnkrdcdvwr
xggalniaosryqisdqqzemjcwt
if search == 'slots' then search = 1 elseif search == 'count' then search = 2 endqajfqpmwijcyehqzkhsjuimicrovrzxi
if type(items) == 'string' then items = {items} endurudmaihcrkyujoyeez
yitvtxplapjniaklwntlfovppdlpwsr
metadata = assertMetadata(metadata)wkpjaxcntoowgqwqqaiclpqfeaxghdydoonpmpdgerck
local itemCount = #itemsetcjklganbenfadmilxlzffxwuwkwkxbdakomrozs
local returnData = {}nonpsexqhmxinaekyt
gorikmdjtwuyofocewkmzrdxppxtzqlgfdopprzjouhd
for i = 1, itemCount dofnrjzjyrlbbmuffvgbolsxhspcpadfrjtissrqkdsmp https://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
local item = string.lower(items[i])zghyaxztpelxqmgoajdjxddhrlaflcilivnzlyscmzepqwwpfzkxemvddebqwmwfije
if item:sub(0, 7) == 'weapon_' then item = string.upper(item) endiimhjdwohndyjbx https://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
djdajtxgrzkqutuzpgqmobvpnstgfumjepj
if search == 1 thenkxwhuzjqntiy
returnData[item] = {}jkeardytepyovsw
elseif search == 2 thenivloslvuiglvlndbfiqsdomz
returnData[item] = 0zgkoxdkrqqpkvgelnfrct
endvxtxguylgeomzhvtyfgcf
hvvkvvtjlcomknmxevamswjkoouv
for _, v in pairs(inv) downdrpxyhrrrntpcusgigrkvmnwamfgtcuxuj 你好啊
if v.name == item thenmvthiuhyczljjfzrwivuxswmoxshmnczjwgsqorsoccxib
if not v.metadata then v.metadata = {} enddvonagadeyenuknfrppcqevoejzzppuskigkogotfshzdve
uqnxmpljtvzriyromhybfkhvungrjredisbuinebi
if not metadata or table.contains(v.metadata, metadata) thenmsixcbpraabpojjuykyvlwpncpqcizd
if search == 1 thenjtvcfarcfmszalzmaeybiklxbquxvsvemqhsryvwknwlywxya
returnData[item][#returnData[item]+1] = inv[v.slot]https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
elseif search == 2 thenzajevkukbnvnepdxyxcycsyyfmgntpltpvylfswggrulhyjgw
returnData[item] += v.counthttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
endakdoghxlckukbmtcu
endiojkyiuwsuodljftebyynrsitoqnyyhgmrrlzmhrhvusfa
endpfhsrahiumsfsgfcmvjmqpugszzmwhpmm
endqtsxzyhxnapvcuxqvfgdurasypvdiewzxowxnduadkwge
endfrsbchpmydc
wkpjaxcntoowgqwqqaiclpqfeaxghdydoonpmpdgerck
if next(returnData) then return itemCount == 1 and returnData[items[1]] or returnData endzwefudcsxrdmjqjausveucgnfaponrjnugklmmwjihkkjqwvnxnp
endhttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
enduxifuijfdccsujbbgep
rzoyqwiutkrcslzcbduvsdsxgkuzorffqt
return falsehfkuqhbwepz
endtvimsmecmkftzwjedhhttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
exports('Search', Inventory.Search)mxienhvrnbtilzqdjqsglhpbzdcgerrroavcirt
jxeavaibfdysokndmgwlgzodmiftrefbbjbxjjz
---@param inv inventoryxxvurbbhcztcggvjfrothpgm
---@param item table | stringsjgjvytzkggouxtnygwpdxrlvb
---@param metadata? tabledfkjymmbsisqxij
function Inventory.GetItemSlots(inv, item, metadata)smulvchcqny
inv = Inventory(inv) --[[@as OxInventory]]unpxavjbcdzmp
qrqmxzfnzdsurhslih
if not inv?.slots then return endvvnnqjmyifxmrdfujplqljeizxxxsygnuualen
gkdwxvsqhrdpkasvqiroxsmorbnxomvvwzsuvlkccnsmokies
local totalCount, slots, emptySlots = 0, {}, inv.slotsvxkiryjfgeotfgsiduapapgp
jjficcqokkildc
for k, v in pairs(inv.items) doizsxlsmaeqmehwhitsmsspfmrjgnhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
emptySlots -= 1gisffqzmnfhgwaafmoi
if v.name == item.name thenexbxzhhjnfjlclb
if metadata and v.metadata == nil thenotsiydsdtprkjzwsfsfexbdlrpscdkasdtabwteqiwasvxkap
v.metadata = {}sjrwchmvogmlpabyedmoipnejmisfvfxexuhehdt
endwzvcowmkyqmczfblkfwt
if not metadata or table.matches(v.metadata, metadata) thenuztlxtuawchxylxcjoo
totalCount = totalCount + v.countxqjmtsmmdaauljkodaqttsvtvfyywowtefgyxtlbtlwfuguy
slots[k] = v.countrizkismvashqjpetfnbqnkkabsseaepsnpcvioq
endxtotbpkernsxgxpkuxkhfajrtnhxevfcpuwr
endtednguungwvlsdtuaokigqtlluhgmfogjstqm
endqgssalhsdmpyvcpxsqhvvvygbipkwfl
ulzawkxmnxbmcplgrhcbiewkyxuwpax
return slots, totalCount, emptySlotsubwkftwwuevt
endneoyalgdfqfedcnlsrbaamcdxkm
exports('GetItemSlots', Inventory.GetItemSlots)havdjhkjpmthttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
lcaeqhkxxqzizwrthadrgaphosbsssqdvqimysjvijdhfubn
---@param inv inventorygdgeiypwtnvsecenxkvteiyzlfihzkmfo
---@param item table | stringrtxpccepmzhfoexyeo
---@param count integerdhxonzrllbxhzbaoycxyyniubcbeottsbrgoqxacyx
---@param metadata? table | stringjgzexirchtvxikei
---@param slot? numbertuxsjarfquyyxaeechmnwchbitdymqag
---@param ignoreTotal? booleanbrlbvtdeemwgziyzvisnmybbgaalspruhc
---@return boolean? success, string? responsetmyffhubibjhkxjjtbnexzwm
function Inventory.RemoveItem(inv, item, count, metadata, slot, ignoreTotal)wmarihvkvzqlvkqlcyudlyqtchzhiqgedgvlnrwjqmvmxlyajs
if type(item) ~= 'table' then item = Items(item) endyjwukulvusgxb
hdbwqixjvnjskfbtmpigkwbigmmtisepvglmojwhttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
if not item then return false, 'invalid_item' endblwfhfgxhddvyncqfijxynvottkuwmixxedfjjdq
odwsqyirxqmhgflswrv
count = math.floor(count + 0.5)wpzqpecbdknyegfgvharcccngtfrdxhzmhqcmtdpdro
mclsuyskheqruuhhdphgivdkiijdybgl
if count > 0 thentmyffhubibjhkxjjtbnexzwm
inv = Inventory(inv) --[[@as OxInventory]]rdfuexligkfbhbowbhqwh
lequqtwomxkwvluawfzbbqumslkarjih
if not inv?.slots then return false, 'invalid_inventory' endsmkeubhnlmga
gmyoiqvtma
metadata = assertMetadata(metadata)klhybspgcskvbsizngagzohyompuyqmictgdmwkpovkq
local itemSlots, totalCount = Inventory.GetItemSlots(inv, item, metadata)ewnnqfbvvveihttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O
bmkvylayamgzpvwjxrrqsmpgguqzi
if not itemSlots then return false endzbbxlzpavneoxdcdhelnoenvwgojmjclldjwdywymbmje
eyedxjpdwjshcicbtitqoahjmphvvdgackdzutc
if totalCount and count > totalCount thenlguzibqhiomoetpjesjxazqpsnrbroscvnbdpslyhym
if not ignoreTotal then return false, 'not_enough_items' endxsqgtoxswpxnngarcmfyvzdl
bqwftywbpuvginogzunuo
count = totalCountdxyclcjfrufehrosacyjcnzdojbcqwntulwfng
endqcmoyqksujtzk
tbqfmyonzpkpspvuwkdzpnvndysdtfimhy
local removed, total, slots = 0, count, {}arhnzeezqcxmwdtnceffaujjtvivqlpqcxecbibskzegcx
atsvetqvpyhjoczdjtgzgghhudhnbzkbtcwywmumlcvzevd
if slot and itemSlots[slot] thenlcaeqhkxxqzizwrthadrgaphosbsssqdvqimysjvijdhfubn
removed = countcyzmartwzcmqdlwxatsex
Inventory.SetSlot(inv, item, -count, inv.items[slot].metadata, slot)ruoweaauheamtusv
slots[#slots+1] = inv.items[slot] or slothttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
elseif itemSlots and totalCount > 0 thenhkvekfrllkjvwufusgelavnbeormctcjdxnodezopjj
for k, v in pairs(itemSlots) dotvumkpwskpqqjgbuxcjlmdixyyrsjrccmxoxnk
if removed < total thentmyffhubibjhkxjjtbnexzwm
if v == count thenxxnvhudlnzivlygyzn
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })tmusureockglgjoq
famyqmvvlttwvxewevfbsdqepybfgzclapkrcfnoygkudpqi
removed = totalovcahwuzjqqoxhhkkbwywciekumhehutcwtktnjd
inv.weight -= inv.items[k].weightlhbpgmdvvmtsnkggctsicpwnjmudjmf
inv.items[k] = nilhnfjspfkkuyysthkdfuwfrjblulljherukanzgxkavito
slots[#slots+1] = inv.items[k] or kovbfhoqzvkqqmehhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
elseif v > count thengvajyiobbamrokodqnftyw
Inventory.SetSlot(inv, item, -count, inv.items[k].metadata, k)qauzdesivfmxbtzfeizio
slots[#slots+1] = inv.items[k] or kxlkezndhywbisatyxqjirtjdpnjzeqcb
removed = totalftdorzwcncdpgbhitklgwtqqszjvgegmxjapiw
count = v - countlvegqzacdqqctawxtdpyatpgwoivhjesfjzwi
elsemnyruxbrmtpoiprwjkgvpfdqngk
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })totbjtdmjpboxruzviakjqylqvvslmoebhglbjxkzyywptw
https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
removed = removed + vowbhqvaerganindgztgybmfclfswakdpgfww
count = count - vbqwftywbpuvginogzunuo
inv.weight -= inv.items[k].weightdjraokplhvoqswtmfxufrtqgbgoowpxzzoznz
inv.items[k] = nillhkaahycmasozxebflbm
slots[#slots+1] = kbqrpzhnexkzxopw https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
endujaknszhsphf
else break endshjhcxsxup
endefvjjymomwdwsmupelukddaprmntvgwa
endywyttetszraxqgyycbqfkfuhvoftgaeexdyqhrjhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
nujurjmafzfyfcekrykyamkivybnckypfijxrwx
if removed > 0 thenqajbqxkvipokwtpum
inv.changed = truepgiaajddayqywkwfpidikvxyhmiyjuoybwzcgdfhbvf
vsrjuoxximgbvbxe
if inv.player and server.syncInventory thenfseafmtkkgaafjghydcton
server.syncInventory(inv)jvreihcwlpvrxpgdteqnr
endmabxdsatpvizrd
nezlfcpedkmvvcnkbvntaytzeaopkbcxfbjleyqh
local array = table.create(#slots, 0)tchooldnzwktdhlr
kptnevialjflmxuevllvylcidzaygsar
for k, v in pairs(slots) donubyuefqzaadctjxxtaacxgiitfntftgzuf
array[k] = {item = type(v) == 'number' and { slot = v } or v, inventory = inv.id}otyaofkbqbmtmthnbbyeskovyzyqgmjufhvumfvdhiwtc
endokwnufxfjiuofyxbuxjprcbbrqeenrvccrpwxnchvwv
hmvsmzslibebkcoigtjdbqkxnmcuheiprehedzqma
inv:syncSlotsWithClients(array, {nhmtehkvztcbtjpzfjzsjnlmtqdocyamjlvdowdtqpejyuiedhx
left = inv.weight,https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
right = inv.open and Inventories[inv.open]?.weight or nilcrvcisjlqrgbeohqthf
}, true)jodkpopgsgvtgixjmiotznbxczwkbxikmmubakisremxmjhzr
bmkvylayamgzpvwjxrrqsmpgguqzi
local invokingResource = server.loglevel > 1 and GetInvokingResource()fftklndrdgqw
yuambflsayuqupnciykm
if invokingResource thenayjjhepbfkfosekq
lib.logger(inv.owner, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label))hlkefdkbstkkwhkbvcrxvwlpfapumlxt
endqixehiicgamimyrwlfzuedwkpsuevwgmdsjbwfuavesamooyuq
ynwogjdagfdujknhjbujyscjnjtebbyzovovfrwmwzhgju
return trueacqqinlqjrhpchwhnvzxidgvugchkqbksrbafmrodzdgga
endelrmoofwnoznqtmscfzacvjnmfjirvj
endwysdrgwhgxlmssjct
whhweuaffdoya
return false, 'not_enough_items'otyaofkbqbmtmthnbbyeskovyzyqgmjufhvumfvdhiwtc
endkqznlceijnufz
exports('RemoveItem', Inventory.RemoveItem)gdyvizamfjzpebnmjwxhupijjjt
nkxbsevchwtrugewbmbkbtoiys
---@param inv inventorydjdajtxgrzkqutuzpgqmobvpnstgfumjepj
---@param item table | stringclcnlpgacsuvofmotskvcfzsbznqudawockasqhttps://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
---@param count numberphgzbfaazpddefwibh
---@param metadata? table | stringiqiscewdljluxwheacalapifpboddckmtse
function Inventory.CanCarryItem(inv, item, count, metadata)lmwdykaknotjhhnjbpxurzaounzzikb
if type(item) ~= 'table' then item = Items(item) endviloxnmngwqcymwbvstrwoivztcjrtumbfbztnn
wrkiithjnrrhmbbhjgvcyabwxrsqwlgscqbljjvxamf
if item thenqauzdesivfmxbtzfeizio
inv = Inventory(inv) --[[@as OxInventory]]dbhiiamnhbelfgsyxowmxysdjwdxsyjvareisrwz
qditoyxfnbudfxeedbkiooyuxxmvinrzrasgypmmrgpwetbh
if inv thenhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
local itemSlots, _, emptySlots = Inventory.GetItemSlots(inv, item, type(metadata) == 'table' and metadata or { type = metadata or nil })qqfbgtdqvnclhsaqnylmnjyujfyh
dubssrpidwoerrdulrgutb
if not itemSlots then return endvgbusfrxuxwhqbqnrtlvhqhddsprwowsv
ujypyzykezebsojvjncu
local weight = metadata and metadata.weight or item.weightfnzzsbakpgpnfhkiqnngxtfdt
mgeivjgqkllosfckrbtieqxdaadrapqnwuwsdcjnnucgafqrgk
if next(itemSlots) or emptySlots > 0 thenvypxmtkaxwuakqeyaaczxvuomjllgakbyzzltjmrggrqxwpyxr
if not count then count = 1 endnseijaarqlcznzuihftmgrefrqodsaqgsvocwoum
if not item.stack and emptySlots < count then return false endtgdcbuqojxrubzugbypqmbypvpjob
if weight == 0 then return true endunyzbcrxiaiapx
odwsqyirxqmhgflswrv
local newWeight = inv.weight + (weight * count)czndltgwyyszivopblmbi
cwsrtssjhmkoswqtiucuhkzxjkosm
if newWeight > inv.maxWeight thenykvkifxyaktbamxuhtagjasoqzdnoqhnbdxjjvhkfbmfnjhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
TriggerClientEvent('ox_lib:notify', inv.id, { type = 'error', description = locale('cannot_carry') })ejvswxmxrtsvaqqwbosgknljatlsdeihndzkamhrfa
return falseiqkfblszbgcbllntlrwio https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
endgsfgubprihjxblapprsynworalidwiwdbckveznnhwljh
fseafmtkkgaafjghydcton
return truezanlvcvgapxktfilomjyfcmclpeqpdppdcbzfxffmdqgjysxlb
endbpsfpghwhp
endoejksthumlpptmilhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
endrluyeuvqdswdabdltwzxgrzggjppasbsevqjpmzs
endmvfjejrbkfvovgjrlhhyztanbozvvzjivprazjbjo
exports('CanCarryItem', Inventory.CanCarryItem)lverdhzvzjrhirqx
fzygumfojvgnfxhshphbrdofttpoijvnjtu
---@param inv inventorywyweteixzjhysfrnurwuxogzxvnsafvx
---@param item table | stringezqcrhivnyhsombmtgombbquwwzrhsemruoibwep
function Inventory.CanCarryAmount(inv, item)gimylldzzqsgsqhvzcsjvayhryotoqovzbuknxknoctgtac
if type(item) ~= 'table' then item = Items(item) endoebblnwzwdccbi
inv = Inventory(inv) --[[@as OxInventory]]iusfyjcabjugfgsuvwq
ovpdmmqefmpmwqtmwcesycmdvistfnwt
if inv and item thenksqclrevfwqjjvcwmozcfperixpbuezewqghildnhuxrpznbn
local availableWeight = inv.maxWeight - inv.weighthonbrvqfgtsfpcyskkkkeplgeciruywcnk
return math.floor(availableWeight / item.weight)ebpijhxbizarcnrgbaherdrlxcicqonuqcdzka
endsylzqkrinhhkbnjpfhocwthxrohdkzgd
endyndwtwmjrjnpzftnempobtnmeumrnzylmbh
wixhsrpucdn
exports('CanCarryAmount', Inventory.CanCarryAmount)piudtztutkjnirra
jctklbmcllwvzuaetcwrgfwpcausqtaawtkh
---@param inv inventorykqwauqihbtwzcbuyqfsgxzgbxlqnechpsepmvytwrqvusp
---@param weight numberpudqiygzfbzozidajenbsxqwodcibyxrsahbynadoa
function Inventory.CanCarryWeight(inv, weight)sepdihxhngikrnmfpbaghpmpnytvffjykycsgzztf
inv = Inventory(inv) --[[@as OxInventory]]hdicsjgczikywzyhpwwsejghwyvvhcupfcrxmyalgkkdjikzfg
zxefyibzihlajtovonafyuzijzgsevbdsgirp
if not inv then return endhwuzmlcjaktingjtrytnyzyjrnokvovckqcwbeg
https://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
local availableWeight = inv.maxWeight - inv.weightaduizhqbvlxtdmsypmpwgfeemcvkpbiqfczekpggbdzfqsdfe https://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
local canHold = availableWeight >= weightiavwgnnlzzdhm
return canHold, availableWeightukkmslcengyew
endewrghkduzvoolgteoyevgkgoxpurcmxhionoqfclhwzmsaxcfqrdafhmezbj
exports('CanCarryWeight', Inventory.CanCarryWeight)kraimgetuoryvvcrcujm
chwuuifhfngptdh
---@param inv inventoryuumkvlzrduicxpquuipud
---@param firstItem stringeslfafvuwwylbahxik
---@param firstItemCount numberhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
---@param testItem stringoogzzshohlbbyaazmoufftllrzgebhlpvsov
---@param testItemCount numberxozhicjyglefvontlhzhrslsaogydv
function Inventory.CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)ztpnbffdvybpavlwebexqbvjjznevgtuajibonfkmg
inv = Inventory(inv) --[[@as OxInventory]]rtxpccepmzhfoexyeo
tzfjawlebncovqgofhxleihl
if not inv then return endegvjwzsajletuubotvewqbhljpvjzgidmdnjdfjmrnflhhabce
https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
local firstItemData = Inventory.GetItem(inv, firstItem)veeyzrfvtccwagfauafhmqd
local testItemData = Inventory.GetItem(inv, testItem)ujypyzykezebsojvjncu
https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
if firstItemData and testItemData and firstItemData.count >= firstItemCount thengzexwxxtttppahbkedmqpabf
local weightWithoutFirst = inv.weight - (firstItemData.weight * firstItemCount)vidobysdecixhgehlhuitvcrppfypinkqqyrprvtt
local weightWithTest = weightWithoutFirst + (testItemData.weight * testItemCount)thxzfvcjhpvpgdoplbfvongmv
return weightWithTest <= inv.maxWeightcletmercgghbbuoirxdzahdxhyucbaadmewyjobpujrwdgfud
endejpcctrmgovxwdquvgifpoklheadddjhnyk
endrbxvkvutcsmik
exports('CanSwapItem', Inventory.CanSwapItem)squvntpqmuzfhdensjpajldtsndhawotnio
pxnvpmuawijtrytyjjnalehowxshrfxgdlbsxvsuebn
---Mostly for internal use, but deprecated.hpndjndyvdnlapsyuoaeqfwvhv
---@param name stringhkvbcobllcmvcundrqivamdhej
---@param count numberpgiaajddayqywkwfpidikvxyhmiyjuoybwzcgdfhbvf
---@param metadata { [string]: any }gpksnlwrhdvybezszhpzebokwwwgfaclpneczbugepfgueyuhttps://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
---@param slot numberncgqrmlxikdjkmefnjhndx
RegisterServerEvent('ox_inventory:removeItem', function(name, count, metadata, slot)yuabtunbqmipkwnciwfzsczuqxkgzswymxafrngizpx
Inventory.RemoveItem(source, name, count, metadata, slot)fvltegdrjydmzdyykcjttoljibzbdtuiofctmgkvfoier
end)exbxzhhjnfjlclb
zlbjgzdahhhrjjhxmgcktmazxhxfshrsstcysfzz
Inventory.Drops = {}lkjlhgkvapewjwfjbq
dontkzqatkgwavoxojhhvof
---@param prefix string?hqfbbppjggkriwnjefj nnkjjifofolpaevmfsmsbvrspjumnicawmkfupuaef
---@return stringoykwoehclvrlcivljzddpuffzmyjmrsbqcyehhttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
local function generateInvId(prefix)yzbozotjmjzyat
while true dobwwlmuwdqrvbekgfrmq
local invId = ('%s-%s'):format(prefix or 'drop', math.random(100000, 999999))gjcwfhxwpfhpqou
https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
if not Inventories[invId] then return invId enddkteihpxhczbjveznagqu
https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
Wait(0)wivjsnkdjaoxehhxtstyvpnozpzhfzi
endnviraxqqlglouijlyemagrbdhicesplfltx
enddlwowuaplnrkngbkbdawneblcjswskqwwmkthkisyzclg
vftgeaubsewoiiejzxatwietggzdmqahwtoauibmmxavgefg
local function CustomDrop(prefix, items, coords, slots, maxWeight, instance, model)dbhiiamnhbelfgsyxowmxysdjwdxsyjvareisrwz
local dropId = generateInvId()utaymhyhxhcrrwqrjigpbvqpgkujgnlahttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
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/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
不要乱来哦
blgvopcbdcpxqpekpbyfjc
if not inventory then return endkyafsfrxctsdvtmtsiwevdtpnakgxqoipooh
tfddrldwrd
local items, weight = generateItems(inventory, 'drop', items)ebhcqsxavnpaqzfadvbnxejqxnyzfnqjpxmfpjgkxvk 这是干扰码
sepdihxhngikrnmfpbaghpmpnytvffjykycsgzztf
inventory.items = itemshttps://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M
inventory.weight = weighthttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
inventory.coords = coordsruoweaauheamtusv
Inventory.Drops[dropId] = {fnzzsbakpgpnfhkiqnngxtfdt
coords = inventory.coords,qwwxbdzvje
instance = instance,bticqaqhbtgvmsmlbjo https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
model = model,oyvmnbhxlhmuf
}dvonagadeyenuknfrppcqevoejzzppuskigkogotfshzdve
ylzxeklopkkzujizwooaeaqknj
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])不影响正文阅读
endnoanaifgitmaxptqkrtscgbhttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
vpssrgzpcuftkmjmjphpeef
AddEventHandler('ox_inventory:customDrop', CustomDrop)oebnicsuvyesivphdlagvhiybxuulzdaefomh
exports('CustomDrop', CustomDrop)https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
vdxcrtgrnsnipsfvbretoapommqqeixzlvbd
exports('CreateDropFromPlayer', function(playerId)vvhzwwqerafzcfdziyyfdkmsfkbltwm
local playerInventory = Inventories[playerId]fnsjlrgkctlpaknznhrlwmrbaqw
evoqyjuxpnundbfpioozrgcqsthkiyfmtudsdxptljgolm
if not playerInventory or not next(playerInventory.items) then return endghzkwsqblprodynuocquppbmr
tlxdebjymfoezpkldunmasgfhhnczilsujvyk
local dropId = generateInvId()gciqhdffjrqxelcfxffvvvetjgxatxwzaeqhiwmsodptosymlalxqypwykjjgykmbmdvzwhjwytegaqrbc
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', playerInventory.slots, playerInventory.weight, playerInventory.maxWeight, false, table.clone(playerInventory.items))dqneyjvbie
efxkjtfxtjsonyqwtnlhfbedptfxgp
if not inventory then return endzfcnwmauxtnojac
gndcdvtirvmttvtcieotwfjjdeixjg
local coords = GetEntityCoords(GetPlayerPed(playerId))ujypyzykezebsojvjncu
inventory.coords = vec3(coords.x, coords.y, coords.z-0.2)https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
Inventory.Drops[dropId] = {ztpnbffdvybpavlwebexqbvjjznevgtuajibonfkmg
coords = inventory.coords,lasijxpszsbmhghttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
instance = Player(playerId).state.instancekbifodbpxwmxdmyludutgezhupltzdwk
}mvfjejrbkfvovgjrlhhyztanbozvvzjivprazjbjo
bmswnyxwvdnzndgu
Inventory.Clear(playerInventory)ltupkfdwgutnepukdllhzrd
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])pvljljnzxdknpjduzaagadvrpndyijax
juzelmyhlvusgbpcuvubklerrljs
return dropIdhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
end)nmvommnnarzjzllomopnwakvsafobyxoksdwe
umxcizsklqkzeyhtegbulzkfqgilthttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
local TriggerEventHooks = require 'modules.hooks.server'pvsledzbbdwokiuqdsxzarvloysxj
jtvgnvsngs
---@class SwapSlotDatardobuwpbeacsjsxqgznahkrwsvhr
---@field count numbersoxvkybkjyi
---@field fromSlot numberrbxvkvutcsmik
---@field toSlot numbercxmjeuehfnpoqoqxatpdrgzzezzuutrwqdgvylcdyssphimh
---@field instance anyfxzjagafqmygfnxixdwadtrwcmryrsowpngquhvltt
---@field fromType stringpyrsqithnuzsfpcuwywiikwdws
---@field toType stringwjfspkucdcsemvjxafblzzrxdbckmqxjzccpnwrqrafoypyivwsiyfluehbod
---@field coords? vector3zjtxjbdtnpq
nqotfhegwwhjfzndibtaozrm
---@param source numbercjhhkznplyjaydhljumwzgongifusrtuaaclapamnkmmouyxpk
---@param playerInventory OxInventoryptdnugapcxfaavrfjwasewzbvpzmwyzmrcamjabl
---@param fromData SlotWithItem?https://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
---@param data SwapSlotDatajhqrjbimehciwsxmeblc
local function dropItem(source, playerInventory, fromData, data)fgxowuvejy
if not fromData then return endzqorpjduqszhqgniyoxreklhtzefgbtfriwgsabjsb
sabjcpbirb
local toData = table.clone(fromData)knbnuszuykxgwfwhoirrkgekmeqgegeotgcnzbiymgejlaqaj
toData.slot = data.toSlotxagsofmvhtmmytspgatdnzgvyvjewcwtdclriynpszcr
toData.count = data.countclcnlpgacsuvofmotskvcfzsbznqudawockasqhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)roaqustyzrtewbbhorefzwflomnugcv
phexpslgrbrqorc
if toData.weight > shared.playerweight then return endjrmmbxlugishzkhttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
nafssynybfzxivxlzuvzdpvkcqcqwvpkvucotpmuumrdhopgjl
if not TriggerEventHooks('swapItems', {zmjizjdrwslhzbstfdgibshjcmivoudogmwg
source = source,qpeojcyofwyqdfbpm
fromInventory = playerInventory.id,ralcojfoqqnnsuub
fromSlot = fromData,ubyzdushaqurbtrobdnfetiqkls
fromType = playerInventory.type,smpsshlfztukgiywbctskfpttqydprxhenawumbugwemfc
toInventory = 'newdrop',leijmeyyctsktnlfcczzdpityttcmeiyjri
toSlot = data.toSlot,laschtvopigctimimdaqccrsazjjitbtuuvcorqdzxgthttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
toType = 'drop',eehpgstehgactpcgesbpaypssgkbfeakjhzpattizuktjnzog
count = data.count,lsukqrlqdobatytaqakaxdfvinzsgfkryecovoezcfav
action = 'move',jryecltprtejlgoajfpg
}) then return endbsjnaqciftahoatywwxteyqypbdxsdruvbhwrkexdfesf
xfzzvyhxzgbivcrcjppwptyyrv
fromData.count -= data.counttbeajykghndxffegfzivohsfbfyfegpxhtxrs
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)lmasgacpluzzdzavykkcdvjlndtaapkmbleimh
zbqblzxlphocjeloqqgbqqvfzuaho
if fromData.count < 1 thenrngbqeqtlsjfqtxcziavhadiyhsgbouscbusflmrd
fromData = nilfwmjepbvyzcvyjqqnunrxpkfdomzravxxigbyiwwhyrgiiww
elsehttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
toData.metadata = table.clone(toData.metadata)nohrsfcewajtquwirv
endiusfyjcabjugfgsuvwq
vsiwtanthpaxqmuawxbecmyttapyqphlhpiaqv
local slot = data.fromSlottzfjawlebncovqgofhxleihl
playerInventory.weight -= toData.weightaifmghcbeytzcfpkyhitdtgzffwcewyfferllumqsgpvmff
playerInventory.items[slot] = fromDatanxwdlpljenwepbkpvra
jlbamfxvjkcxkvyevr
if slot == playerInventory.weapon thenyrtobbnjmuyzohguuczllnoggocsvvu
playerInventory.weapon = nilydnuhtqpqfkbzbfeycgnyw
enddmwyeiqywykkhyoevbwqzmhizoepjrhnddlimchibsti
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
local dropId = generateInvId('drop')https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', shared.playerslots, toData.weight, shared.playerweight, false, {[data.toSlot] = toData})kqznlceijnufz
ubyzdushaqurbtrobdnfetiqkls
if not inventory then return endoktdeerzazogklyjjfuo
fxzjagafqmygfnxixdwadtrwcmryrsowpngquhvltt
inventory.coords = data.coordsgpksnlwrhdvybezszhpzebokwwwgfaclpneczbugepfgueyu https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
Inventory.Drops[dropId] = {coords = inventory.coords, instance = data.instance}mkgmcfqqbmetqwrbupdjctzvbrrzvnihyoubt
playerInventory.changed = truetlafgtknbt gjzkeljurnsahciwaexdd
jgpvmqosvhlxthktizybiufykpkxaknjrcedtswoah
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId], playerInventory.open and source, slot)bdsemkwnwqcuxab
kgwkhaskyygenhnusml
if server.loglevel > 0 thenwgjhfdpenxowethaxpgqroirxjionyrjf
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId))ynbowzeorgykzzijxcgmftpgvvgsifxgszv
endwpddpgkrqgpdkwsdkyobocsnxxxsdi
raaaelhwiitlxlbgllzjbzkvbbavrfoifojkargizztxk
if server.syncInventory then server.syncInventory(playerInventory) endjepurxjlndbywqcjudoxronprhchyngirwcjtlvgpwfmnivilj
hwufdqflijkhsdaqkueytpocpk
return true, {fkgaebhzrsgvzqspurvg
weight = playerInventory.weight,gsljmertdmk
items = {mxtqkbbhmbnsyknvujfskjsu
{dlwowuaplnrkngbkbdawneblcjswskqwwmkthkisyzclg
item = fromData or { slot = data.fromSlot },ulhqtrwzvbyhqpgwuhetumalbcpvhhpbtwsmnoljpkrfzy
inventory = playerInventory.idovythwwpyldlsoeehxbpdqacggopuasjv
}yggktskkffftolv
}enouhmoaoicvmcweiobmrkwzxb
}jgzexirchtvxikei
endeihshzfxtlbjffltjpvbhizjnbywrdkwmroururkg
wfvyupxoxkjjzjklbruwwiqauuptyzxufthttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
local activeSlots = {}vypxmtkaxwuakqeyaaczxvuomjllgakbyzzltjmrggrqxwpyxr
rjbsbpaxzngdhegfbjvyc
---@param source numbertclsddpifvtupas
---@param data SwapSlotDataxmnwgvdmppsguyykmbdnsjfoxhkmbx
lib.callback.register('ox_inventory:swapItems', function(source, data)alyhdwestrqrjtafwxyuhuvzydrpzqiacghgdmywdonnhhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
if data.count < 1 then return endzwefudcsxrdmjqjausveucgnfa https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
txsonjncwoduoisjuvimmuvmauomnhphe
local playerInventory = Inventory(source)ztpnbffdvybpavlwebexqbvjjznevgtuajibonfkmg
https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
if not playerInventory then return endqkblejovchyywlmlcwssaehofmephryyczkgi
lqyxyrosuzmdotikjiqxkubldadiyotkfrhdjvw
local toInventory = (data.toType == 'player' and playerInventory) or Inventory(playerInventory.open)twhuqzpvurbixcojojpzzapkoimzssxloeffevaznchkfwttf
local fromInventory = (data.fromType == 'player' and playerInventory) or Inventory(playerInventory.open)xdjezxhobcibjqtjbvylambqaojujkfgoolomt
crupzkelehvziqehdtswsnnykeeuqtktleikpmwtuss
if not fromInventory or not toInventory thenzbdyhhknclnxisurtgkdqtzlmqcnsahrckqkraxullrud
playerInventory:closeInventory()xotfwiiwefluisfeixawsctdmvrenixkxrpuzyqedcylu
returnjlpwelymbigjouoklgfauirbdebyktwtflqkwpwyxdhlyvwjc
endoobdcltnscbojqeflp
yhvvgzpkkhlketaspkmvxnywkfkmmchljdgpcvamdlxhexz
local fromRef = ('%s:%s'):format(fromInventory.id, data.fromSlot)cjbqfljhhxhtbozinhkoapisackhyvybfaslmbstzana
local toRef = ('%s:%s'):format(toInventory.id, data.toSlot)ebvgbeljtefexuxmateu
mblifnncepynzxbetixoihwkvkpgwvgjxsrdffgjuextczyvhv
if activeSlots[fromRef] or activeSlots[toRef] theniprkwhrcypqgrzijmetlxhevc
return false, {hizugyxongwrcqomlivgnzxxts
{asmazbxflxkxfrpaaydafiwkunvreaxftkf
item = toInventory.items[data.toSlot] or { slot = data.toSlot },jicpukuxbpxblwutcsadstaszvlfhpeqxhgsrapsqmtcjowlgwhttps://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
inventory = toInventory.idrdpzwugyoryywoefayhkmvr
},nmvommnnarzjzllomopnwakvsafobyxoksdwe
{https://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N?pwd=bcd8
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },boavemwnklyr
inventory = fromInventory.idxieybaqoofzyvjpajnddsk
}zzcdqotrpozn
}bbtqfsmvlqqi
endrzqmajutxpgnnlqkppejukuiseuhsaukakwburvs
nkxbsevchwtrugewbmbkbtoiys
local sameInventory = fromInventory.id == toInventory.idvjjxaoinwnmhtxficduousjtqsqfdr
local fromOtherPlayer = fromInventory.player and fromInventory ~= playerInventoryuqqronkqvqockupraitiyzrim
local toOtherPlayer = toInventory.player and toInventory ~= playerInventoryhlkefdkbstkkwhkbvcrxvwlpfapumlxt
local toData = toInventory.items[data.toSlot]qbkujwceevzgvizpzddcbdolpkpdgswxhaggvolywilsrlhqpksr
zolghzeiixerxcimlwhfxndefsybasqahbhpamxjjc
if not sameInventory and (fromInventory.type == 'policeevidence' or (toInventory.type == 'policeevidence' and toData)) thenfqqpuljzjwwlk
local group, rank = server.hasGroup(playerInventory, shared.police)ubyzdushaqurbtrobdnfetiqkls
bdpnbxkrxhpoiwuixetjhhmppfwhhtzjxpxymhqjpfxx
if not group or server.evidencegrade > rank thenrtxpccepmzhfoexyeo
return false, 'evidence_cannot_take'dvffzotgcxvwxrdcpj
endolaangbbnzorkolptekrwcromdptkjkzvlzjrakfaywl
endhgllvzgqissbarzohcfwicnmanzybwljcwvxwbof
jucarlrehdbsbcbugxlzmwspuedroihpdniaadljjxtzdshgwmvniodcshuhpcws
activeSlots[fromRef] = truedvaoluscokxbyzpyztcniavptxazbmsfhtttnmvcwteut
activeSlots[toRef] = truesjounlvxwu
sudxlxafocfnmhcawibybhuemzevnmmghqesnexchcpt
local _ <close> = defer(function()awgrzhxljyjowmajqanfvrrtcxfstmaujhmi
activeSlots[fromRef] = nilinmhiioecjhnlpubqdrsztwyrnaijbmsoz
activeSlots[toRef] = nilhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
end)nrdtbvmrhavajuflychboonhksltsxhfokzqgliol
atsvetqvpyhjoczdjtgzgghhudhnbzkbtcwywmumlcvzevd
if toInventory and (data.toType == 'newdrop' or fromInventory ~= toInventory or data.fromSlot ~= data.toSlot) thenmwtujsrupuip
local fromData = fromInventory.items[data.fromSlot]xcbyyxwwxdadcrzufjqpgoqfhgsxgquesvdqsznqcntffsal
stsummpsdeokffjyteojmwiriisyrpnkjgevsuovyd
if not fromData thenwfhdmrdotusqmzmmcihrijdwbxihuxkq
return false, {https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
{https://pan.baidu.com/s/5G6H7I8J9K0L1M2N3O4P
item = { slot = data.fromSlot },njmoshcpoqmykuchbpqjypbxgjporllfuxunfwdtmprxkuem
inventory = fromInventory.idhttps://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
},xesievmuaeyakkuuvbvvgecodfqwueqsiiandmhergebr
{wkjfwdnxcqodaxpdeiscnc
item = toData or { slot = data.toSlot },ohybhynbigitdijobikzuidnf
inventory = toInventory.idsfnuikkznmmkofgxnovoufjinljhttps://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
}miinstrmmeptfmhyzqnzsqqgogatbymohubzosmaxbudn
}lixwouttuegimced
endwfvyupxoxkjjzjklbruwwiqauuptyzxuft https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
zytrjarlskqwryxjgglsohhjkvqxswusvnjenbqglgccfamm
if data.count > fromData.count thenmxmwwyxuypfihwirsznydtu
data.count = fromData.counthxbettanhrtmdfwoplzqdnmahjidgrqnorshlsut https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
endaolpzyxcqomcylntmmipqnww
xeuxztoknjz
if data.toType == 'newdrop' theniaoqxchxevckcesfcygzog
return dropItem(source, playerInventory, fromData, data)jibmbhzagrcgcrnsfszpbpcowzibdbsmkuylbylhqoo
endkxelsymvoxxkiyulpqjwvkbdxlpjxdihbmtulfpzdmjlldxbtgqnbgkcbqjoakqkbryhgzipxedtympmsgaumkwobg
mvpigjvmptbjvjlbsudyhvomxvthzubmpquwapjqikzetk
if fromData and (not fromData.metadata.container or fromData.metadata.container and toInventory.type ~= 'container') thenvbhqjuhgoevqsvondrhumavgs
local container, containerItem = (not sameInventory and playerInventory.containerSlot) and (fromInventory.type == 'container' and fromInventory or toInventory)cuwdgduhucqeb
vefkonoelixrpyregfcujgisjapxuoiqsoahbo
if container theniusfyjcabjugfgsuvwq
containerItem = playerInventory.items[playerInventory.containerSlot]wettdrqaxohtjnzhbguf
endyuwpwmxkjksaxjgmlleebjnm
ujdsfjhruzjzmxzljnfjlrwmnxvqlnqgxuycdgtxfcxszwdjjj
local hookPayload = {https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
source = source,cihjrzycnayykugouhcfkcweqtvybfxenfnffmismhqxbxlwen
fromInventory = fromInventory.id,nkjmoejxgahrvazycscmse
fromSlot = fromData,wdvqfwhapuuvupkz
fromType = fromInventory.type,ybsniefzbhalbizpwcxkzeceg
toInventory = toInventory.id,idmojrpysttcfqeqcbiqwgbtxvtypudyxqhttps://pan.baidu.com/s/1T2U3V4W5X6Y7Z8A9B0C
toSlot = toData or data.toSlot,oszhgmhhzap
toType = toInventory.type,exbxzhhjnfjlclb
count = data.count,gfcyqiokbfifvadde
}kihfqeuukhfixmj
udliwosaxm
if toData and ((toData.name ~= fromData.name) or not toData.stack or (not table.matches(toData.metadata, fromData.metadata))) thenmjfhtxdwdjrhslljjnigjidgkeqqcyfoilwbizylip
-- Swap itemshttps://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
https://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
local toWeight = not sameInventory and (toInventory.weight - toData.weight + fromData.weight) or 0npwmxlwlijlojuwdi
local fromWeight = not sameInventory and (fromInventory.weight + toData.weight - fromData.weight) or 0pavgwvpvsgzdtgvkjjicprkxrsuwyemnehtacjwvqv
hookPayload.action = 'swap'qhxqcyqnkmztudmpfvkygclclvaxxsroapecnvqxhprcse
faezakeulpfgylf
if not sameInventory thenvvhzwwqerafzcfdziyyfdkmsfkbltwm
if (toWeight <= toInventory.maxWeight and fromWeight <= fromInventory.maxWeight) thengbdubuspxbsqqskmw
if not TriggerEventHooks('swapItems', hookPayload) then return endecqbbstqcelqhovezumwuwewfjljrxvvalxberr
pxnvpmuawijtrytyjjnalehowxshrfxgdlbsxvsuebn
if containerItem thenaqqhxirzfrhvvpgquyubxpbhgiqyynnzddhamyarqh
local toContainer = toInventory.type == 'container'dohqsvptgvwmmcrpffb
local whitelist = Items.containers[containerItem.name]?.whitelistejmcjwgjegwfgpadmnchwmxaqpwgrewwniyxffgkmcp
local blacklist = Items.containers[containerItem.name]?.blacklistwdywpbznlmypafftbuniqjvdmnsrhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
local checkItem = toContainer and fromData.name or toData.namevguyamitzuycwycaoltmenpqrxpaoxvkdqiddqxdkwfhvih
ayjjhepbfkfosekq
if (whitelist and not whitelist[checkItem]) or (blacklist and blacklist[checkItem]) thenfrmkamvijjdptrt
returnmohdfgbnmuduycseqegfxfmds
endlkhnibjskneyhcbxrazsqyuqpb
bfvqqceghvkvlxiwxmoeoeyrwnwikeyljtczvhgddq
Inventory.ContainerWeight(containerItem, toContainer and fromWeight or toWeight, playerInventory)irubqwuiobppshhrljvoltiwvvpyvijdzefqbayhcdrrgyjdvrebyzqjynrk
endkvlfejgklsjkjgnliyyywhyyknmgedgoysuccbmntvydblokkm
hhegoauanaebfqlrujgbsusimebfqtnxareps
if fromOtherPlayer thennhlyoesacxgkshttrbepknjmanjajwuxegwtlpuomayeis
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', fromData.count })ibnmrcbxjefptuqtrucfvvcjhnfzntywvminokkyppojkecby
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { toData, 'ui_added', toData.count })jloybvwwcnjfcelkprrjaxbksnorhtcrfrphnme
elseif toOtherPlayer thenhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', fromData.count })grhwqvnslwdctxcxyxjsgatklmrixxgeonafjnyukbxezzbxw
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_removed', toData.count })sudwqeijastpgokmedapsyvdqmzkqgqibt
endgnsqfbggkeb
pcnqgiwnpwfsgaynpnkawardezvhrtegwswcasqppvhwvgjl
fromInventory.weight = fromWeighthttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
toInventory.weight = toWeightrzqmajutxpgnnlqkppejukuiseuhsaukakwburvs
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot) --[[@as table]]druqxuyglhzxzolvhvrir
pzuksdrczpvzacgowdijcofrsdidzkgp
if server.loglevel > 0 thenthxgmoofaczrbcwqrdb
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))bqrrvyhaybpinwlaeitmnhfxtbkynsppiggefoedptl
endzievfdzdhydxyg
else return false, 'cannot_carry' endboprgemucjpxljqnzuapruirjkctzcyaro
elseakbypkhsvwmentqziwed
if not TriggerEventHooks('swapItems', hookPayload) then return endcazdkimnqmbleurciepkgccronjahvekw
axoqajectsshazkqkbynla
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot)xumanrnajyoyzqhnwaphuiwaqyarz
endqevjijahxbeztrrvlpbkc
qdgbzrqfommxjepmkustpxrjzqhuydepglqfdh
elseif toData and toData.name == fromData.name and table.matches(toData.metadata, fromData.metadata) thenzfqiprnspuwgspnlqqaycazjnqjeahzanqjdhwvxrrekhrv
-- Stack itemsxbxrmtleknfardlpnvryjyxkncsenmrkopbbingt
toData.count += data.counthttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
fromData.count -= data.counthttps://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
local toSlotWeight = Inventory.SlotWeight(Items(toData.name), toData)vrsbuadzhvzvmdgxophxoddw
local totalWeight = toInventory.weight - toData.weight + toSlotWeightwfchleaxujdeffnmrz
ebbkfyurprvgunyqinyqdwoirrzdieymfaxlyrdoiyvdmttcjmufqfbbsgkfpqwchwdzadutoijtofwyrqdiwfkpluublr
if fromInventory.type == 'container' or sameInventory or totalWeight <= toInventory.maxWeight thensplrhgzmmiildkzqucjgmnaounzguawnpiewodjbmrm
hookPayload.action = 'stack'ihiemmeqtdtrcayjcooogbctgwcefaioh
https://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
if not TriggerEventHooks('swapItems', hookPayload) thensqrvfbfvcdjtdsxflpytpxdghfevqevjumeankwqngjqygwkvu
toData.count -= data.countuthccsejabdrlltfsk
fromData.count += data.counthttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
returnxlyvvasivkmyubjlwllrpnkfgavzzejxphslil
endzteyejeoydjjgnnvigetukmvzglayfkyzoweya
kgxbcyccbupouews
local fromSlotWeight = Inventory.SlotWeight(Items(fromData.name), fromData)hazrfokhbhkqzyhzhtszsobwqfetiffqgfhmtstv
toData.weight = toSlotWeightgdyvizamfjzpebnmjwxhupijjjt
xqjcpciawxjgjwneiyczpguoemov
if not sameInventory thenqdgbzrqfommxjepmkustpxrjzqhuydepglqfdh
fromInventory.weight = fromInventory.weight - fromData.weight + fromSlotWeightgnsqfbggkeb
toInventory.weight = totalWeightdontkzqatkgwavoxojhhvof
xtlsrtyhhjsolnbwlkvidzanlcaqunwrhij
if container thenayhgbqmvawridzskzwihnlpggmorqxprvxxxokspgjykjqvjm
Inventory.ContainerWeight(containerItem, toInventory.type == 'container' and toInventory.weight or fromInventory.weight, playerInventory)yqknnccznzfvnzps
endtccawulburvimtpuqpgtcqnahbovztys
qtpojuyvzpxmhagdxvfhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
if fromOtherPlayer thensvdmesmrldqrpbmttxswo
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })jydhdewhsrjpawgkcuskb
elseif toOtherPlayer thenonfkzmtdwwqhwijqdprudxnozegneowsbbcbo
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_added', data.count })vbpqpjizcyrsevkjumxhttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
endznjecpptvsagktezwgelsdtysywqckwbxff
gaqdestrtouy
if server.loglevel > 0 thenebebbmpkxxskghxtsbvqjwwbyaymkkxomcpnpfy
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))kntndotvdlyjgdhrmnbrpjsdgtkwqstagmokbiffueoaivru
endipuhfycoqivskkozqfkzmzzkxupixfwgvrnaqqpgy
endhttps://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
shjhcxsxup
fromData.weight = fromSlotWeightjidplbsmtfqnuuqfnwhxkcaspwwtwiygrc
elseacwwiewpohkvscgfxrbxcwzbqqtusvxtx
toData.count -= data.countpzuksdrczpvzacgowdijcofrsdidzkgp
fromData.count += data.countkyfkvmiveeppqdeyzdpqmf
return false, 'cannot_carry'vjjxaoinwnmhtxficduousjtqsqfdr
endbigukorqagdmmrshbypydzjjlauosgkupqozegqfntrzlkhmfujzjzellmilyalvcrmuvnaczebaoxnuswucvznhlvskwe
elseif data.count <= fromData.count thenxtotbpkernsxgxpkuxkhfajrtnhxevfcpuwr
-- Move item to an empty slotsplrhgzmmiildkzqucjgmnaounzguawnpiewodjbmrm
toData = table.clone(fromData)wgjhfdpenxowethaxpgqroirxjionyrjf
toData.count = data.countqtodbnuvkadhvvukdcsguejcdixgglmweaz
toData.slot = data.toSlotrlanyrpljackapzpcehttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)ordrscqqovsxyhpknqxdakgqjtfruznjqqajtrzhnsfmzuw
eebfuiumknfddjyurlsjvorerz
if fromInventory.type == 'container' or sameInventory or (toInventory.weight + toData.weight <= toInventory.maxWeight) thenaujsbsakgznblomxqccnjjnvkzkfytmyowr
hookPayload.action = 'move'xevfmeqivnashsnvcsieiopprruregybluh
uradoebwwidldowtwvrfzqa
if not TriggerEventHooks('swapItems', hookPayload) then return endhttps://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
rzlscvoejzlybuc
if not sameInventory thencohmiuvsjravxjmywpeyzbijtcpagbci
local toContainer = toInventory.type == 'container'kplapozgdahttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
uycvgzmmpgxcmiyfqbtvruembjerjnte
if container thenhyiyuaxrbzngolnsiophwxqk
if toContainer and containerItem thenewbdbyjzinklksrqnxvytey
local whitelist = Items.containers[containerItem.name]?.whitelistqwqetxbkhisjcgokcxbffbq
local blacklist = Items.containers[containerItem.name]?.blacklistwkdabipzjvfjyrkobcrhpffvpzzfqhqnsuntccs
uotmezvxontm
if (whitelist and not whitelist[fromData.name]) or (blacklist and blacklist[fromData.name]) thenefblpuaqhvxrbreblfyvhhgmtowsnvorapdqkdgrzeiavnbh
returnjalsvitingw
endsnvtqmvzqr
endldjvgzrbbagwaumeojehbeoeikofahblkkhrkytlyaizvue
endvkyadfkctsqhwg
cdnjouuqjoolab
fromInventory.weight -= toData.weighthttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
toInventory.weight += toData.weightqajfqpmwijcyehqzkhsjuimicrovrzxi
ovhzpxizfgrfl
if container thendbhiiamnhbelfgsyxowmxysdjwdxsyjvareisrwz
Inventory.ContainerWeight(containerItem, toContainer and toInventory.weight or fromInventory.weight, playerInventory)mxienhvrnbtilzqdjqsglhpbzdcgerrroavcirt
endujpjvoupdvrmunwwpqhfmftoqrw
sqjmydjaepsvfdklqwtawwvvvhsmjwcbmlokpxkundp
if fromOtherPlayer thenvgsctfgiftdh
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })cxuagxbhgvomchgxdxytptoowohcvmrxjmyqjaypvm
elseif toOtherPlayer thenuoayqhtbtk
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', data.count })icicvrwwyrvukcutiqeeuuhlpxjpzwhhypjuhgrfxmzi https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
wnotpgsjcfvwinqfmnmefyyzrmqiepdadsutzmcbsyyalog
if server.loglevel > 0 theniojkyiuwsuodljftebyynrsitoqnyyhgmrrlzmhrhvusfa
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))dmwyeiqywykkhyoevbwqzmhizoepjrhnddlimchibsti
endbrsauwfgxkmcmqikkpuatddppfykiirkakk
endhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
fromData.count -= data.countvffwyinuxzepfllxnwwtlpncylphx
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)iqxknfmdkwokesgykblkilnowm
yhrfrximevlnwiufqgmakjp
if fromData.count > 0 thensqzaqueodp
toData.metadata = table.clone(toData.metadata)dqwjyucrvyhfuehtefgoqedcgtqwyoibfflezovvcezokjgkxrpvjcguuzacvjpqnvzesvbuzaikkpuihkdqnkkh
endqqlpjlcthhufetqnpenfcwjywduvyrx
else return false, 'cannot_carry_other' endoraurnvcbiarkceumspwsacquooikfxyxytolprmxr
endkbtulddosuzqmrkjpovdsdxtghqbx
pfbwwkxwwnkrdcdvwr
if fromData and fromData.count < 1 then fromData = nil endvstmerpmufaharkequfrmfswiixrzzhvsbhwsxincju
byinavojqsqsraeofnpajvoxgnwjuiewgmjhiyrzqhriiw
---@type updateSlot[]wpzqpecbdknyegfgvharcccngtfrdxhzmhqcmtdpdro
local items = {}zjpqltxbadrtjygmevbbncvdeilktwatfpjqigsikj
nkuxnvzgruutkgfrsyehohlgjlcqkjaxtuugpu
if fromInventory.player and not fromOtherPlayer thenthpezbsakkapbmwfjhxs
if toInventory.type == 'container' and containerItem thenaxoqajectsshazkqkbynla
items[#items + 1] = {ngvxnqalrbiosaepmlho
item = containerItem,wvkyytyukybei
inventory = playerInventory.idedqmmyotzablzsikyhf
}igliceeveydgxtqahuryvvefbqcdkhbsnnbpsflxdpebiucpp
endcofvvmmgwivicdexzuwucg
endzhphesefwxwsaikzacnwsbdi
jeihznhfcf
if toInventory.player and not toOtherPlayer thenqhecwmgdoasxgtzbnrbcgygjmntpkd
if fromInventory.type == 'container' and containerItem thenwloabsjycld
items[#items + 1] = {jzfetbxgssdgkkpttills snhsnlmhavrtjwpiogmwdrhsdbmenejgs
item = containerItem,wfchgnbskxkskxkhigfdzykirovqimmfrpnycormmbewzpe
inventory = playerInventory.idfflkuzednwhiujxcypxfusvzsgnfnlis
}ovbfhoqzvkqqmeh https://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
endvelqlmyhblzensugdxsrfegqlepfjxhe
endbkbfgljbgkesxtzolfrqbrzvhtrqlnbmycrfnb
krtdalciybh
fromInventory.items[data.fromSlot] = fromDatagbdubuspxbsqqskmw
toInventory.items[data.toSlot] = toDatadywgafvxkkmbdigtbihbrjfmfaizhkkljgskmni kqlffzsxjgspqdcczlkhvvqmrmzozotkfe
pgsfcytjwiwdtldbnmiszxhtmiiznxrdekjhjcqfkniey
if fromInventory.changed ~= nil then fromInventory.changed = true endhttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
if toInventory.changed ~= nil then toInventory.changed = true endfrkwktcflrhvhzwkduobnhlelhhmkjlqbwnlppragzvoysycmn
napbqnbaxjbpr
if sameInventory thenffwyxaurmnkvkorohhbirhgiw
fromInventory:syncSlotsWithClients({ahtkqhkclsqhpiogommrxokvkdpoedkfkdqakbdvttdicso
{cehxuefhxlnqwqhszlrhbgtp
item = fromInventory.items[data.toSlot] or { slot = data.toSlot },https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
inventory = fromInventory.idzwjlllhdxkvqqpcewcagpvizpzddcbdolpkpdgswxhaggvolywilsrlhqpksr
},gmmupdaxnyvatkunupjgxhebkjlunchtouoexoblm
{sdrebwwcuugvyxuvauefamumzytnfxjxaabcxxesskoriimi
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },rjbsbpaxzngdhegfbjvyc
inventory = fromInventory.idahtkqhkclsqhpiogommrxokvkdpoedkfkdqakbdvttdicso
}ifxwhwkabgddyi
}, { left = fromInventory.weight }, true)nyvlsktrlapzcyglrjubxvkiveqzsvkfugrnqke
elselguzibqhiomoetpjesjxazqpsnrbroscvnbdpslyhym
toInventory:syncSlotsWithClients({rwpzaokxplxcwnzsrgardxgqidww
{vtofmpqiqiklkusfzocyuwnhimcmxips
item = toInventory.items[data.toSlot] or { slot = data.toSlot },https://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
inventory = toInventory.idqykcsiizjunsuclmabutflkepworthljgwmzevyoqlglorhttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
}ltovvznodnagwzhddcrszrnjsqnsdcpowekrexghlgnhfvkix
}, { left = toInventory.weight }, true)qgoqagzrvbmcjcrxrqzyjlhwqzptlaqcgfthlsyhukkdnbbf
mjfhtxdwdjrhslljjnigjidgkeqqcyfoilwbizylip
fromInventory:syncSlotsWithClients({nhogfjymnpm
{dvonagadeyenuknfrppcqevoejzzppuskigkogotfshzdve
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },qcivdpeewrclz
inventory = fromInventory.idsuwxpypnmopoobnfrycuzrhgmtgoxczpxvnmuc
}dptyozkvzivntrvojdgkjmiyjdt
}, { left = fromInventory.weight }, true)nderdixkjlefzxkqwkcanvqgppraqdrehwvkftuofzu
endcgkvlqntexcetuxzxangph
arbhzlsaiqxlzbvuncyvxrxukioysrcsj
local respilqgzocjtmvgpcrygyoiuovxzs
hahwpnsccsqtlclnilolhyyteihttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
if next(items) thenzwefudcsxrdmjqjausveucgnfahttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
resp = { weight = playerInventory.weight, items = items }vnfhnbiurwnlbbw
endhfnweqjocusavmht
ebvgbeljtefexuxmateu
if server.syncInventory thennsmyrhkqivtqewlqaizzxaazrwchjbrwueummf umfmmsyjwe
if fromInventory.player thenndusvtijmhdqbjiyqfen https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
server.syncInventory(fromInventory)yywxpglricyyhetxdtd
endcbpkexfyufnaoxefdyuierducdimgnbiprtuoysjeg
teiwwgcvvlpjhnjzsoqxnondschzbfsvkashhucdgsmng
if toInventory.player and not sameInventory thenxazdeuventuixcmtckiyhvccwgmtnqnkrnnvhizucudawq
server.syncInventory(toInventory)lehrzhxoyyibb
endqmukiddoxjtmhcpcisajzghzqolyli
endcehxuefhxlnqwqhszlrhbgtp
splykihmkidvealaofzawlruepxahppzeaxojebtne
local weaponSlotgrecssuydiknjdzbhdko
cvbfvokhdpyutggazohnxoeenicswouz
if toInventory.weapon == data.toSlot thenqckmfqtvrcsevykrbgwcevplgvordzuuc
if not sameInventory thenjchtneajfvnvvatuxzgabihfiycjgbqqeykr
toInventory.weapon = nilgguxotxuyephotxzzauaytmeyyfiezkl
TriggerClientEvent('ox_inventory:disarm', toInventory.id)xxnvhudlnzivlygyzn
elsemyhbivevbbgiavmnesgvwlwxuyveiutvsbxbwbwydd
weaponSlot = data.fromSlotoohkmuzqidpzzcwinahzjbbjxjpbmfabthmfblwkomkoogxcge
toInventory.weapon = weaponSlotfrsbchpmydc
endqqofigmtzh
endpliysgclvetcmkeuoygmlnmvfamdaxppjyobeqmz
gimylldzzqsgsqhvzcsjvayhryotoqovzbuknxknoctgtac
if fromInventory.weapon == data.fromSlot thenlshrzmwvdaqmvdrwqbthozqfxwbirvmdn
if not sameInventory thenyubznbtczzjkxcqpuroqlgggjods
fromInventory.weapon = nilifurpckqrbdeydxtsjqewdacb
TriggerClientEvent('ox_inventory:disarm', fromInventory.id)leflqnetztrvvhtoxajtwizyrpinuubgygrouvit
elseif not weaponSlot thenznmtxqrqcntywowmlzsuahixsaextgxstkmraeidrbboqxacws
weaponSlot = data.toSlotrgzwnoowzkktsihwhogvfgrdzwkcflowsnsfbhc
fromInventory.weapon = weaponSlotljhqhwgikrzshssdavqccxixzgzmtqkezrvgncpytprbijeje
endnfglsjrcygqjznfuynwfyoclbhrxaiooouahdrjcyam
endknwgxdbrqftcuiuwowvlymtntevrxiehwaotepluv
jumoazyinbgytmemtnrrkzwyynxunh
return containerItem and containerItem.weight or true, resp, weaponSlotbkbfgljbgkesxtzolfrqbrzvhtrqlnbmycrfnb
endemyuqjmtfjmqkvuc
endbaxgurarqwbzmadjlzstinz
end)ruqrcqfgsjat
nnipowybqxafehazjzlvnzctnemjagenundjjbkaylgdsg
function Inventory.Confiscate(source)hlwtzvlttmcugdppqpavjrpnjyzyfzyivcvvseidpkywonlfd
local inv = Inventories[source]izoddegeugxn
vfoynqbutwabwgoopdnqmsztsmbxogaj
if inv?.player thenzmgwefybtgqwduxznabakxeernme
db.saveStash(inv.owner, inv.owner, json.encode(minimal(inv)))lkjlhgkvapewjwfjbq
table.wipe(inv.items)fyxyukccbajwocrrissustuqdjb
inv.weight = 0dzlxjtrtuvdykrdpurkdflqagnafscvvchslakfvfit
inv.changed = trueoxesuauqcvsrkxffleiinpacfdficqtkmoayfn
ksqclrevfwqjjvcwmozcfperixpbuezewqghildnhuxrpznbn
TriggerClientEvent('ox_inventory:inventoryConfiscated', inv.id)gpksnlwrhdvybezszhpzebokwwwgfaclpneczbugepfgueyuhttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
if server.syncInventory then server.syncInventory(inv) endxtxjlpacmqgfohqvqjfsptdrrexxgnfdgcns
endphjbmntquklkwoojasiozefyuqbsseshmbjyodojnztjohtoab
endxxcswkyiiwmh
exports('ConfiscateInventory', Inventory.Confiscate)fxirbmypahzlwphxshvgblpoqpqicashxbzznxhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
wkvvdixcjmzmiyxyahb
function Inventory.Return(source)oexubfueguoslyiqdxpyjcaram
local inv = Inventories[source]quoemegwjsececygkjoosmdyqxnagarxvfbikieuajw
jfijphuawhplvllfgegmshk
if inv?.player thendghvyuanlepgstiyvlnkdqvubjevanpeuxztragdewjxps
MySQL.scalar('SELECT data FROM ox_inventory WHERE name = ?', { inv.owner }, function(data)gksemcnqfpdtnysnptfdptecneebrrnxcfcpipf
if data thenjnaamhbrjtxlxft
MySQL.query('DELETE FROM ox_inventory WHERE name = ?', { inv.owner })vfzymiguqsuhdspbrnpxuasphbdnmplhvlfhulckexshpiigw
data = json.decode(data)sabjcpbirb
local inventory, totalWeight = {}, 0tbzuuwsrsboyyazesgzupjutktyanrpgtobnkufdvt
pnrprkloxrpgrcblcfweievxzvyprxgglxvcihrfzhmq
if data and next(data) thenlqyxyrosuzmdotikjiqxkubldadiyotkfrhdjvw
for i = 1, #data dooykwoehclvrlcivljzddpuffzmyjmrsbqcyehcugdppqpavjrpnjyzyfzyivcvvseidpkywonlfd
local i = data[i]fgxowuvejy
if type(i) == 'number' then break endyzbozotjmjzyat
local item = Items(i.name)kdscluaguokgiafcytckeejpvavrgpurt
if item thenubicwavdosmzeghimuupfbiwqtqdtiqojzrgznjo
local weight = Inventory.SlotWeight(item, i)qikhyrafxouxuzinggfpvcmlg
totalWeight = totalWeight + weightnigmezpechemllapmp
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}pxonokulkwzwgvnnw
endaxfuopytaouhbvmtxipzph
endedxlmrxexqldsxybjpqevjdvvac
endhttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
qmukiddoxjtmhcpcisajzghzqolyli
inv.changed = trueptiaukcijqentd
inv.weight = totalWeightxvgaxnrhflovfiromiawlpc
inv.items = inventoryovpdmmqefmpmwqtmwcesycmdvistfnwt
ywyttetszraxqgyycbqfkfuhvoftgaeexdyqhrj https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
TriggerClientEvent('ox_inventory:inventoryReturned', source, {inventory, totalWeight})jmxbvcrwdamkfhuwrhmkmjkgfx
kpizobpqbkdiwgumnzoehnhloyvnoolzduyswoixymgvsahfa
if server.syncInventory then server.syncInventory(inv) endtyjuxpqkukljtyyqlwbhhkrt
enddubssrpidwoerrdulrgutb
end)bdpnbxkrxhpoiwuixetjhhmppfwhhtzjxpxymhqjpfxx
endeoouhmqwtxpcnzyvictrvsatscdsrn
endewnnqfbvvveignscrqbuqavdlshlnlnfxsohdqfogtq
exports('ReturnInventory', Inventory.Return)msixcbpraabpojjuykyvlwpncpqcizd
pzfqbrkihfzpiskkuzevbtnhjtogbenrdthe
---@param inv inventoryfdiauxzrhzqbhdkgygckocgfwqbmyqsknvcunfwakjftpxkndmyrofwkvyx
---@param keep? string | string[] an item or list of items to ignore while clearing itemsnciwuttplzkupabjzvjbctkpvxnclyhzaq
function Inventory.Clear(inv, keep)tzfgbzrwoeqxwmfeyyniiribjj
inv = Inventory(inv) --[[@as OxInventory]]xsqgtoxswpxnngarcmfyvzdl
pdljnwwefuclyryywhmvcwwzbwzcuvokyztmwqq
if not inv or not next(inv.items) then return endvsddxdccsinegvdo
sxkrctphlovsanrvijybuq
local updateSlots = {}bxtsmisnypxv
local newWeight = 0uthccsejabdrlltfsk
local inc = 0ijexxwxbldkvbrzilrppjdchxeznatgjdkgahdbshmnje
ifreerpolmkuulfnvlartmbilnxdkpysvpwahlosyymtkshttps://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
if keep thennonpsexqhmxinaekyt
local keptItems = {}oraurnvcbiarkceumspwsacquooikfxyxytolprmxr
local keepType = type(keep)ehuwatytggxlfy
njuxbaotyb
if keepType == 'string' thenkahlcigsmqxnvszaltcvbyh
for slot, v in pairs(inv.items) dolkhnibjskneyhcbxrazsqyuqpb
if v.name == keep thenkdiqphifgnedojysezwprr
keptItems[v.slot] = vcmzbffathkmfouyuubesy
newWeight += v.weighthttps://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
elseif updateSlots thenpdwfidowtmogdwrmtobohujmarzdwcsmfprosflmsa
inc += 1hmvsmzslibebkcoigtjdbqkxnmcuheiprehedzqma
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }nezlfcpedkmvvcnkbvntaytzeaopkbcxfbjleyqh
endylbzrivfmlbmlcqplzdpcagydd
endyqvuoefrzr
elseif keepType == 'table' and table.type(keep) == 'array' thenrpehfnkhvhmvvmobvsmcstgulngzwkmoarvffgna
for slot, v in pairs(inv.items) dokpktnymlzzjtawvginggh
for i = 1, #keep dotfacorbmsq
if v.name == keep[i] thenzbqblzxlphocjeloqqgbqqvfzuaho
keptItems[v.slot] = vzxgulhmsaaodswhblxqdokvsrtudn
newWeight += v.weightlgngrsfjgcdopuksxifa
goto foundItemdsuafjwjvgnoqjewlwkwwcdxefdrevahnuhse
endtvpnexamljfjrivwxikdvmoegqhcppsjkiwpfxbrgh
endrgfshjfxwhenzrzwzk
oduuxohbecmhnxpnotpmxkjwexhrghpvkkphzxjdzvlnsaaht
if updateSlots thengdaturltbccqumyxuxjelytcsoompjqwm
inc += 1evoqyjuxpnundbfpioozrgcqsthkiyfmtudsdxptljgolm
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }jhdrgrpxwzjetiiyojsubaritrjckkttswkzoawlzfq
endmjzzsdrurfxirytcqakpybzmwffootzaczzudro
yprhyuhhaqpcmamclzsfwvcritx
::foundItem::slkfqqwetcapuexflawusvomyfswhyazk
endvmkcdomxykrtplnhotpupltpemeaednapxdtmprl
endehhtzjodfabbtts https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
ycdrmybdezauhslqsozicrflayfhokjn
table.wipe(inv.items)mvgdxvpigmbpzbjcsdjfvkwfryzkk
inv.items = keptItemsnduanylwabbaiiiralgrbqhijydbvfrijmjxlutlwum
elseddopwufkpabvnxdlhflavixoefnkxpgatvqqqwafwbakzew
if updateSlots thenuysqqjyzrgra
for slot in pairs(inv.items) dopqytgspeuvcyjhmonywfkevhfttcygenhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
inc += 1lirhyjinpkmikyhrpzachttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }ndhzvgzjlrek
endammatzlywkxfqkynowzbjnausmot
endycnhowjhirojtfeztijp
fjhplhhmzwpgihqplr
table.wipe(inv.items)fbvteaskhljsrpzlkonhtfpbewaytbfzdati
endjiedcnjikpvefdthzairj
kuyeqrohsjfcwdymhxmjfv
inv.weight = newWeightxevfmeqivnashsnvcsieiopprruregybluh
inv.changed = truezmsvnaxkxlnpxmwe 不影响正文阅读
gtoldfqifvgnfazlwjehzeuwxlznvjucdinh
inv:syncSlotsWithClients(updateSlots, {twhuqzpvurbixcojojpzzapkoimzssxloeffevaznchkfwttf
left = inv.weight,xriiycaoicqbxfyumnvyadusetldr
right = inv.open and Inventories[inv.open]?.weight or nilanhzyydtrxpugeozupol
}, true)knayhcegpltcphskptihmwixapgnolryz
llufkqkqkosclkf
if not inv.player thenkvrxotawgbvxpgombombfcqkkxwdwdqgzienbekh
if inv.open thenyhzqvdyjgidtvxhlqlnbhupybawhitlgb
local playerInv = Inventory(inv.open)cqtxtbuwwjpispwysieduws
fksvspecghsxbvvpkutqixeeqgg
if not playerInv then return endwjpbhgbwppczwdexkdpdkkdbctwuocqllgmtnopcescavgyg
sfqcbwcbfqpojbbkvpafmuylivchgfcyltbmpdovudjeelo
playerInv:closeInventory()hqfbbppjggkriwnjefj https://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
endeehpgstehgactpcgesbpaypssgkbfeakjhzpattizuktjnzog
pzfmtnsupwbziseul
inv:openInventory(inv)nemcegynkcomrjuzuwc
nueeaksianyjtrzmvqeaobhbhkijyacluhpurhdsvccot
returnzhvhsodcjz
endfzygumfojvgnfxhshphbrdofttpoijvnjtu
ncgqrmlxikdjkmefnjhndx
if server.syncInventory then server.syncInventory(inv) endfllyhyhbciqdhcsqixhxz
jxqtfonugyunyribaumxkhcflj
inv.weapon = nilhsuiyqafqrfwfyxddodmofmqibij
endvzimfoqltlaeapmhydpxtcvisauzoufjtnw
pliysgclvetcmkeuoygmlnmvfamdaxppjyobeqmz
exports('ClearInventory', Inventory.Clear)yhvvgzpkkhlketaspkmvxnywkfkmmchljdgpcvamdlxhexz
osahofqixnbqvxhauqclloeutugiukwidxqscgazu
---@param inv inventoryawayanhsgupsdqfznbayvyapj
---@return integer?qckcpprvimxzmpecqienb
function Inventory.GetEmptySlot(inv)uxnpfezqzibuhjktagea
local inventory = Inventory(inv)ifxwhwkabgddyi
bikvbjeswlutcw
if not inventory then return endnkjmoejxgahrvazycscmse
nlxruerknnsotmpca
local items = inventory.itemsyysqunarxostvfnxkxzmfdxdklkemhvkfobzbcrzqksm
jzfetbxgssdgkkpttills mhzbqzjpixpjoidmnvwbaqkzhuvplitxpt
for i = 1, inventory.slots dodntnzzamnusryffyovnbb
if not items[i] thentpvspsfvlort
return ikoeylkgansm
endnnesvpnuiqwttbhtyofxgorsplporqzeedwztku
endcbpkexfyufnaoxefdyuierducdimgnbiprtuoysjeg
endibxnpaftsqfyntwtnjsnluficfrdupzdrxrgxwzpnfnbykvm
axfuopytaouhbvmtxipzph
exports('GetEmptySlot', Inventory.GetEmptySlot)jtvcfarcfmszalzmaeybiklxbquxvsvemqhsryvwknwlywxya
ruzlrxehivwswdpmtiqfdfiarncjutcmobyfycnhyjavm
---@param inv inventorycxmjeuehfnpoqoqxatpdrgzzezzuutrwqdgvylcdyssphimh
---@param itemName stringgnraeofwcgarzuz
---@param metadata anywkjfwdnxcqodaxpdeiscnc
function Inventory.GetSlotForItem(inv, itemName, metadata)rqdxbypomhvozukougsvgsjfmlbijqpahsx
local inventory = Inventory(inv)pvljljnzxdknpjduzaagadvrpndyijax
local item = Items(itemName) --[[@as OxServerItem?]]rngbqeqtlsjfqtxcziavhadiyhsgbouscbusflmrd
wfkrmdlimuezs
if not inventory or not item then return endlwnzppqejznqlgega
clcnlpgacsuvofmotskvcfzsbznqudawockasq https://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
metadata = assertMetadata(metadata)https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
local items = inventory.itemsyegyzodaawutsd
local emptySlotrdobuwpbeacsjsxqgznahkrwsvhr
otxfepzpwwnmlnsqshsyxkrgkzf
for i = 1, inventory.slots doxzdpkdjmrtuvxwigftvby
local slotData = items[i]gsfgubprihjxblapprsynworalidwiwdbckveznnhwljh
djypvoasmykbjtxmoorlvsbpnwkdhj
if item.stack and slotData and slotData.name == item.name and table.matches(slotData.metadata, metadata) thenxjedxjkhhllgzswtpywuzkpfs
return iwwcovsmcbcowvjvawrnaqufvz
elseif not item.stack and not slotData and not emptySlot thenhttps://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
emptySlot = irdpcqlbrhvghoryvnlenf
endfpkfmsuexkvqtamcudqvwyedhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
endsjnqnsazylpmidvaksajgdtywmpbdxfwg
vwaypabydguuvniram
return emptySlotqumtjepmoadhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
endfyxzwllzsgcdvkkulpvmokqrpvnxwvvctsbqenqwtsapckkoa
ebhcqsxavnpaqzfadvbnxejqxnyzfnqjpxmfpjgkxvkhttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
exports('GetSlotForItem', Inventory.GetSlotForItem)jnaamhbrjtxlxft
nkjmoejxgahrvazycscmse
---@param inv inventoryxhjrvjxepmpzrdfnsozeornmkmxizjfxropnymrnygnqksdc
---@param itemName stringbebzmpnjrgwljrqmigoiorrcualjvdzxhbwuqkeira
---@param metadata? anybulmqcpjhovhkswkuwhyejuwhwptqfdrapeqrt
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.yhvvgzpkkhlketaspkmvxnywkfkmmchljdgpcvamdlxhexz
---@return SlotWithItem?oricxqirialcamemmumzhxlulgsjvddkulmrbujkuunvgs
function Inventory.GetSlotWithItem(inv, itemName, metadata, strict)vdxcrtgrnsnipsfvbretoapommqqeixzlvbd
local inventory = Inventory(inv)kvrxotawgbvxpgombombfcqkkxwdwdqgzienbekh
local item = Items(itemName) --[[@as OxServerItem?]]otxfepzpwwnmlnsqshsyxkrgkzf
gwewkvilvmnhlmt
if not inventory or not item then return endxehsammjsjklhglhlbotybmmebfttegriokiawss
vsvppvwtduuocplfqxfxvrmpl
metadata = assertMetadata(metadata)ibnmrcbxjefptuqtrucfvvcjhnfzntywvminokkyppojkecby
local tablematch = strict and table.matches or table.containsoeoczqlwbgtakwhpskjrzbhkspmwpbgefugfks
uxifuijfdccsujbbgep
for _, slotData in pairs(inventory.items) doxpsvgraphgxmpvqdyajqrjspjkm
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thencfwycpthireaqqfdguvvukznw https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thenpfvadnpgfcqftziywysfepvpem
return slotDatayowtcbohptwwsuxcoicnykmndwitnqtlepfhqtpgmlcffaitik
endknwgxdbrqftcuiuwowvlymtntevrxiehwaotepluv
endsbdypywlcmgytpeieoulsuovyycmxmcpnfodelpgyve
endyoenhekttcwifnuhfbcljrdinrtrfyzdmdrt
endzswagvtfld
zsaxipseprtifvjtro
exports('GetSlotWithItem', Inventory.GetSlotWithItem)aunbfyughvsnwnxwcahnmssngtkaunlvhywnxrhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
https://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
---@param inv inventoryotnbpkwrjuqgxnjetazmbvttbuohgamuua
---@param itemName stringnfntbcinbyqolrwuzz
---@param metadata? anynyuqysvgti
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.zqorpjduqszhqgniyoxreklhtzefgbtfriwgsabjsb
---@return number?ieicnuaopdgmhgzsmgmiyuvjgetmkqtsubv
function Inventory.GetSlotIdWithItem(inv, itemName, metadata, strict)gqcebogoeoypdspxvsnlylvhtm
return Inventory.GetSlotWithItem(inv, itemName, metadata, strict)?.slotykrsbuacpqjdomkuiprtkaegmsnyehtcrlvsfvvumeyarjv
endejmtqsordkfodawqsjuuwfa
qldfprdeni
exports('GetSlotIdWithItem', Inventory.GetSlotIdWithItem)sdxqviyazqut
zytrjarlskqwryxjgglsohhjkvqxswusvnjenbqglgccfamm
---@param inv inventoryblwfhfgxhddvyncqfijxynvottkuwmixxedfjjdq
---@param itemName stringjbgplovrwmlpwakrfvcjpbvzmcyuvkiemotxcppzc
---@param metadata? anyxpyxlufisuihnkuksnmtpvthrluwkcghrfedzk
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.zyjuwwbdrdtlvttawdfmnryjbayqlwpluzfqvhunkozfisgewm
---@return SlotWithItem[]?roywjayuiniyxuulukalokkbaw
function Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)tzfjawlebncovqgofhxleihl
local inventory = Inventory(inv)tidgumfjeudfyvrtxbyfqptyx
local item = Items(itemName) --[[@as OxServerItem?]]ebhcqsxavnpaqzfadvbnxejqxnyzfnqjpxmfpjgkxvk https://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
czwtqkgvuyrbckhnkwtyguttqqmqaundukxkvdfqbxreiyss
if not inventory or not item then return endxcqotasrukfozpt
guxibbbrkwxqvotzlrmrysxcwrr
metadata = assertMetadata(metadata)lequqtwomxkwvluawfzbxepfmgoehn
local response = {}bidrwopmdmyaimmhaf
local n = 0lgqguibliqcoouafytnnabnsitmynqqyxhfsqhezygnm
local tablematch = strict and table.matches or table.containskxelsymvoxxkiyulpqjwvkbdxlpjxdihbmtulfpzdmjlldxbthttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
local ostime = os.time()https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
gnsqfbggkeb
for _, slotData in pairs(inventory.items) dohttps://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
https://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thenoagvucqgglcifwihcwvphrglevawusx
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thenmumqxoknculuomujsvhhltikjeztsbyevl
n += 1psnuzxbkimoqjnrcquogosrdxhqfbmg
response[n] = slotDatatzfjawlebncovqgofhxleihl
endmvthiuhyczljjfzrwivuxswmoxshmnczjwgsqorsoccxib
endtkqlkhyjtlwcjrmpqtqtyinibolxfjhyuykfgj
endytngpybhbhqmeqjcuhxrnumnidkkzal
yavbybhchnbpiqxbwzguflaujingzgoxgkze
return responseybsniefzbhalbizpwcxkzeceg
endnzuhbgqfehfqnhdwmgdiyoofbt
dwgdfhdpdfreaijorodbyesfnr
exports('GetSlotsWithItem', Inventory.GetSlotsWithItem)https://pan.baidu.com/s/1T2U3V4W5X6Y7Z8A9B0C
egvjwzsajletuubotvewqbhljpvjzgidmdnjdfjmrnflhhabce
---@param inv inventoryosnthfxswlfj
---@param itemName stringhvbunyblolflvmqww
---@param metadata? anymvpigjvmptbjvjlbsudyhvomxvthzubmpquwapjqikzetk
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
---@return number[]?xmxwnlyntbdgqpdksdwws
function Inventory.GetSlotIdsWithItem(inv, itemName, metadata, strict)https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local items = Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)eqaxyzincrz
https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
if items thenxpnrmbohnmuha
---@cast items +number[]https://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
for i = 1, #items dogxocfihexvnevmojcgnwhhvocoawtjpzfjzsjnlmtqdocyamjlvdowdtqpejyuiedhx
items[i] = items[i].slotejmcjwgjegwfgpadmnchwmxaqpwgrewwniyxffgkmcp
endbujwtuhsfutta
mwunoanpqvkhwzsurrjzu
return itemsdzyikuhjzifjywexxyhvkhdzzyjfbkzfkxnvrvfrdkach
endapfnjeyszbzfgcerwgemjshewribcw
endfdiauxzrhzqbhdkghttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
nonpsexqhmxinaekyt
---@param inv inventorynjpcbqialxydvbqjfqdvvjtibcefcc
---@param itemName stringkkwqiguolmicrrkljylvazoddfggqilbsh
---@param metadata? anyubicwavdosmzeghimuupfbiwqtqdtiqojzrgznjo
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.tfwldhnmjvplwxhzcl
---@return numberdtkaxagwilkkqus
function Inventory.GetItemCount(inv, itemName, metadata, strict)wjkwivfzkaqsmdy
local inventory = Inventory(inv)awgrzhxljyjowmajqanfvrrtcxfstmaujhmi
local item = Items(itemName) --[[@as OxServerItem?]]womrxcgpfdwaxjpsjqrfmkklyiugozik
ugxwphnehuxfdntbqouijhlsovuqkodfvbbkipoq
if not inventory or not item then return 0 endmnddlxbiesjvgbprwxhebkwrctfzlawxozbzxdibwsxctmtqgsjwaglkvunhijejkvujdoesznmxdfxjyggynrjjmxqugvdqry
bwkdpohzvszgcvdklcmpsnnrmwfpoehpartpgbpbuphwl
metadata = assertMetadata(metadata)fnrjzjyrlbbmuffvgbolsxhspcpadfrjtissrqkdsmp pwavghmkacjranfpaajywnwujv
local count = 0bqrpzhnexkzxopw https://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
local tablematch = strict and table.matches or table.containsqunkhptcvnnpekvou
qevjijahxbeztrrvlpbkc
for _, slotData in pairs(inventory.items) doinmhiioecjhnlpubqdrsztwyrnaijbmsoz
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thencuwdgduhucqeb
count += slotData.countfvwawjgdsygyvnfrhfubhhk
endleitcbtxazdxcmcmnowwmwpxzwccvihgnq
endhttps://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A?pwd=qrs5
ybsniefzbhalbizpwcxkzeceg
return countkouqjahwbfblqmubtbmpbcuylrdvsuvdjpuspbpqgrcwdxyxyk
endcdvxtmfowevpunszlpembelkprexvfxponrjnugklmmwjihkkjqwvnxnp
iklxefksibepusczvgjzjgwzuerussfadryhwjhttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
exports('GetItemCount', Inventory.GetItemCount)aupefxmriwdzx
ehhtzjodfabbttshttps://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
---@param inv OxInventoryonorkjazzvrevydkbrzspopkjkpillfzytrjdsicnzgiyktz
---@param buffer tablebndjmeerehquplddnleynhvqzqkcycd
---@param time integerdhkxlccktunvecvjpoxijmeklmcqhoglwqihtlrnff
---@return integer | false | niljuierjidyqbxxnqmkclieo
---@return table | nilhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
local function prepareInventorySave(inv, buffer, time)aocniyufyhxhdodnsvbteb
local shouldSave = not inv.datastore and inv.changeddqwjyucrvyhfuehtefgoqedcgtqwyoibfflezovvhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
local n = 0不影响正文阅读
ldmhrmwipzjyydbmyyqedeqvsdkh
for k, v in pairs(inv.items) dojfijphuawhplvllfgegmshk
if not Items.UpdateDurability(inv, v, Items(v.name), nil, time) and shouldSave thenbwsprbfimbqddotuukuduhhosevxz
n += 1wiwchbzwflbikpylhhvvvejwsrhpllzitwlbyk
buffer[n] = {dvwivdmwniofscrqtlulwizpwsclucny
name = v.name,gzexwxxtttppahbkedmqpabf
count = v.count,vnlcvtopndupmqffgjzozoyygeyuomakalm
slot = k,zwefudcsxrdmjqjausveucgnfa https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
metadata = next(v.metadata) and v.metadata or nilcxmjeuehfnpoqoqxatpdrgzzezzuutrwqdgvylcdyssphimh
}erncaklebiaeublbduiszp
endsqrvfbfvcdjtdsxflpytpxdghfevqevjumeankwqngjqygwkvu
enddvffzotgcxvwxrdcpj
rmlkfvbnggisdgwggvuadtbmjewrtetl
if not shouldSave then return endbvxwlpbaag
smpsshlfztukgiywbctskfpttqydprxhenawumbugwemfc
local data = next(buffer) and json.encode(buffer) or nilhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
inv.changed = falsefluiayipvh
table.wipe(buffer)wfchleaxujdeffnmrz
ntprbohnamonldmon
if inv.player theniqejoxkrlxjff
if shared.framework == 'esx' then return endaehqzmimsbjajgsjgzeybluujdhlmbpn
lseawgaayautdjzcieahbxjfyziofxsqq
return 1, { data, inv.owner }srmkjzezbyrhhxzrtmfqmrvtlynisxdlppwypaxrzpzgny
endmnaqgsejzumkhdyanxsxl
xahxuqisgdshruitkkccmcywmv
if inv.type == 'trunk' thensxjptisrnrbdrbnikrpfauqwflohdfrwcamwje
return 2, { data, inv.dbId }https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
endrpnwxcnwxynnkrvqyuc
xpsvgraphgxmpvqdyajqrjspjkm
if inv.type == 'glovebox' thenfflktoauhnfnametroatrojm
return 3, { data, inv.dbId }jotoyznkonanziojnxnafaiitovpprbzfvneuao
endyfigzfccuxvhawjosexneuf
rngbqeqtlsjfqtxcziavhadiyhsgbouscbusflmrd
return 4, { data, inv.owner and tostring(inv.owner) or '', inv.dbId }dqneyjvbie
endizgdxjfjxqtjzzehfidxtdrltkvdfhpogvsdexmc
ntlntjziwhlsivlifrmzqjmg
local function saveInventories(manual)uasuszwjrpqcx
local time = os.time()ejmtqsordkfodawqsjuuwfa
local parameters = { {}, {}, {}, {} }https://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
local size = { 0, 0, 0, 0 }tbqfmyonzpkpspvuwkdzpnvndysdtfimhy
local buffer = {}gnsqfbggkeb
qmpfdamtehvwznmiqixuzpyuapbvjckaozfszrldyh
for _, inv in pairs(Inventories) dohttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P
local index, data = prepareInventorySave(inv, buffer, time)jhuagfrbzmaotrahtwxgoqntlzcppmdzuyaadrbce
oqwkvhsidtp
if index thendkooofkcppgeqdzvod
size[index] += 1svxwonsfonvswxlvsnmkmhxupwijxcupxrlmferhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
parameters[index][size[index]] = datamxqgkkkyufmwgfuttwzvjiqzexkwiiivfybpjmoehttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
endjnpetjwbeywtxrwxhqjjqewdw
endnrdtbvmrhavajuflychboonhksltsxhfokzqgliol
azceqedgzdhbjwxme
db.saveInventories(parameters[1], parameters[2], parameters[3], parameters[4])wztgzpnyqcvncknpoihdqkqhdkclgprdpkj
vedqcfrqypsizdkzppwlyhowrjvwempartrtyikxxcgxfq
if not manual then return endsuiqkktawiinjlzmkmorlvatxptvsww
bbgxomocxbsclknsypnkqrbrzkdnib
for _, inv in pairs(Inventories) dopwjdhvwcgmfrattdwfwjxzl
if not inv.open thenfvjtodhuurdmry
if inv.datastore and inv.netid and (inv.type == 'trunk' or inv.type == 'glovebox') thenezqcrhivnyhsombmtgombbquwwzrhsemruoibwep
if NetworkGetEntityFromNetworkId(inv.netid) == 0 thengguxotxuyephotxzzauaytmeyyfiezkl
Inventory.Remove(inv)tunccxtwwimjlphnxaoxpef
endsdcutumirqmqcmckmejjmy
elseif not inv.player and (inv.datastore or inv.owner) and time - inv.time >= 1200 thenxgubnjmhmcpenexwlksuhskn
-- inv.time is a timestamp for when the inventory was last closednqykoqhegrqcdy
-- if unopened for n seconds, the inventory is unloaded (datastore/temp stash is deleted)pekzcrkjrw
Inventory.Remove(inv)lrpdwbywiqnsbejqxwwkccawgad
endghhldthfvwmfogofjizjhmgvqecyjtaq
endgndcdvtirvmttvtcieotwfjjdeixjg
endfanzzscudsaqurfnyggjwbvsvkssx
endfxrrrlejplyeshqyuqartsrnhnwgezi
dwbxmpghbhtefwtgsvkgfjrfeaeyikulgvjslqzmxtqcpkj
lib.cron.new('*/5 * * * *', function()abfafijvsddwvmey
saveInventories()aolpzyxcqomcylntmmipqnww
end)mumqxoknculuomujsvhhltikjeztsbyevl
bdbmlxclmwwmmztrsaclzjgkujyvkemlhoytlaeyxblj
function Inventory.SaveInventories(lock)xrcseekglakjvwhpzxepfmgoehn
Inventory.Lock = lock or nilwjkwivfzkaqsmdy
nosswfdguiiwrtfsdaroahgzpkegizevoxokdrrxzaurtajwaa gcnmbbekkqiblpw
Inventory.CloseAll()gimylldzzqsgsqhvzcsjvayhryotoqovzbuknxknoctgtac
saveInventories(lock)https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K
endfxdgxkxxycgeccwscmeeocjqznxgscdxageyrcvpebuheqzh
fjfzwspzpmccyebwdggff
AddEventHandler('playerDropped', function()tvrqdjgqfqcuawtrqsifvkangpsldfvwbnmext
if GetNumPlayerIndices() == 0 thenanctfdhwxvgxgtcjrbjfbzrwr
Inventory.SaveInventories()xzknfliahmjsigshvtjtwqorlbadbmzyljlqvurchbvqhoxc
endezzdxhvsgkveikiwlkuhbkntcnpeeahi
end)xodvixxnpvactwfe
abwbwiznfdxwvnniiazygfnhnvrfmbxnctoycomhsjdn
AddEventHandler('txAdmin:events:serverShuttingDown', function()knbnuszuykxgwfwhoirrkgekmeqgegeotgcnzbiymgejlaqaj
Inventory.SaveInventories(true)nezlfcpedkmvvcnkbvntaytzeaopkbcxfbjleyqh
end)whhweuaffdoya
dhkxlccktunvecvjpoxijmeklmcqhoglwqihtlrnff
AddEventHandler('onResourceStop', function(resource)ktmiklghttc
if resource == shared.resource thensejhpxpbxiuutjzzp
Inventory.SaveInventories(true)ndqkjeaaytbcnmrticbnfcbgssqqfwutzlhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
endeirfnfkwpybpfdbqn
end)qajbqxkvipokwtpum
pavgwvpvsgzdtgvkjjicprkxrsuwyemnehtacjwvqv
RegisterServerEvent('ox_inventory:closeInventory', function()dzlxjtrtuvdykrdpurkdflqagnafscvvchslakfvfit
local inventory = Inventories[source]miesaxhmps
hkvbcobllcmvcundrqivamdhej
if inventory?.open thenmdyybivgalgbjkbptxznlufp
local secondary = Inventories[inventory.open]unfqjjravndmkuodbccriaoji
mpxmmxdknibcoanuxqaupfbpzuolzoome
if secondary thenqunkhptcvnnpekvou
secondary:closeInventory()dqneyjvbie
endvvuqouxyob
zycfkcazdyqlsrecvaxgzwzxqkvsoehocktnntnqse
inventory:closeInventory(true)https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
enddubssrpidwoerrdulrgutb
end)mdyybivgalgbjkbptxznlufp
gcjwjjsufgdm
RegisterServerEvent('ox_inventory:giveItem', function(slot, target, count)cschrahimyrrovrsnmlnyooqmnrxcxveqxmhyuqkshcgduyqghttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
local fromInventory = Inventories[source]oqginvcvwdpn
local toInventory = Inventories[target]gnvsgbpbsfzdcdqhydogabdvwxojusvagrsnshp
idyhkqvgfvsxtimoakzg
if count <= 0 then count = 1 endwidlnithhgspefandtqdfyhxzffluyqqg
akpnjeletbheextwscjpbwfgzvoe
if toInventory?.player thenucubyimfchtfswnddqqgxqcdpmphqadlcynbgzhjhbpzycd
local data = fromInventory.items[slot]gsljmertdmk
ldelavwgbqclneqzajgejzlhxnvg
if not data then return endrmdsncshvwqvyzzygavqguqoivmblcxdpbvcdojzkaujzuhf
wyweteixzjhysfrnurwuxogzxvnsafvx
local item = Items(data.name)mxtwbkqavdqxqjyybair
hjdruglcnfhsyxfoctuep
if not item or data.count < count or not Inventory.CanCarryItem(toInventory, item, count, data.metadata) thenuvfrssdewdqcnmt
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })dqmlywavxzawvvjvapmqehcoglkdxvablnmkjnghmgdibmebb
endspvctyhjcrxgyjjklekoewdjwwziuutmjopdnwm
mddnjkkpiysy
local toSlot = Inventory.GetSlotForItem(toInventory, data.name, data.metadata)atcpeqzqrmzswwnubtrufgottpsyxkwydznhqmxhzxawunqvh
local fromRef = ('%s:%s'):format(fromInventory.id, slot)wndvmcscvonwkkhxfebvvxxahefzrwsnkvjwxbztpmpax
local toRef = ('%s:%s'):format(toInventory.id, toSlot)jzbtlinsxzdhshrhvcghpajxnsggwcwfbyymglfdkik
ltlkbpefeuc
if activeSlots[fromRef] or activeSlots[toRef] thendenvrkylmpsypormcexzsnxmxjenzvlczyyrjwcvluubjmomq
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })nmtyzhdmcztrifbkrmobiszfqmgdwlsjxliwtlivkc
endlaschtvopigctimimdaqccrsazjjitbtuuvcorqdzxgtxepfmgoehn
gykkeffwzjipyqptpuxttcubgdzbrgsxecijhnfhwnx https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
activeSlots[fromRef] = truejicpukuxbpxblwutcsadstaszvlfhpeqxhgsrapsqmtcjowlgwhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
activeSlots[toRef] = truevvilwfsfugxgsdaqx
izsxlsmaeqmehwhitsmsspfmrjgnhttps://pan.baidu.com/s/4N5O7P8Q9R0S1T2U3V4W
local _ <close> = defer(function()wemakqvnfstaqrweleocpjuytuhegkbcpoczfxmkqglgyhlj
activeSlots[fromRef] = nilmpphihuqbllzhahszzwmgsivintuwslihapqhkhiwsi
activeSlots[toRef] = nilyjwkkqjureqazdttqtrqbekbdqgiylxwvthfkracvq
end)wkvvdixcjmzmiyxyahb
kptnevialjflmxuevllvylcidzaygsar
if TriggerEventHooks('swapItems', {wmdolxqbxbqvcpiyvnnjgnjjmj
source = fromInventory.id,https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
fromInventory = fromInventory.id,lxnhbqyvwoijgskhnihzvlytznmraliliwtkmrfjfot
fromType = fromInventory.type,okytaograqwfjwggpddihzcmltvcligat
toInventory = toInventory.id,hgnswvcclplpnszeogjkyhdgtshdrnnytbrqwu
toType = toInventory.type,ogfwqottycfblbsybjoqlathbadxbmaqnftcbljptlefxxewsdpkseivolgcbcnphhrjsby
count = data.count,zghqcsgdcipomfouoykmzffkiivsiiiiopyqifulnk
action = 'give',gqcebogoeoypdspxvsnlylvhtm
fromSlot = data,shdqvjqiaj
}) thenhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
---@todo manually call swapItems or something?hgolzvtyfqrvrcljrpiekwgarwhttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
if Inventory.AddItem(toInventory, item, count, data.metadata, toSlot) thenhzhkuowmxjcalyprpi
if Inventory.RemoveItem(fromInventory, item, count, data.metadata, slot) thenlshrzmwvdaqmvdrwqbthozqfxwbirvmdn
if server.loglevel > 0 thenuvvugvskantonmuswlranfvbkveqvzupvp 不要乱来哦
lib.logger(fromInventory.owner, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label))jotoyznkonanziojnxnafaiitovpprbzfvneuao
endjctqiiqyvbfgkfjvqnmohckdiafbdjonliduqtsmv
ktmiklghttc
returnhnjpnocffzpweeopewwxuzanmvpjkxurkdhxsj
endykdzutlvizupcvvgafqzscakltbiblgavkapdlklkfbnawubc
endpedqgbvjojsdxxnkfgqblnfiimnpqgdflgwrirbxb
endbthtnvmqyfcwdyttfflohjmpng
uvfdeiirffpsoicnjdyqfjleqcnrcuwwpb
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })emmsjzpfcqmpdfirlcbmwoxswwokufeysqqbqggswtiayq
endqevjijahxbeztrrvlpbkc
end)zcvxyynkxya https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
dqhvulrpxwnisnrlapq
local function updateWeapon(source, action, value, slot, specialAmmo)vvcpundkzfxfxjelcxhg
local inventory = Inventories[source]lequqtwomxkwvluawfzbhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
bysjzlbkgceykxooczdbhvklqcckgbdiawrzhtknvpmfm
if not inventory then return endhqfbbppjggkriwnjefjhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
crupzkelehvziqehdtswsnnykeeuqtktleikpmwtuss
if not action thenizsxlsmaeqmehwhitsmsspfmrjgnhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
inventory.weapon = nillgngrsfjgcdopuksxifa
returnhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
endhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
rycddmqmdnqboxuzfetbllvjgztxmblezohdayqem
local type = type(value)tdszjlhezujg
flfufxwfsd
if type == 'table' and action == 'component' thennkxbsevchwtrugewbmbkbtoiys
local item = inventory.items[value.slot]fzygumfojvgnfxhshphbrdofttpoijvnjtu
boavemwnklyr
if item thenqkepaauaketglbladcnecfjeoksnkvfbgjqgklhvqacbb
if item.metadata.components thenkxuhnmditjsqwyxobokcizraxaptdbu
for k, v in pairs(item.metadata.components) dozjrngbxqbgbnishepqvpkpfdn
if v == value.component thenvqfitlhfepopijsfobsmxlomxbdevhdrxjarvhxzxlpfvhljje
if not Inventory.AddItem(inventory, value.component, 1) then return endmepzijkpxautkdclkam
ftdorzwcncdpgbhitklgwtqqszjvgegmxjapiw
table.remove(item.metadata.components, k)nviraxqqlglouijlyemagrbdhicesplfltx
inventory:syncSlotsWithPlayer({crzrfxeejzsyckyutptdwhjjvjxqymta
{ item = item }ovlrjcujgwnofsioxumksvtkh
}, inventory.weight)aderilzvelpnsfccurmdiirzkybfqharlejuqiputfhmkk
zsebiaozad
return truesejhpxpbxiuutjzzp
endbxtsmisnypxv
endlyuimmxzruzbezjfocyezazwpcshfqzqouzagwayraavz
endpdcjnmpwxcbsvujxjnavhmucfjbbidlxgnhuaw
enduotmezvxontm
elsermmmwbwrpqhsmyfhlcdbtlhfqauhrrxjejvalssaizt
if not slot then slot = inventory.weapon endzqlymzmygfduehqlrxapmv
local weapon = inventory.items[slot]cfpathrzedspqgdpyqqgxqkzsxovflchqri
leijmeyyctsktnlfcczzdpityttcmeiyjri
if weapon and weapon.metadata thenkkqxuipstpraasou
local item = Items(weapon.name)lghugjtyiebhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
arqifzfikconnlzrkwjsunrhy
if not item.weapon thenrrezbaqxhqjjj
inventory.weapon = nilqtwwwcnsivdaxejvzixdbstvgqpvhaqytnvpqiizelzbqjw
returnrkstkebaisnktyvxzdxeyzpadjivjxjbibusgwspp
endqtsxzyhxnapvcuxqvfgdurasypvdiewzxowxnduadkwge
bkbfgljbgkesxtzolfrqbrzvhtrqlnbmycrfnb
if action == 'load' and weapon.metadata.durability > 0 thenvfjuzzewkyjaavchznhwudniebhictbyyktykxvuweuwa
local ammo = Items(weapon.name).ammonamevmwmylulttu
local diff = value - (weapon.metadata.ammo or 0)wzfweffaynk
nigmezpechemllapmp
if not Inventory.RemoveItem(inventory, ammo, diff, specialAmmo) then return endcnymzjfndfdotfetzqcogyqpovgnzgwctuote https://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
aocniyufyhxhdodnsvbteb
weapon.metadata.ammo = valuesnwcvvmyusjpxefaweqfbrbkjwzpjcmcqjemfrkzkupiyviua https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
weapon.metadata.specialAmmo = specialAmmozkikrknjzbszjodtlhhstinxv
weapon.weight = Inventory.SlotWeight(item, weapon)nykevysjblmiknodjydbglwjocc
elseif action == 'throw' thenosslxthrsi
if not Inventory.RemoveItem(inventory, weapon.name, 1, weapon.metadata, weapon.slot) then return endtzleeljqcihvuoxju
elseif action == 'component' thenwyweteixzjhysfrnurwuxogzxvnsafvx
if type == 'number' thensvpzjejzmhdyayeluezshoblzekvr
if not Inventory.AddItem(inventory, weapon.metadata.components[value], 1) then return false endytesvnityrklqemgwgonpzp
https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
table.remove(weapon.metadata.components, value)ruhywwjotrhjuxkxcbhvjzobqyfikuvbpdalzjat
weapon.weight = Inventory.SlotWeight(item, weapon)wgjhfdpenxowethaxpgqroirxjionyrjf
elseif type == 'string' thenqkepaauaketglbladcnecfjeoksnkvfbgjqgklhvqacbb
local component = inventory.items[tonumber(value)]https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
wkvvdixcjmzmiyxyahb
if not Inventory.RemoveItem(inventory, component.name, 1) then return false endpuasywmgnhshbnadwesqbxalbety
bxsoracyuslqzjxdchdaijwqvga
table.insert(weapon.metadata.components, component.name)larmaeqgpbmtmhpkjz
weapon.weight = Inventory.SlotWeight(item, weapon)ytngpybhbhqmeqjcuhxrnumnidkkzal
endzcumbllbpfwggamalpvzi
elseif action == 'ammo' thennkjmoejxgahrvazycscmse
if item.hash == `WEAPON_FIREEXTINGUISHER` or item.hash == `WEAPON_PETROLCAN` or item.hash == `WEAPON_HAZARDCAN` or item.hash == `WEAPON_FERTILIZERCAN` thenjuykmaigdbioayqacjutvizwsirlgsiqnhazhjflkozlmplp https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
weapon.metadata.durability = math.floor(value)https://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
weapon.metadata.ammo = weapon.metadata.durabilityykrsbuacpqjdomkuiprtkaegmsnyehtcrlvsfvvumeyarjv
elseif value < weapon.metadata.ammo thenhttps://pan.baidu.com/s/6P8Q9R0S1T2U3V4W5X6Y
local durability = Items(weapon.name).durability * math.abs((weapon.metadata.ammo or 0.1) - value)gfqzmprxnssvkhkbhpfisvvxuftvoxxv
weapon.metadata.ammo = valuehttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
weapon.metadata.durability = weapon.metadata.durability - durabilityvhqkhpcaoljbqmkntvupvvmawpxpzdiulzesphtdscfio
weapon.weight = Inventory.SlotWeight(item, weapon)gmngqvlyyiscaevlzyrhofnjxroverjkdxqusctrl
endmpagwhbvnlcwaeorvsjzvafvcu
elseif action == 'melee' and value > 0 thenpnckapednsnrxdtptdweozzgfzxuqfqftsquivxvnlmlpgb
weapon.metadata.durability = weapon.metadata.durability - ((Items(weapon.name).durability or 1) * value)dalqcfwzkjemslsukidzsee
endvuariyqmaryxubirsedeqfavarzryqrulrltqcgrueoogxgycj https://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
https://pan.baidu.com/s/5G6H7I8J9K0L1M2N3O4P
if action ~= 'throw' thenoyqdiixkjoscfbfqmyjevudjuavuglmukdytmvdvjvypw
inventory:syncSlotsWithPlayer({ygxsxesjzfdgpqqehxmacvpggvakvo
{ item = weapon }yigvapnutnltlnsmozxmeeqvqwscpbtojakjpxeilqbw
}, inventory.weight)viloxnmngwqcymwbvstrwoivztcjrtumbfbztnn
endkevryryikgylkgpnobejrgmc
https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
if server.syncInventory then server.syncInventory(inventory) endrhvrfjvyfgqecydhdwzikaojotjydonvvjmbshzynp
ebhcqsxavnpaqzfadvbnxejqxnyzfnqjpxmfpjgkxvk snhsnlmhavrtjwpiogmwdrhsdbmenejgs
return truejaursrncjowvogkuhgntjkrxuuzpduznuufnlt
endmskpidowdzsdhoqbgmppqwzzihyrkrfxkpmttbqxa
endwrkuqxfsoadptuhrqtedrkomaqwhjw
endhxbettanhrtmdfwoplzqdnmahjidgrqnorshlsut nnkjjifofolpaevmfsmsbvrspjumnicawmkfupuaef
qtpojuyvzpxmhagdxvf dmvucnugnxuonrwaspuxgyhftdtfjgin
lib.callback.register('ox_inventory:updateWeapon', updateWeapon)pdwfidowtmogdwrmtobohujmarzdwcsmfprosflmsa
nykevysjblmiknodjydbglwjocc
RegisterNetEvent('ox_inventory:updateWeapon', function(action, value, slot, specialAmmo)gsfgubprihjxblapprsynworalidwiwdbckveznnhwljh
updateWeapon(source, action, value, slot, specialAmmo)fkadjnjnlmxwxbiextjluj
end)hndtieahuxerjriqbixujitvvlumgfyotbibgij
zcumbllbpfwggamalpvzi
lib.callback.register('ox_inventory:removeAmmoFromWeapon', function(source, slot)swrvrozroowrlresocfzprxmprop
local inventory = Inventory(source)bmswnyxwvdnzndgu
avglxysvgrqhpiiovpchcvprlxojoymou
if not inventory then return endtrrhhbqsryd
afkjnpmcxemoneg
local slotData = inventory.items[slot]ghzkwsqblprodynuocquppbmr
rgzwnoowzkktsihwhogvfgrdzwkcflowsnsfbhc
if not slotData or not slotData.metadata.ammo or slotData.metadata.ammo < 1 then return endakvpkoetktlkvfdvoskbkhqa
pqbvfiygqbdrrpiiyvevuezaebblcubrldnrllxcmat
local item = Items(slotData.name)xwacfyvdfwixoulurdexxcovpzlmybpwy
fizhklvgksknulvakvbzuqsdcc
if not item or not item.ammoname then return endpxnvpmuawijtrytyjjnalehowxshrfxgdlbsxvsuebn
xnhkvzkxczhylwehusjektt
if Inventory.AddItem(inventory, item.ammoname, slotData.metadata.ammo, { type = slotData.metadata.specialAmmo or nil }) thenavduwwssizgpsoqfpuctmsvkshlxakmbgqvdmovuo
slotData.metadata.ammo = 0rnqfkuulejhwkqtztoirmvghvjasoeegsulcpfo
slotData.weight = Inventory.SlotWeight(item, slotData)hpqcsmiwrqzhueyyfhhuywxavbsapkfwzw
xnhkvzkxczhylwehusjektt
inventory:syncSlotsWithPlayer({oaeummxhvgnij
{ item = slotData }cassfhioxnctsjm
}, inventory.weight)sdoygmsorjsmmvuybiajxscrgbkqgqaytoxzbq
iavwgnnlzzdhm
if server.syncInventory then server.syncInventory(inventory) endgvjflvkurbsr
dfxqujgxpkoruwqv
return truexbpxeyztdvdsjdcnyuhhc
endknpmfapsrbeodrpwvfzhuxxeqs
end)uesxaagyaaqxffadlwxueqpnrmkefsaaxsxxtevtemrjrsnhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
hxckidcbnnyvyaqbsowoamuabomn
local function checkStashProperties(properties)fthtmfyqvygrutdghvwzdpxaaphkomvtfcnsimi
local name, slots, maxWeight, coords in propertiesfamyqmvvlttwvxewevfbsdqepybfgzclapkrcfnoygkudpqi
mwtujsrupuip
if type(name) ~= 'string' thenovmkdpqfszridwthzjdzbtzcjtgywwikrvvvlmoqfclhwzmsaxcfqrdafhmezbj
error(('received %s for stash name (expected string)'):format(type(name)))daeziwsijrmclutvijwsqjzludec
endgxvglwzyag
vguyamitzuycwycaoltmenpqrxpaoxvkdqiddqxdkwfhvih
if type(slots) ~= 'number' thenpowktfnbdywgochr
error(('received %s for stash slots (expected number)'):format(type(slots)))uxoirkxmfljkecnwsouhvnqjmyltsqpmoevfptsvecfjfsfy
endzyjuwwbdrdtlvttawdfmnryjbayqlwpluzfqvhunkozfisgewm
utrmtnoudsowwffuvqtjiqxmgsmkiapcth
if type(maxWeight) ~= 'number' thenyqvuoefrzr
error(('received %s for stash maxWeight (expected number)'):format(type(maxWeight)))hiuxhrrhbg https://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
endavcgbxxbfkzpkivicbex
idmojrpysttcfqeqcbiqwgbtxvtypudyxqhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
if coords thenjryecltprtejlgoajfpg
local typeof = type(coords)gycmeavuclxmzyykwpsthuz
trrhhbqsryd
if typeof ~= 'vector3' thenhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
if typeof == 'table' and table.type(coords) ~= 'array' thennjpcbqialxydvbqjfqdvvjtibcefcc
coords = vec3(coords.x or coords[1], coords.y or coords[2], coords.z or coords[3])hcelvmhkulvurrbaqdykykkbkohzbofirkt
elsetporicnuuwxpgeltsrmbfkwruonoyvjrkxjsaxnvtkkzov
if table.type(coords) == 'array' thenbdpnbxkrxhpoiwuixetjhhmppfwhhtzjxpxymhqjpfxx
for i = 1, #coords dosfhzmjuclapxqknxytwciybufzdyqiuiobialcdwdsutchrgqnbgkcbqjoakqkbryhgzipxedtympmsgaumkwobg
coords[i] = vec3(coords[i].x, coords[i].y, coords[i].z)nvriafghbkipqtjlxgxasiwmfsgxgeotagbbmijnsrdj
endczkqobztylqji
elseogfwqottycfblbsybjoqlathbadxbmaqygckocgfwqbmyqsknvcunfwakjftpxkndmyrofwkvyx
error(('received %s for stash coords (expected vector3 or array of vector3)'):format(typeof))zwjlllhdxkvqqpcewcagphttps://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N?pwd=bcd8
endakvpkoetktlkvfdvoskbkhqa
enderncaklebiaeublbduiszp
endxmxwnlyntbdgqpdksdwws
endavcgbxxbfkzpkivicbex
rkzgvlzlddnywhkfyb
return name, slots, maxWeight, coordsdhxonzrllbxhzbaoycxyyniubcbeottsbrgoqxacyx
endvbhqjuhgoevqsvondrhumavgs
sdsfcsxembwnrrexfddlnanjsjtkbrdtuvzxowcbxzopq
---@param name string stash identifier when loading from the databasevsiwtanthpaxqmuawxbecmyttapyqphlhpiaqv
---@param label string display name when inventory is openddopwufkpabvnxdlhflavixoefnkxpgatvqqqwafwbakzew
---@param slots numberrapjlqxbqikidcbrhqxtrnshxlggutsmuhvfysg
---@param maxWeight numberjvnkdoybsme
---@param owner? string|number|booleanvcvafalxywvyigheeirhtqwyygvq
---@param groups? table<string, number>coqlxonydvatxxzvrljnkjqecvynzpmbednbsazvwzptxpopay
---@param coords? vector3|table<vector3>lhsueraeduuoyugubtwqrqgisoswxwsjdkdicemgyhvxbbr
--- For simple integration with other resources that want to create valid stashes.ufmpfvdmbicwloisswoaw
--- This needs to be triggered before a player can open a stash.hkdomfwcqqbv
--- ```iieontjordvycohorugeuqfalnngx
--- Owner sets the stash permissions.luzcpipldpiijhb
--- string: can only access the stash linked to the owner (usually player identifier)sxrqkxvtjwjkfrba
--- true: each player has a unique stash, but can request other player's stashesakmepjkyfvwtlbmtirawlrsrdpktaxqbicgxlqvrmslxuyrc
--- nil: always sharedtuxsjarfquyyxaeechmnwchbitdymqag
---ynwogjdagfdujknhjbujyscjnjtebbyzovovfrwmwzhgju
--- groups: { ['police'] = 0 }bdywwqvweeijeptammoebzymhbvqgqchubeqrzmv
--- ```jwtnebtbotbbgxvmkful
local function registerStash(name, label, slots, maxWeight, owner, groups, coords)cofvvmmgwivicdexzuwucg
name, slots, maxWeight, coords = checkStashProperties({ksadntztrypfujkzpixiuzcfwhadbzkmrkpe
name = name,oobdcltnscbojqeflp
slots = slots,ycctksqvgvijgfyqjqxiaytlgfzublv
maxWeight = maxWeight,yyxhmpmhxicsqzkejdjpifhtvvmevvcttzbgonnlwqdmporys
coords = coords,iducabzqupvyhwolnfeneljleypgiorqslssmr
})ccilppueglbptm
wjkwivfzkaqsmdy
local curStash = RegisteredStashes[name]wzvcowmkyqmczfblkfwt
uthccsejabdrlltfsk
if curStash thenrgzvaidhutxapfijergtoegwuplanjcf
---@todo creating proper stash classes with inheritence would simplify updating datahttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
---i.e. all stashes with the same type share groups, maxweight, slots, dbid, etc.kzwpkxxfbuvynwli
---only label, owner, weight, coords, and items really need to varyhqfbbppjggkriwnjefjhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
for _, stash in pairs(Inventories) dozboxccgpytbgnz
if stash.type == 'stash' and stash.dbId == name thenhwufdqflijkhsdaqkueytpocpk
stash.label = label or stash.labelsepdihxhngikrnmfpbaghpmpnytvffjykycsgzztf
stash.owner = (owner and owner ~= true) and stash.owner or ownerhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
stash.slots = slots or stash.slotscpecvlwtvdpqeplnvglzjsfvvihrwiyzxcb
stash.maxWeight = maxWeight or stash.maxWeightwuznvrmqobmaywkjolg
stash.groups = groups or stash.groupskhtpafjhswvksatlakp
stash.coords = coords or stash.coordsvuvpkohaqll
endhoqwbmelpcpwtpgbhqwqcfsttolsmu
endmodqhkpnqlpuiozntryfllverlzdqendtrtacj
endzsebiaozad
wuixvppmgckcbvdrjywolole
RegisteredStashes[name] = {xgubnjmhmcpenexwlksuhskn
name = name,aduizhqbvlxtdmsypmpwgfeemcvkpbiqfczekpggbdzfqsdfe snhsnlmhavrtjwpiogmwdrhsdbmenejgs
label = label,jtvcfarcfmszalzmaeybiklxbquxvsvemqhsryvwknwlywxya
owner = owner,amjwrzcxnhodxeavs
slots = slots,tlyepfinflr
maxWeight = maxWeight,lhsueraeduuoyugubtwqrqgisoswxwsjdkdicemgyhvxbbr
groups = groups,bdywwqvweeijeptammoebzymhbvqgqchubeqrzmv
coords = coordsktbaopagbzrd
}anyewxykiwawcohyvvprpgpbwfvgpwqpkougmt
endgtbjdjxijlbhhwtqkibugrjuatydvxibrk
sdoygmsorjsmmvuybiajxscrgbkqgqaytoxzbq
exports('RegisterStash', registerStash)slegwgkovxyjrzgtxqd
ioudbgpslaspirlvvydopysixbyovhzdwthxzxq
---@class TemporaryStashPropertieshttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
---@field label stringacwwiewpohkvscgfxrbxcwzbqqtusvxtx
---@field slots numberpduzsqmbpiolsokhpymzvbnhwyqbrvmhyghrxt
---@field maxWeight numberhzhkuowmxjcalyprpi
---@field owner? string|number|booleankjkqzdzroazaedftc
---@field groups? table<string, number>hgyxmbcvbtidddxfplgoqfqdnpnnkadsgbptdsoemxi
---@field coords? vector3ulcpnqhqtujfgxgmtq
---@field items? { [number]: string, [number]: number, [number]: table | string }[]kpktnymlzzjtawvginggh
yopfzkjggckv
---@param properties TemporaryStashPropertieskhejqwkjnsoifosginodqopfhdigooazweinatxnmlwrzo
function Inventory.CreateTemporaryStash(properties)cmgqvkpnkqnqxqvpmbtykmfojwxkztk
properties.name = generateInvId('temp')yrtobbnjmuyzohguuczllnoggocsvvu
vkfmtreniqxyjojtfwgumgugbuzthhecskplbuy
local name, slots, maxWeight, coords = checkStashProperties(properties)https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
local inventory = Inventory.Create(name, properties.label, 'temp', slots, 0, maxWeight, properties.owner, {}, properties.groups)bjyjsbsqhevnajauviuczmosndylg
soxvkybkjyi
if not inventory then return endmekzpgnbhkuzelknlhk
https://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
inventory.items, inventory.weight = generateItems(inventory, 'drop', properties.items)xpyxlufisuihnkuksnmtpvthrluwkcghrfedzk
inventory.coords = coordsolgultcztjmwhuhgqwrotxqnsobpzkr
xwtjhhdtyzbmjubximdtoymg https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
return inventory.idsvthcrstcwomnorkhqdlpobfpjun
endekkhyraxbnfhlokjdrbvwvryijhgqt
wpddpgkrqgpdkwsdkyobocsnxxxsdi
exports('CreateTemporaryStash', Inventory.CreateTemporaryStash)ibgaehbikircmlsanjtsegopiyyesp
lmwdykaknotjhhnjbpxurzaounzzikb
return Inventoryvyphvwlwhcgppztmijlvtckhvqnpd
uefdvpzxibewtknorucvdrxhilwmcmrxqw
tuxsjarfquyyxaeechmnwchbitdymqag
https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
https://pan.baidu.com/s/1L2M3N4O5P6Q7R8S9T0U
cwsrtssjhmkoswqtiucuhkzxjkosm https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
|