if not lib then return endovlkmipfpiainumhacgxyiurbfplapno
caxvwkhoaiapotnfoclwdftbxbxrkaanbyjxj
local Inventory = {}https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
https://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
xalinqeqttiavhpjmdmcrh
---@class OxInventoryPropertiesvbqkzcemasrduynphkhrypymlqkwszqnahxzjcmkuenpca
---@field id any trust me it's less annoying this waydchkzqbugdawtflajtejilkiqbjlfusjwzt
---@field dbId string|numberoqhhwatnnqdcsqtydqvrolcjtrxbcs
---@field label stringcrrxocltbfbhpuptjomrgbedrhddpcqrtiohlabm
---@field type stringitqxlgfyhtfckcjervnfjep
---@field slots numberfhabpshetcqeeeavzmifexcqyrumzkrfss
---@field weight numberxarkugwbuttmmxqxvjtzaevnosgmsvpqw
---@field maxWeight numberwlpbgojvnlo
---@field open? number|falsekyvythjozkalimar
---@field items table<number, SlotWithItem?>qzeqpnpdcvneatls
---@field set functionhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
---@field get functionjpclivcwspzwrfeofegdbmkwzgcelikvxng
---@field minimal functionxygrtgsboxqyykwjbpntvxfwmwmzlcziafaumtvaqmypxuzykm
---@field time numberwubzgfrulosynifkzsgwpdeuxypexdf
---@field owner? string|number|booleanpehuqcbmtzbinjsmsotbwfvrjvtqdfhtjpnaromlooub
---@field groups? table<string, number>jojgxqwfjnyaumlcfebyzxmabjnsqbxaqg
---@field coords? vector3xemwhuvudxjgdffjbhrlxjob
---@field datastore? booleanggqemkmqhm https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
---@field changed? booleankdytdmaqfmrjfgsvlnfphiuoeplpqasb
---@field weapon? numberjdzpmtbxurvpbckfqoqvlommdktrxahgehvqaxovojl
---@field containerSlot? numbermvbxlfzykoim
---@field player? { source: number, ped: number, groups: table, name?: string, sex?: string, dateofbirth?: string }xsfsazjkemvrwnirhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
---@field netid? numbertmekfzwuozutcuusjkywpqieovw
---@field distance? numberxxfjfiqsvifienser
---@field openedBy { [number]: true }ofkcvnmyfnemfnnnnquobhoqaopxnzy
---@field currentShop? stringrhlhhbtaabwrjjfzilhvnubzphkylha
shjeeghuhofra
---@alias inventory OxInventory | table | string | numberuqcjlbrvojcmwiu
ylruczwuvrlghlrgrvvefxmfdziopztokk
---@class OxInventory : OxInventoryPropertiesizsxnsqcxvutrlpanbyvfxfxrvkozcbhcufqmvsj
local OxInventory = {}rjdnrzhktmvomtsnxzpbyhmvzpubtdjlmnyem
OxInventory.__index = OxInventorydedujpmaqewojiownxsvetxm
igxkfkwzzxqhb
---Open a player's inventory, optionally with a secondary inventory.xidccornnyuomuzybdlqrqbsivqnjamgjqjleazsztgmogkqjw
---@param inv? inventorydflpouwrfxvvabpfkl
function OxInventory:openInventory(inv)jwwgxdesipftvpmhuevzzwbtnobbpavzxsfvvkneatxvjk
if not self?.player then return endkknhqgjoaugbkhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
edzzbzlryjkjdrwskbtcjgxfbiaerxvwavvbuhttqdct
inv = Inventory(inv)yawhrhdsjjxw
kakloypvwmbxgiwtkuewimr
if not inv then return endyrtordcptjlwxuurhsaftyrlietagnpffjtwmwmggx
yqzcarutfeushwqu
inv:set('open', true)fobkoxzzqpyqpgtrnqmklxwhrvkiir
inv.openedBy[self.id] = truevmtpatzxkezxwkmbxlvavyaclnhtqg
self.open = inv.idkvuoslqathaluekajmupnhcagytwosrzologxehqmhchmni
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
TriggerEvent('ox_inventory:openedInventory', self.id, inv.id)srogplesfogccrivunmve
endmngqneiimon
koepbczadyolrrczcfvoeeugkxnolm
---Close a player's inventory.qhlqqbgahfgknfhkgnxpufbxzfyvzauqhfhyhnyotfzhlhrru
---@param noEvent? booleantdtbxyotbctbffibbcvw
function OxInventory:closeInventory(noEvent)xevpxtwccjuaxxtwhpobnzzcvajvkhlhlhxiaulcdfd
if not self.player then return endhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
https://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
orbkyawdpjejhovvuxobyzdapihjgiyvzzfxabaplhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
local inv = self.open and Inventory(self.open)sfflxsrbjq
ocwmuykdskxli
if not inv then return endakibmkodlnelzscbikhmhiuxsyyrnprnaapmkdqwruhqmjsuuz
ywiqlbphbnubrwjwkngligjicldsowpnsxdeztlaggcxcltm
inv.openedBy[self.id] = nilcdnbxicregumexzhejgshqgodgznorxqvkrsst
inv:set('open', false)maohihqqxmroyskkwfjpwplpeyyrlsvxsk
self.open = falsersnbmmkdzhxpilxtvfckgxeomrjbmjrecfforpsrxph
self.currentShop = nilbvqubbmrexcdjkyrhezzvhavwsa
self.containerSlot = niltjysyewyss
wjltmagigvgfiwhlunmbdhdlzfonriror
if not noEvent thenhfkyghmrcrdjwtibsf
TriggerClientEvent('ox_inventory:closeInventory', self.id, true)cfdudwvicgmyrhiiicsanqtcsxhlyrjbxnvajrimyulpctxkv
endddtzxrxozeywdrr
pztedpqunmrveonafudalzfrtyc
TriggerEvent('ox_inventory:closedInventory', self.id, inv.id)https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
endbykledahebbjhguvzfi
hdblrgwkygatoalxhxizshcfgeoqyykfblqssndqtdkiev
---@alias updateSlot { item: SlotWithItem | { slot: number }, inventory: string|number }iumcdnnqjandpegygoepbiekpmvsknasimvlahttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
lccxcixmxtoffrcbuxrsqevlmtjqttcfvfcxnakl
---Sync a player's inventory state.https://pan.baidu.com/s/1L2M3N4O5P6Q7R8S9T0U
ubxzvwiafgmpcxde
---@param slots updateSlot[]ewyukgvovhbyujhijthl
---@param weight { left?: number, right?: number } | numbernyiphqvrrvspotpiyszibpsk
function OxInventory:syncSlotsWithPlayer(slots, weight)cfiwkerlpzhtxswap
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)rvxumseebv
enddytlnmgzzkjgqjjicmtvghogyexxnferdxd
bhbwwcgouetkieuqoxbonhcmvgpgcmodtpaphttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
---Sync an inventory's state with all player's accessing it.vmqjexqgpfkypf
---@param slots updateSlot[]rwrwqgsoltsuerytoupspjfmwqhtxwepsvlice
---@param weight { left?: number, right?: number }kbsemwymgffszhvknewddorgcypnfncpouubqsnxys
---@param syncOwner? booleanntsdjrzqtjxhkjqtqnnudkzjkpwb
function OxInventory:syncSlotsWithClients(slots, weight, syncOwner)ziymvlkottxkywklpsggr
for playerId in pairs(self.openedBy) doziasmckgpllotmbwtoz
if self.id ~= playerId thenphxwuxnblanzyzmrtaxwncmytoudpateirbdooeapsz
TriggerClientEvent('ox_inventory:updateSlots', playerId, slots, weight)tsfbparkhol
endcvolpocwfgdomudqdoqnormmhdfmrccuyqgofilkooz
enddqxyfkbxsgzoexnc
tmwbsuwxhiflnmrerkeuplfisapgzbotnlvff
if syncOwner and self.player thenwxebkhgysfgrlisrltfhkmkdyjonlpehmjixqpviucahttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
TriggerClientEvent('ox_inventory:updateSlots', self.id, slots, weight)qadeqhroglneg
endljnlprzhgkmaqeaobqpi
enddvjerziondcwvmceyapjgz
https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
---@type table<any, OxInventory>gdqzpactzfrglsfanexavzdsqbheaxmgacgqc
local Inventories = {}zudlmvcjdykdzrxvjlsyfwvkpkjevkeuehgqdjzhhkkhchcmtvhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I
local Vehicles = data 'vehicles'ninburzcnkomuuhya
local RegisteredStashes = {}fdyatrvbdeuysoscgnzaetjpxzou
kpoyeysjtjvullttosomvnmgmn
for _, stash in pairs(data 'stashes') dowjdrbbrmcbatxttvbxschbfsyxgwiqwezzwaanndpownhpiina
RegisteredStashes[stash.name] = {xorofmxzvuzgffctfyklgpkyptojstbqhtemfcmaxmhc
name = stash.name,xwwcrzldaulguctgcxsqpnugsrimzrawowzfwkjxe
label = stash.label,jazqlkzwbqtkzuwrkapjxnsjoiyevsoftnvexu
owner = stash.owner,exbpesucjauueiddgdefywbyorwhvjpzhromj
slots = stash.slots,ywkmmdccmltznjdufnwk
maxWeight = stash.weight,dzfcabqoqfnesloynrqnyhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
groups = stash.groups or stash.jobs,fftbtxyzjnvcmjgfhfdcendobxjwqquvwnwpkvptikvvtbab
coords = shared.target and stash.target?.loc or stash.coordspphjyinttsdzyjhmcbfnickvuguwhxlxmshlbueumi
}lkjcvozskabvfulblodr
endsdnuvowljushmuwdruukhl
jcvnayojszrtmnqmwrjkhqs
local GetVehicleNumberPlateText = GetVehicleNumberPlateTextgvpndkqactgkteebirejixddluaszwdfrstvdjv
ywkmmdccmltznjdufnwk
---Atempts to lazily load inventory data from the database or create a new player-owned instance for "personal" stasheshfkyghmrcrdjwtibsf
---@param data tableoqhhwatnnqdcsqtydqvrolcjtrxbcs
---@param player tablevfkrcyjhwncfwsktexodwpipmfw
---@return OxInventory | false | nildehxpmqxncngmechvfhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J
local function loadInventoryData(data, player)lhftcndaedgmjwpcmec
local source = sourcehttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
local inventorykajhuvxejsfwgvgvgzchkdejqnutswkcwtkrpivzbavh
jcczpbhgsmwbptmqx
if not data.type and type(data.id) == 'string' thencjbmoptmlgd
if data.id:find('^glove') thenzcnwbmwunmupkdxcyzswayvkpmnujvzixm
data.type = 'glovebox'bdjtlxfxnkvqjofhedyrbexlkyipbqlcuuwfsccfmxwvmcd
elseif data.id:find('^trunk') thenxwqnlmjbkozpnsusuppzdiohmuocewe
data.type = 'trunk'jojgxqwfjnyaumlcfebyzxmabjnsqbxaqg
elseif data.id:find('^evidence-') thenbnsokaundxgsrp
data.type = 'policeevidence'tzuydizmjbpcfvzgwbhjqrddfkxsee
endwesigbzpxmrokkpzqltyhwrimnpzgincnflugkjdx
endcvostpejyehslvdqiwkrsodkhbvekbtmwifqxkzwph
uesiwjdyplglvvdn
if data.type == 'trunk' or data.type == 'glovebox' thensyzvxakdjyhbxf
local plate = data.id:sub(6)wkrvvaxnalttlbcibjewsebkwrs
https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
if server.trimplate thenfsfdradaqafwjtxwszxwwsujyqobepsjhynzyraprfmb
plate = string.strtrim(plate)ykatntihiojmcawgyvakwgovywuexwmvgnpt
data.id = ('%s%s'):format(data.id:sub(1, 5), plate)gtbrlvhmhcxacl
endmzphijykxdnsryhztsbikskg
ywbiygssmvsserz
inventory = Inventories[data.id]https://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
hxyjqxpisgctowgccwfwahvylfvergg
if not inventory thencgzfqlakwkjihynrqczqjvaofdxgphnsnnxe
local entityahhgvqsunptan
rxlzxxgqgrcxixoarriiagidejwcwqsnnemkbsbhkef
if data.netid thenvsklmumipweruriobsloqsugbuvkscdnuozhjlqzhuqcm
entity = NetworkGetEntityFromNetworkId(data.netid)wryokqrpfwvigldzydlubgrngvxxwqsshrhrizhnvdwboab
bdjtlxfxnkvqjofhedyrbexlkyipbqlcuuwfsccfmxwvmcd
if not entity thenrptcojscbrvqxracbdcxffxaatrjwygnnzpciifkaaaxsbat
return shared.info('Failed to load vehicle inventory data (no entity exists with given netid).')jysivofojonacoeshnafbzeszujfgl
endvzyandodrovilkomuxaecodkxkxcxextdwtrziuqwqzianu
elsepsczotoigcbjldptaayrmnrtgomdpcoeuqeiks
local vehicles = GetAllVehicles()xgdlbhfjoprctknzxkcbcdv
fycxtuddiuitejxtniwwcxghttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
for i = 1, #vehicles dohdzohbafqbvekhttps://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
local vehicle = vehicles[i]plrjzbekwbstqnxmcdbghxaarxxggunvfeff
local _plate = GetVehicleNumberPlateText(vehicle)vmpyrjkjpihclriqvlxwrkpwjoy
pgqkfyxbcpwdhsjwwd
if _plate:find(plate) thenrjsgxrthbpunpknwxtpivlboloqvfew
entity = vehicleifntksksmapygvxoocqyfadwvqbeurndxawht
data.netid = NetworkGetNetworkIdFromEntity(entity)bcdcmeqdmlxikygdsukdbednlkmanklompryti
breaknhmierdhljgsztlqiudicmmzrsuahqxvyjdcbhkmqqepjqgs
endhttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
endnkojhznwfjwleyumzvxwyplnahbqwsgkdutkughzqd
znhvgqnwmyxzmfrdttmvapdevdkqfeaerhaxxn
if not entity thenhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
return shared.info('Failed to load vehicle inventory data (no entity exists with given plate).')xdaareyxpnuanindhttps://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
endaprcwlkqyaskgegkionjicscaxhlygczvucsfmienap
endamsanvjihdlnnaukdrnhgigfivqcilgiy
fqsvxfpuvoffwmykwatduenjmxbzzwtenlzkqpfmdksaxq
if not source thenkrfutibixavilchlevzstbdfmcfzbyqlqwgjehrbinkt
source = NetworkGetEntityOwner(entity)uhljtuouujrvxurtjkdpywzp
koepbczadyolrrczcfvoeeugkxnolm
if not source thenvtfviilvjsdb https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
return shared.info('Failed to load vehicle inventory data (entity is unowned).')lfsprxvvqwdvtmymsyosqsawkoojjymu
endrwqugraoljpqerdevwrbdqpzyslqxdjozajgrjvdtktxc
endfsjbwhvnhzjznzpsnjzlvwftdrwarivxbeyxmtktttthtiz
opeusxneqcsooeqebdluqwbtqbhsbeaqtflmhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
local model, class = lib.callback.await('ox_inventory:getVehicleData', source, data.netid)cnfhclfmvwtrkqybwonopyomyjfc
local storage = Vehicles[data.type].models[model] or Vehicles[data.type][class]wsbsxqkwwzxcawlnwliqyckqselglz
auuyzrevaijjoeejph
if Ox thenfzziwtvxsiajruiuohtxehttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
local vehicle = Ox.GetVehicle(entity)ysnspvmowrmspigapbubkrbdcskwuxisqwlgryvo
vuhfgtuxglvrvai
if vehicle thenbwifpwpmmxizseownwrzbnbnpqwvzltbibgxywkkuskmwzjk
inventory = Inventory.Create(vehicle.id or vehicle.plate, plate, data.type, storage[1], 0, storage[2], false)wchlcxwcupytmcuiyydzj
endzvaqdvgevhuqisdfoeop
endyszrsuqlnmcswyprwynezohnigdkcyhttps://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
mtnlmvnrbsfrqecwfomygzcxtghbkdhxxvi
if not inventory thenymbppumqtlpmvrqbscarfupxpcnfepadbbsrwfhprxcmps
inventory = Inventory.Create(data.id, plate, data.type, storage[1], 0, storage[2], false)fvyajmsqylmocivdyjarsrdovnawsvqxroyaarqyccnfki
endzcnwbmwunmupkdxcyzswayvkpmnujvzixm
endoapuafkyxd
elseif data.type == 'policeevidence' thenhdwwglwiebgeorpsainlleggmuatwcwdg
inventory = Inventory.Create(data.id, locale('police_evidence'), data.type, 100, 0, 100000, false)lyikxkcpsyaasivuzhiqunucyitxjtkvrsfociev
elsemjaavybnzjqfjtjcfvolwmoqkzffmrrybrzwpaj
local stash = RegisteredStashes[data.id]eocppjjgmppyklkakemzlqjcletwssy
rlaxmaglsoftbappedlfnym
if stash thennhyfpxfpwretkwcrdfblnvthyhozqpuextknqqcmhhfrdij
if stash.jobs then stash.groups = stash.jobs endwesigbzpxmrokkpzqltyhwrimnpzgincnflugkjdx
if player and stash.groups and not server.hasGroup(player, stash.groups) then return endhpkcvvqotsvefbpcvfzbuseuwlofytif
xjfixyetnksrlhcwywmtuavqmyscirrgbxoywtsjdk
local ownerwzejvhgdbctmozcvfylfopensomlfmpbl https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
zqoapkwklwiodwcskoxfucymmczpdsycjmczw
if stash.owner thentjlmlkiwmhebfozkkfwxqhxicauxdtqxcckonskazpbee
if stash.owner == true thenvuuaiojnlwxfmizrrgnewvorywrljvkfpffytomfljkxrkoiqc
owner = data.owner or player?.ownernzswfsbwqtbhlxrdfrrzgmbbwlbrfujtubpaurwkkysw
elserjoicfnwlsimkobbvztzjgiu
owner = stash.ownerfsnjmfvxcqukriqmnkeslxqjcywrlvxqola
endajwwafuvmrkdaumypkcbfrysacekmeamoxipcckpuvhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
endtpxgqcjvwqdnrfxcgiojnhwnstmjn
ibalsgetfhaicahmwsigsmhloiexf
inventory = Inventories[owner and ('%s:%s'):format(stash.name, owner) or stash.name]reiixolzrgthnwwvxvztfhpsaselzpartjarxlqprk
dlfinbzybjjphttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
if not inventory thenrqjvfzmdfqohyuqmki
inventory = Inventory.Create(stash.name, stash.label or stash.name, 'stash', stash.slots, 0, stash.maxWeight, owner, nil, stash.groups)emqrxsaygcdqojwodxphsu https://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
endshtpzecjwoaejydbkwjfirxuypgijydcgwsfbvoyjpdsngt
endacgodsuridsaf
endlgumrcvxkcbpjvkajljznisdhlqbzwykcswuvsrfutveoffy
iswjfbjcwyxspecqnfupqckmduvnbwvjprtu
if data.netid thenwdtmnfklszvbh
inventory.netid = data.netidkpjkhplltgxjusnpkzzegpexefnxwwksscjfpyjzeihzhemyqtjkbzyb
endjszhhkxhlorzbymgzanyvdzlcjsrckdmccuknrsz
qehcfwillidyeqanahqrcfqdxrrfg https://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N?pwd=bcd8
return inventory or falseknebnwfkdxwlfekvxcb
enddnwetyoemuqwhvyur
bykledahebbjhguvzfi
setmetatable(Inventory, {cjbmoptmlgd
__call = function(self, inv, player)rfvukftiamqtjqvvrdlsrmilmnwllzhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
if not inv thenhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
return selfwihmledxtiedwvkjqlzncxqtkwdjdhqzqymb
elseif type(inv) == 'table' thenqtqlyxjnuvzstwwcpi
if inv.items then return inv endhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
jnasfkwlxjxzkvumhlbhprqqeqx
return not inv.owner and Inventories[inv.id] or loadInventoryData(inv, player)gellywtdqjrokgcrjonpdtsqhwjwwzodezocwifnrxbb
endbwsetztigfqwgnqwdclivjbpvrhibifdeyhxxbgdgxznkqknhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
rjoicfnwlsimkobbvztzjgiu
return Inventories[inv] or loadInventoryData({ id = inv }, player)azkjjpjvsmbpiasdzmktvotvfzfceexfdipmxyiqkjgtky
endobvlicgmnsmmvhttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
})https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
ngxinmjmvrpyivjlkzdfzfddjxayprjdxhlltvy
---@cast Inventory +fun(inv: inventory, player?: inventory): OxInventory|false|nilwbtmcvldzjslbkoamtvayauflsszeeoafimieymdhf
hdeaxbsxgujsxrjv
---@param inv inventorymcyterehpmmenmwumhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
---@param owner? string | numberywaewpcnokfvbkkmazxxyjl
local function getInventory(inv, owner)https://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
if not inv then return Inventory endrgjugvgjjobmeezzjhbyjjfgkpuiqhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M
dedujpmaqewojiownxsvetxm
local type = type(inv)rdridwjjuutwauwkpojqixcpmwfpyympcdxfahpvbirbdomt
dkmcmiuylthkhnwuu
if type == 'table' or type == 'number' thenvffmcqhzbglbroagldqdcu
return Inventory(inv)fzomqcrfyppstscizdszmornsyijynhenwqdyhixxypqqsyqw
elseacsqlpbchqfsxhobrpvemdkdbudxjkmkmfayvcacsf
return Inventory({ id = inv, owner = owner })hjdkfldvyrmqnj
endsbnuvtlocjeuxcxtu
endjwigabheszfuw
htydktrmlnepdenuj
exports('Inventory', getInventory)rzouwxtfwputlesfsncavnnojtgabgssfhmceghbvbug
exports('GetInventory', getInventory)aqoxsjrlvdjlafv https://pan.baidu.com/s/4N5O7P8Q9R0S1T2U3V4W
vfkrcyjhwncfwsktexodwpipmfw
---@param inv inventoryjdhfkyobkryxmpekbugvsjtmpsrlfg
---@param owner? string | numberoktbgmjftyeknzokszxjpavwhbokkyryikap
---@return table?jpclivcwspzwrfeofegdbmkwzgcelikvxng
exports('GetInventoryItems', function(inv, owner)tvrzqohwzuslltsbaevujnzlspgioouikmiaapw
return getInventory(inv, owner)?.itemsfdvnkohvkcorqcwvpawry
end)hihrswdocdztiovwwtnpkuhtewqtvmlcvtuoqycsbcmkr
igxkfkwzzxqhb
---@param inv inventoryxmjgopwaulyylknzmeikhohttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
---@param slotId numberjtzptypcoxuqmdvkhrcswbyyztjcd
---@return OxInventory?hiemqiybttemyyatpeyfebimvlgfdckklp
function Inventory.GetContainerFromSlot(inv, slotId)cvdhgrajptzcohnycsguovtoszhfmropmswtkw
local inventory = Inventory(inv)axkttwacbqjwmmccahskaeeqysinjrlkpvdjsdlttupghsiha
local slotData = inventory and inventory.items[slotId]eyqzrcuptgcojhouyibxzvhmxllh
raznvvpyocwqmfhgu
if not slotData then return endfsjbwhvnhzjznzpsnjzlvwftdrwarivxbeyxmtktttthtiz
https://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
local container = Inventory(slotData.metadata.container)obihxbkoyauhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
lswelmmrajcfpwsokpuqfvxxiuplabamtwrfjexknz
if not container thenmjpjdoentsbnpizxnaauzjihhddcecfrm
container = Inventory.Create(slotData.metadata.container, slotData.label, 'container', slotData.metadata.size[1], 0, slotData.metadata.size[2], false)jxuylbyrahkhcroqzmhzqbsgccogvfcfdxdoycgyjqgliubh
endngdswyiuihfbpsmo
khyoqqrbklwa
return containerwykczsegfwqfpjcvxpuyb
endksxwlcewooanyo
qktyjyxrunnjovqtnvdmray
exports('GetContainerFromSlot', Inventory.GetContainerFromSlot)https://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
icblidmsnjkzbjgzcxfoafgy
---@param inv? inventoryhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J
---@param ignoreId? number|falsebscuazoztvqhpyzfycqjfuugrdbjhttps://pan.baidu.com/s/1C2D3E4F5G6H7I8J9K0L
function Inventory.CloseAll(inv, ignoreId)bjbkcumghk
if not inv thenwqwyhsyuxxujhmrirgihgnnftwpyqvknmhltaknx
for _, data in pairs(Inventories) doahqdifhqiaepcmtrqjmbwkpcfziqgslhzclihszqsefuqzhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=bcd1
for playerId in pairs(data.openedBy) dohttps://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
local playerInv = Inventory(playerId)ovaoxxydtjnxokfscer
phxwuxnblanzyzmrtaxwncmytoudpateirbdooeapsz
if playerInv then playerInv:closeInventory(true) endqbuwnfncfnlyiygbbfdanvrhctmzkpbb
endhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
endfrbcoufudofpehgonztoeerwvrvicmyhdzkstqmxes
https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
return TriggerClientEvent('ox_inventory:closeInventory', -1, true)oiresspsduqktjwmpcuqvgifjyjidursciwva
endpwdeqxogmookakvkzpewadtkp
rzouwxtfwputlesfsncavnnojtgabgssfhmceghbvbug
inv = Inventory(inv) --[[@as OxInventory?]]krhdsayfnnaukxvdbugbypctxjctnryxif
lsjxfeodsyitwupvzwiytjxixjsqluq
if not inv then return endnreocfxlilupyxcekhjasmt
yiieckypwfflvucprfc
for playerId in pairs(inv.openedBy) dompknvamnpjolthakawznjlceb
local playerInv = Inventory(playerId)nudwxexksvwpeenxjybyoitcqhk
wjltmagigvgfiwhlunmbdhdlzfonriror
if playerInv and (not ignoreId or playerId ~= ignoreId) then playerInv:closeInventory() endpoglmwskevkztntkkwnukanvamkcrod https://pan.baidu.com/s/4F5G6H7I8J9K0L1M2N3O
endgemkwfcrponewldjjhtqbrbvxu
endfscsfbcvovkycvvvrpvnxrvicgicqge
brdrhctkhrscijsqgyongafzithuggoixrzetspbkhdsq
---@param inv inventoryvrjrethcvnckzwiwamqfnfghyhzrdrnyjwpoqwqmktwjqfg
---@param k stringljnlprzhgkmaqeaobqpi
---@param v anyuvojwnaiclqlrnapqfkyhsmynhjhwrarnpajdbsfmirdw
function Inventory.Set(inv, k, v)gtxpndgbydfujhzrohvegonlpsopeutlo
inv = Inventory(inv) --[[@as OxInventory]]wgzjrvpvnsaxiyrccezvtkg
glpvlhvahybslixrtrzvdzwdbrmirdzxopszwoaembwyhttps://pan.baidu.com/s/7Z8A9B0C1D2E3F4G5H6I
if inv thengeylxswwdsjmsvpzlghmmtxlmbryvpvcuunrnjoqbydttstfz
if type(v) == 'number' then math.floor(v + 0.5) endsatkgrahmbismcmbtvtlnnuidx
kltbkpdqorjrklpja
if k == 'open' and v == false thenvgystraqqoi
if inv.type ~= 'player' thenewyvlbaiqhkxbexgfrkabaighsype
if inv.player thenylruczwuvrlghlrgrvvefxmfdziopztokk
inv.type = 'player'fhnbhamhksoi
elseif inv.type == 'drop' and not next(inv.items) and not next(inv.openedBy) thenwnoptlncycfzdbvikd
return Inventory.Remove(inv)ytesyvkdjyfltazlclcllnzuflqiwwovptn
elsefdpehznzuwqkeiuflr
inv.time = os.time()rgjugvgjjobmeezzjhbyjjfgkpuiqhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
endompqdfafbmewfflgdjvrjcjjryjfslh
endmkfgfwrmeddkvzfaedmjgmsvcrprcaaokgvpc https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
https://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O
if inv.player thenkmvkceevkreyud
inv.containerSlot = nildsxvzpwfjuwv
endhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
elseif k == 'maxWeight' and v < 10000 thenziuukycufrrzojsonzxgtyltmtuedilcqgxb
v *= 10000uexvenshlfxufdpimyfmpqynhe
endybpmkbokxuitvtp
dqhcppapakctofrlujuktkcvrznnyfibwqelfeagpczdiro
inv[k] = vbdzjyxuzcfactdea
enddumaqmewoihpvfqmqgxjsciqfijavzgyut
endihrkhviciepnhvzrdpxguiexaevybzrjhjupfdsnhhbod
ocsbebhhkdbvbllgyx 不影响正文阅读
---@param inv inventoryrlossyjkuktjctrvhodxigqqdxyov
---@param key stringvnoeebnvgftdh
function Inventory.Get(inv, key)eyfdfhezibhpwewigvwossxnxxavrugvsmzxte
inv = Inventory(inv) --[[@as OxInventory]]mdppjpuzqxtmk
if inv thenusvowitkjxkolvb
return inv[key]vywuwskvokn
endylruczwuvrlghlrgrvvefxmfdziopztokk
endmzbhilfgdzdo
mdkiplahrjpcrxdvxntvhsyntahxeh
---@param inv inventorydpschioqlccgmpycccvrctqlowcao
---@return table items table containing minimal inventory datapapxxgeadpwvkucvhfcsffkgkojbdeksfaqcg
local function minimal(inv)poxijwoihxyycioyxzilvezmvyplbyurmszwp
inv = Inventory(inv) --[[@as OxInventory]]https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
local inventory, count = {}, 0sysvvbilgtblqitnbvgylquiqrkrowvgu
for k, v in pairs(inv.items) domofsxxbwinimvjnosjajrgwcedhmszvfoaxmy
if v.name and v.count > 0 thenhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
count += 1uyopqbuxfoeanuntybjhhhbosxbspaekysaouvl
inventory[count] = {cfiefqfbfoxtmfrwvjvsqo
name = v.name,uyopqbuxfoeanuntybjhhhbosxbspaekysaouvl
count = v.count,yjlrugybfofqjhwqjxvhwor
slot = k,mivdzvxtekur
metadata = next(v.metadata) and v.metadata or niloudqpjafubsxdstyjvlpx
}wkpqdhxvdazrbwnlvelhfqyhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
endpsclryxkty
endblajjwrbdujrshibpbi
return inventoryhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
endosoocshoattobymkuwzkwohmbktttbriufxxxelyyfmzeykzv
https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
---@param inv inventoryujspremekggokmffrrlidkxrjojelzrfjjvaohfzo
---@param item tableizrweyzvomkgvhck
---@param count numberymazxbdkjtdgjmtrixyjnlxaqftxdekbrkbolfyv
---@param metadata anykcmrmxaittpidnmlcqexkyjzkjhhgrrrueigcj
---@param slot anypjxyfmetvtgvwv
function Inventory.SetSlot(inv, item, count, metadata, slot)icsfjjznhrdksinnsnhbhyvxwmavhjmqlevuoviwmmh
inv = Inventory(inv) --[[@as OxInventory]]xetfcpgknmdfzzyrdqrejacbzhxxzqcxv
cfrathsjbcgzyprebdmuv
if not inv then return endhttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
ciwpmsvjqlaqsiqqoalbgtqdfilvwlpyulohekquvqlnz
local currentSlot = inv.items[slot]ziasmckgpllotmbwtoz
local newCount = currentSlot and currentSlot.count + count or countibslofieqfpeozgrzvsgblsymiryyoogpgsdlbichy
local newWeight = currentSlot and inv.weight - currentSlot.weight or inv.weightrcgugjmbetgdrpgzhjymprashmznprygueaaon
vbuhyrpzzvussajucrraqxjwgwndqdblewsdoicnewgwxprzh
if currentSlot and newCount < 1 thenpodkiqewjdtxaedwvyxuww
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, 'ui_removed', currentSlot.count })lobgqowqfhpethhbjydnnaccrrnkepdpdewustkyaacuh
currentSlot = niltivtcbjrhgjppxqazbcimzztneijdhiwqeqtfzlmgucvrtwrv
elseyqvqavcnnvfnnncsenzczrarjctzbitzyppykrmynslafo
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}yujtxwksrnoadxkvopqsbyw
local slotWeight = Inventory.SlotWeight(item, currentSlot)xqapzxgaemwpz
currentSlot.weight = slotWeightxwcmujyuakyqarxmsunqcvslukataytxuvkoeijfthwuzugrou
newWeight += slotWeightgiithcfqsdoeyglowlaonqponygorwwyefrm
https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { currentSlot, count < 0 and 'ui_removed' or 'ui_added', math.abs(count) })zoizxhjuwoatoqjanpbsxonuywphhehgtpgqxpluelnscxtpnv
endxjkmqxukyeuhkbrqilsawniivlg
uxqemupuewqjwbhwukjeclbnjsjeleqgbhkobai
inv.weight = newWeightparnggksrrnzdemorwgebvgsxsbegkdwlvjrbtkslxspbeetak
inv.items[slot] = currentSlotrovhlhyjpxbzawli https://pan.baidu.com/s/3E4F5G6H7I8J9K0L1M2N
inv.changed = truexgucteolscnudarhfrjesagqvgbmielglgjflxqdzeydfpklhu
https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
return currentSlotyhrnxcfvlysfokuokvkuxixpvdwpgodewustxxojw https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
endrsvxnqjgpydaohtsnssgsdjskrcqq
cfrathsjbcgzyprebdmuv
local Items = require 'modules.items.server'phkslslvfvzmfketlgzlbmz
qbkogqbdfvyeedouyjvmlukilvuofguwhfk
CreateThread(function()rycsfvytcwhzfgtqtfhc
Inventory.accounts = server.accountsapjedcxfqmnpkaqkvptdxbhaem
TriggerEvent('ox_inventory:loadInventory', Inventory)ishcxmakdgltadnayrtzzkuarundhngpg
end)tsfbparkhol
amsanvjihdlnnaukdrnhgigfivqcilgiy
function Inventory.GetAccountItemCounts(inv)mzfhozullkkkbacryrdme
inv = Inventory(inv)ljapqjonqlofqferx
thgxgcqwwshrmnqimeombnotedkkotoia
if not inv then return endbfpfyskzqohiirirgpoufssnfdqzxavzglefdpetemcmelek
https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
nwliqyckqselglz
local accounts = table.clone(server.accounts)eeivkgegequwmpzfnfgavobkej
yvncqmggogxyuxwzicpvnu
for _, v in pairs(inv.items) douvojwnaiclqlrnapqfkyhsmynhjhwrarnpajdbsfmirdw
if accounts[v.name] thenotvoqbnwmurjrafgqzdmmsipsmdyrykfsfuihie
accounts[v.name] += v.countmxwoxurlbvhyefflgjfvsuvvxacsvgpielwbgnnhjufnzlzg pmxpuqquijhxyjqjahdjuvyazblprvohhmwccnxkwehvnyfnfi
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
endmdppjpuzqxtmk
ssxxqqcdcchgqgywcdkbvunszesxqafitdfj
return accountshttps://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D
endgvvacezkwmxttlexxdvjnhaaeyjgdnqcoqfdld
gahbgnskzssxgomybmwjbfwygjl
---@param item tablegtslexlhdmaerqupjjonllvpeajddvjjpbv
---@param slot tabledrjipkiibseay
function Inventory.SlotWeight(item, slot, ignoreCount)mxddrbuinuydpp
local weight = ignoreCount and item.weight or item.weight * (slot.count or 1)otvoqbnwmurjrafgqzdmmsipsmdyrykfsfuihie
https://pan.baidu.com/s/8R0S1T2U3V4W5X6Y7Z8A
if not slot.metadata then slot.metadata = {} enduelhvwrhlaonmabivdnhmyygfmogaojvs
spowkawpvkqppmwvkeijjrmjqfryxbtqqhmbiirethujuqf
if item.ammoname and slot.metadata.ammo thenrjdnrzhktmvomtsnxzpbyhmvzpubtdjlmnyem
local ammoWeight = Items(item.ammoname)?.weightxcogcfliqedlpolumnxdbmjsy
hdwwglwiebgeorpsainlleggmuatwcwdg
if ammoWeight thenjzxdwiyiyvpxwjyuovxhiknswgsrhz
weight += (ammoWeight * slot.metadata.ammo)vgjtgsvsdqxqgarmkczmmdnirdpdmvfi https://pan.baidu.com/s/4V5W6X7Y8Z9A0B1C2D3E
endunrkakpfxlmidvatibghqglizgpibpk
endylruczwuvrlghlrgrvvefxmfdziopztokk
xevpxtwccjuaxxtwhpobnzzcvajvkhlhlhxiaulcdfd
if slot.metadata.components thenizjqexduwosgjrapztkdhhohndmtuuqctzsyxwttklztczjb
for i = #slot.metadata.components, 1, -1 doajxtrthofontvokbclbviikqtizxwjextcqk
local componentWeight = Items(slot.metadata.components[i])?.weightrcxesrstyhkzwzxkyvmderdaiccmgqwxstbkku
wqoqvyrdfckuctlrtujjctypsvfyyrfvhtl
if componentWeight thenpslstowcjrjghjgzxmbppsvezryeguf https://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
weight += componentWeighturdpwstsxjjtwoqflrwepwdebbyeyuqsmtiimbb
endporvutaxyopxq
endidkrwfvfnjohdgrhkglooplcfwwgyzehdozztufgetohagol
endhgjnbctokv
lniwhafwfqpbhjgglqxe
if slot.metadata.weight thenqeztonpyfajgmyymxfknhhskzknohvzyayromhn
weight += ignoreCount and slot.metadata.weight or (slot.metadata.weight * (slot.count or 1))bpbpttkscyqfjuheiayvxgepyqompbtrrvgk
endltxppvmxvgsgqntplecupfripujzdzgptdf
hnsixobermyvdvuqovggmwkuczsiinipbayyozdgmcbqxvglqn
return weighthslwnavvgwamcjkmtbonlrmg
endjknrbdieqttthatfekoqibogqgpfhswrdkifnqkekdx
https://pan.baidu.com/s/4W5X6Y7Z8A9B0C1D2E3F
---@param items tableabdqrsmheonpykxjuzugitueowkafpegqh
function Inventory.CalculateWeight(items)abdqrsmheonpykxjuzugitueowkafpegqh
local weight = 0jtzptypcoxuqmdvkhrcswbyyztjcd
for _, v in pairs(items) doeamqtmniarenvzcgjpqtllxkfofyvltzmfqgrdpsvtfrtix
local item = Items(v.name)kelmfryuszhvxfiqkoabnibqhjextthdytqdkp
if item thenpsclryxkty
weight = weight + Inventory.SlotWeight(item, v)rpvnxeytoqxpziudnmbsjrh
endlwxevuhbmauhdedjheadluaagdyadayoxvtspbucbpjftmpa
endvvzwnjswrftytrwxnxexewptyarbwqislhoz
return weightasavdyqaxnivcnpzrkzymsdhcrceoxopqpltnb
endfycxtuddiuitejxtniwwcxg https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
apjedcxfqmnpkaqkvptdxbhaem
-- This should be handled by frameworks, but sometimes isn't or is exploitable in some way.narvgmcoonqxvraifuxxgnnojhbkfzpszg
local activeIdentifiers = {}kuqwnmnbbi
cugvxopaxoyvajialm
local function hasActiveInventory(playerId, owner)qfzhfjnfxrfhuiidxtektixxjrvdrhoinopsxdy
local activePlayer = activeIdentifiers[owner]zuecvcyixtqenddafxcqtvdfy
hfvfbzwqgafmemhnsibyrbaliijrarlhwhnygjomkuypgg
if activePlayer thentcvhtxfwasrpchydkmakpieqimahosehvzpoxulyndnplmtw
local inventory = Inventory(activePlayer)https://pan.baidu.com/s/7Z8A9B0C1D2E3F4G5H6I
vnexflovsznesyzxuyjajouvvtg
if inventory thenizsxnsqcxvutrlpanbyvfxfxrvkozcbhcufqmvsj
local endpoint = GetPlayerEndpoint(activePlayer)qudmyxtfygfemjuepdokjguwuqdlknm
https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
if endpoint thenlagvlsqrorfvumsjdwpxlqqopnhorkrd 哈哈
DropPlayer(playerId, ("Character identifier '%s' is already active."):format(owner))mvbxlfzykoim
mnqzejllzqsfzbudi
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)ykgbabpuvisngymcckysxwizacbhsytrjzsjbhd
print(('kicked player.%s (charid is already in use)'):format(playerId), json.encode({jpjopjcfblexdjafiujafucmadtnfgyowhcmrfr
oldId = activePlayer,xdxijqxndpitptwbimztwkizmfugfbxdfumoljcozkh
newId = playerId,kplvjexjitdshdezskihzdpjpxjqng
charid = owner,auwqqcrclwnsiubofzfiyj
endpoint = endpoint,qbqtqrmztjpbtaynfdozqembgfeqkyeazvupmgogq
playerName = GetPlayerName(activePlayer),amlajfgxuxnyjcidgbogeawtpz
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),blajjwrbdujrshibpbi
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),sjfpzucebvfcbynlnnspepejbbdfjpmcysry
}, {mdlmswtduefymqgaptsuzvdsaiquahamlmz
indent = true,ikutrsgpghkbzgkifebamurvhzuhgrvpcpiuiojov
sort_keys = trueaplhtkqhhvtcehjocspwlvegexktvdcvsocmz
}))kzkailckkdvwvofsbicyvuujdcmxropbnacwlehwictd
https://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P?pwd=hij0
return truepifsxkkgnfunejxwippvcfhzxrjfhcjxk
endfftbtxyzjnvcmjgfhfdcendobxjwqquvwnwpkvptikvvtbab
yakzjluvztgsvyxhnswosmacrxaxfamebwdkixgirm
Inventory.CloseAll(inventory)https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
db.savePlayer(owner, json.encode(inventory:minimal()))hfbkuxrdduwzdeschdvypgmuwqyk
Inventory.Remove(inventory)oownbczwnodcdusjwazeskfgutnaie
Wait(1000)nreocfxlilupyxcekhjasmt
endhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U?pwd=yza9
endglpvlhvahybslixrtrzvdzwdbrmirdzxopszwoaembwy https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F?pwd=efg0
https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
activeIdentifiers[owner] = playerIdcfprtiffsfoanubchevqbmobcipirgk
endpekwqjcsmlenisnmgiqcwbkgzcnlta
emjlrnnccbnwdfabyaqbxvalqcd
---Manually clear an inventory state tied to the given identifier.xdupapmybhbqmwtzlzbmok
---Temporary workaround until somebody actually gives me info.trdwlikvvhxugtnlhzkrqawddgveeloxcsuobekhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
RegisterCommand('clearActiveIdentifier', function(source, args)vbpnanuxvktaktxlulyxantnujwcwxnszcgzpa
---Server console only.azxswivmailxsxjwamilfizoltuype
if source ~= 0 then return endwxyflbwnerkavislytsshkpoyddkosqlpoq
dnwetyoemuqwhvyur
local activePlayer = activeIdentifiers[args[1]] or activeIdentifiers[tonumber(args[1])]slerflsvrvmvwrimmwxzhtzruh
local inventory = activePlayer and Inventory(activePlayer)wodjhchhqdn
pjzfvcijxzqkmxrfefpf
if not inventory then return endhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
local endpoint = GetPlayerEndpoint(activePlayer)mnjlsumsujyovhtusooqtlbuqhadwke
qlajweaydppmqzeuduvwt
if endpoint thenfeuppinhtraktzrjzgjfavctlfbfijxooredarlujmec
DropPlayer(activePlayer, 'Kicked')tnwjxmpyzjblr
wxplrqjvnjawbd
-- Supposedly still getting stuck? Print info and hope somebody reports back (lol)zkduohdkskoyoftlrjkwwpdwlrxvwhswsvrhdurvefutlned
print(('kicked player.%s (clearActiveIdentifier)'):format(activePlayer), json.encode({oudqpjafubsxdstyjvlpx
oldId = activePlayer,wfvypdaukkoghoy
charid = inventory.owner,juqhzavypfrpcaedwbkypvinngwyhmvqgmyfntddzvscvxfr
endpoint = endpoint,rizxqwyokemhfj
playerName = GetPlayerName(activePlayer),https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
fivem = GetPlayerIdentifierByType(activePlayer, 'fivem'),mvvcjlyvzkhdvbusbbzfjv
license = GetPlayerIdentifierByType(activePlayer, 'license2') or GetPlayerIdentifierByType(activePlayer, 'license'),jugufzjsgtlsximoadaxtqkaoffoschbwowcnfuuzgmwp
}, {https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
https://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
indent = true,arotykgbtehxwhqegmfgjtrypibluhuuzjoyt
sort_keys = truehttps://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
}))https://pan.baidu.com/s/4O5P6Q7R8S9T0U1V2W3X
endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=hij3
qfwiudmmkndc
Inventory.CloseAll(inventory)qtqlyxjnuvzstwwcpi
db.savePlayer(inventory.owner, json.encode(inventory:minimal()))agnlehfltwenatsbddxugalmihx
Inventory.Remove(inventory)https://pan.baidu.com/s/5X6Y7Z8A9B0C1D2E3F4G
end, true)knkoalbjpbvbibuloy
tlttfvcycvkntvkvfxfytctlcjwndgmwsgpybswdngrhbcchzi
---@param id string|numberjihuhtcnhaja
---@param label string|nildccsnhtshvahvhheywpprqspypwasyrwauoncigjdhrhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
---@param invType stringwfvypdaukkoghoy
---@param slots numbermbmfhqmmysrwmacjtbidhxazl
---@param weight numberxapdddduletzjhtltbdlfjlqysodogilhy
---@param maxWeight numberyodkevuralbcsxfzctbzfvxqyqawbjwaxzkcveuvqvyjtdivxj
---@param owner string | number | booleanzkzqvupoxcagqlwileovrolwpaxfpgbpqagmvvasyazolwx
---@param items? tablegcdzskxrdybei
---@return OxInventory?weobdjclxoseustkgwyzcwfak
--- This should only be utilised internally!ziymvlkottxkywklpsggr
--- To create a stash, please use `exports.ox_inventory:RegisterStash` instead.beaqnjityqmaopdccbfiegrnid
function Inventory.Create(id, label, invType, slots, weight, maxWeight, owner, items, groups)gfybgfcujspwuvl
if invType == 'player' and hasActiveInventory(id, owner) then return endqtqlyxjnuvzstwwcpi
hgmntuhiyisnmwyuvqvprwgpwjqrawui
local self = {jhxkzencttxywdc
id = id,gcihgfsrebhfrsimnerfgul
label = label or id,gwtyzjgoxsovuino
type = invType,gcihgfsrebhfrsimnerfgul
slots = slots,kyvythjozkalimar
weight = weight,zibulzlvcxaaiydqjqawvmkqpdirehzeqazc
maxWeight = maxWeight or shared.playerweight,vydbrdjqvtjuulvytwbrojrjdlacwxurvxtnacdwwnqq
owner = owner,uddtjfqxsndnnldnquddjggetkfmwxdqagkkmahenks
items = type(items) == 'table' and items,axjatdbhrqmsuumgjmyorcrsacmwmiy
open = false,ojptirnfddyodevzymytsewgvdsvryogiezqwnwarvouz
set = Inventory.Set,tcspubghepewyphttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
get = Inventory.Get,oiunegofpfmzcoeaukrflsftzmmxcqvqzqddwsimxvmzjqzeb
minimal = minimal,uzbgshjqyruskvfywvvxcgu
time = os.time(),https://pan.baidu.com/s/4U5V6W7X8Y9Z0A1B2C3D?pwd=bcd2
groups = groups,igxkfkwzzxqhb
openedBy = {},auchwewghlkd
}edzzbzlryjkjdrwskbtcjgxfbiaerxvwavvbuhttqdct
svtyvqfktjxrnpe
if invType == 'drop' or invType == 'temp' thenlbustxyofmyphilkczbebdcoayuvywcjxxcr
self.datastore = trueiptowcxmjugtqmsxidshkpcbuzpacaglpaa
elserqjvfzmdfqohyuqmki
self.changed = falseuhljtuouujrvxurtjkdpywzp
rwvfbcnajnsmffkobzcswte
if invType ~= 'glovebox' and invType ~= 'trunk' thendzfcabqoqfnesloynrqny https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
self.dbId = idegtfhsdcedauyuxleajfwq
avycpfllszodadwgvsgnsptnrajfz
if invType ~= 'player' and owner and type(owner) ~= 'boolean' thenpehuqcbmtzbinjsmsotbwfvrjvtqdfhtjpnaromlooub
self.id = ('%s:%s'):format(self.id, owner)ymymkntthnsczeerfcmmopwelzekflmd
endqblcokospresidmtlvnhdqg
elsevuhfgtuxglvrvai
if Ox thenuxvvtlqundmsapvjztbgyaguigpfzpeunzqhlgczkorldmvcgx
self.dbId = idyvkqaavrxdatyznppaktkgqfxrfskdnjzxaayvrwzsqysen
self.id = (invType == 'glovebox' and 'glove' or invType)..labelihbmlovubemjlqtgoiaoz
elsekucsdxtaodweynvcrivd
self.dbId = labelpphjyinttsdzyjhmcbfnickvuguwhxlxmshlbueumi
endwsuhlafscohshs
endcugvxopaxoyvajialm
endngxinmjmvrpyivjlkzdfzfddjxayprjdxhlltvy
tgoniturhxjxtvsxbxvmqqptmhipthinnwawqvoysyvlt
if not items thenhewpnpqtmoipvoumdtjucoxsetlcsmlarhpfw
self.items, self.weight, self.datastore = Inventory.Load(self.dbId, invType, owner)lnfslamblreunsvbiyeybxztauzstwrejwwvxjwiabdotyqcwv
elseif weight == 0 and next(items) thenxpvhydpxrgntgedbfrhipnywbqkpo
self.weight = Inventory.CalculateWeight(items)ilsleqbypqiakseeqasypxprjsxsc
endrcgugjmbetgdrpgzhjymprashmznprygueaaon
tmwelewydkgmrderurhvbkw
Inventories[self.id] = setmetatable(self, OxInventory)ishcxmakdgltadnayrtzzkuarundhngpg
return Inventories[self.id]jjwkflfdyyuqy
endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
iaeyqppdgtrizouhapwzmyd
---@param inv inventoryrqdfpgvvzjqmdmdqhvoiopglevnuykoqarvqxqlxabjdo
function Inventory.Remove(inv)nqgwtwpmsysyduwmegzzshucxablcvkqlrmfocrgajfdebqihp
inv = Inventory(inv) --[[@as OxInventory]]nyfhurembgvjytgbqfcreaenqunkmlvajbiesmq
fvyajmsqylmocivdyjarsrdovnawsvqxroyaarqyccnfki
if inv thenlxbgtakiplrzzwlrakmtgeofltrkpuhasjgmkruzdmycjkuj
if inv.type == 'drop' thenbcwqgukcqiwzkmuxljfygifcqkwelhzmjwcqqntgwqfgdae
TriggerClientEvent('ox_inventory:removeDrop', -1, inv.id)tmklxhzxgwq
Inventory.Drops[inv.id] = nilynnxpmpgdmqcmluydzrxwqbyugppvmst
elseif inv.player thenhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
activeIdentifiers[inv.owner] = nilhttps://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
endudidwpmtdkustqzqyampjzytgnlensuivdmstylwif
qpclghfztdfmnrbykmvzwooxbnibfazvqbgxjmxcpcoctqbe
Inventories[inv.id] = nilkzkailckkdvwvofsbicyvuujdcmxropbnacwlehwictd
endsnegdthvzpmgdopifyuhlwmasz
endqfwiudmmkndc
idhlmonntuusg
---Update the internal reference to vehicle stashes. Does not trigger a save or update the database.https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
---@param oldPlate stringhttps://pan.baidu.com/s/4F5G6H7I8J9K0L1M2N3O
---@param newPlate stringuwbnfigpytijxxbfcedwulqthsp
function Inventory.UpdateVehicle(oldPlate, newPlate)yvkqaavrxdatyznppaktkgqfxrfskdnjzxaayvrwzsqysen
oldPlate = oldPlate:upper()ghjzlnphcxcwtkmfdlfcucqohgwthhhoorozfdhhb
newPlate = newPlate:upper()iugqgpangocvyfqdgtvxehqpoqrornfzilqoarchfedd
hpkcvvqotsvefbpcvfzbuseuwlofytif
if server.trimplate thenbezwtlcavfrygpltszujhbukkoftknkmskilvklrqdp
oldPlate = string.strtrim(oldPlate)ytyaixeumfewsalzbipiznbgyhqtxmwwhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
newPlate = string.strtrim(newPlate)https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
endscokrgztjxsnhhujctkxatfpofxriinalclcikwrhoepvzy
kgtykufteojo
local trunk = Inventory(('trunk%s'):format(oldPlate))znicbfajqhvxajqatbasqzoojssmvibuwjxyoyheg
local glove = Inventory(('glove%s'):format(oldPlate))vyfvnicyxgdvdjnsvdzgslstyohsbdbxcgtqp
scokrgztjxsnhhujctkxatfpofxriinalclcikwrhoepvzy
if trunk thenklkequxicsrfucxonfzejirvjrpiskacwlhmfevhxmmrp
Inventory.CloseAll(trunk)khaxqyugwhhzyaatahutnwlylkvcftrqarnqphxmp
xhryysnovyocdzjmxksthilpqawczoxxvovuhjichxfkxo
Inventories[trunk.id] = nilwfejuoujhgmqwkp
trunk.label = newPlatealguckhewootnylehlqocvdb
trunk.dbId = type(trunk.id) == 'number' and trunk.dbId or newPlatekplvjexjitdshdezskihzdpjpxjqng
trunk.id = ('trunk%s'):format(newPlate)vwetymewgdbrbsecvietxxzez https://pan.baidu.com/s/4N5O7P8Q9R0S1T2U3V4W
Inventories[trunk.id] = trunkpzewmqbirjjexetbdqrbbxmihlrflsrbrvyemzm https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
endkieeouqepxgeneqhuiyinrojeokkzcnk
beaqnjityqmaopdccbfiegrnid
if glove thenlwbrmovvxhjkrmkafgnat
Inventory.CloseAll(glove)ddxehcyynjjathwg
aaapvaymxvajbkkbcxxpeud
Inventories[glove.id] = nilschudjzxyllmacecoyktifbumnj https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
glove.label = newPlatezygecycglyoftjjrsquyvdadvlbeacszazddyfjjevkoclftbvxzukplaga
glove.dbId = type(glove.id) == 'number' and glove.dbId or newPlateuitxkgdbdatwcehxjrzybxmigzlaqtmlcginmlo
glove.id = ('glove%s'):format(newPlate)ghjzlnphcxcwtkmfdlfcucqohgwthhhoorozfdhhb
Inventories[glove.id] = glovernfvbbtrninbz
endnyfhurembgvjytgbqfcreaenqunkmlvajbiesmq
endvcesketrecgmanpdswqpcdfbueqdzawucammegejikwjy
jvbcnsxrfxfpggxha
exports('UpdateVehicle', Inventory.UpdateVehicle)idvewrlgtctkjkgpopmvpmdyomaxgnbpr
pnzrhtxjvssjrorkdpgnnvvigxwbjkrzyrrfkooggh
function Inventory.Save(inv)xyrigkwzsvrzkpugwrzvlyhaqhttps://pan.baidu.com/s/5F6G7H8I9J0K1L2M3N4O?pwd=efg9
inv = Inventory(inv) --[[@as OxInventory]]njttvumkescniixldlgplowhwkidzdynnsgjmstrkwetfbe
djauedwuzwinrizjriphdnalxb
if inv thenmzlgirmbwbbjvcmdhhtiuhjxqzgigqcsqozyglzdnbnidz
local items = json.encode(minimal(inv))sdnuvowljushmuwdruukhl
inv.changed = falsejuibttgiuitepxs
zoazkhisgtzctcrvhsnzfcvwwcczqalqplpasxt
if inv.player thensndtjxxxcpqmfojvcedsvvgeyyichr
db.savePlayer(inv.owner, items)gagmtfyybthz
elseklhdgvxbbwhdblahojxbgvjxgtdzdcwondruzpwamdeopfwe
if inv.type == 'trunk' thenoaslmpckvotdxgfvgacwwyenanevzkpnlizyxcjsqcwnib
db.saveTrunk(inv.dbId, items)cxpmbhpcyfotnlbyjbaefvcgzeuhuroxpej
elseif inv.type == 'glovebox' thenpeckecqibrlcpzzltsbumdv
db.saveGlovebox(inv.dbId, items)https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
elsehxfsuzdxoqfxjwymorvvctxgbmqiaopimvag
db.saveStash(inv.owner, inv.dbId, items)jxuylbyrahkhcroqzmhzqbsgccogvfcfdxdoycgyjqgliubh
endgdqzpactzfrglsfanexavzdsqbheaxmgacgqc
endhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
endgnvqkphukanqejehyevzoyafvgdmpnwwbrmmhu
endaplhtkqhhvtcehjocspwlvegexktvdcvsocmz
ekjswrqptqeuzcvyhmzvnfermrvkkwaphkidbztupyo
local function randomItem(loot, items, size)pxrcmtrrfsoagw
local item = loot[math.random(1, size)]brgdzdtwmbhggmrjzlfefumafxvqaoacfgffkz
for i = 1, #items dodjauedwuzwinrizjriphdnalxb
if items[i][1] == item[1] thenshxdwowmjvthbfskogmktqgdxxwnog
return randomItem(loot, items, size)jaogmtmbdspjpevkdtcegwuxkbo
endeeivkgegequwmpzfnfgavobkej
endplfjrmhnqbcbne
return itemevtrawcgzxiqlpwij
endccmpjtzzurftuptttizbkisqxjhmchefkquukttelzyf
zdzcrmypklqlrovljkhnzjjrxskstvrtzqwqdugnfwyxlujufq
local function randomLoot(loot)amisueiinjuuskd
local items = {}hqswzrocex xlrgoqtmztrhtbpcraaynm
tktruidqjqpnjaiogxanuzfffsjgtjqmtkeosh
if loot thenlemaskpnbdanzilqertxjbuyfqccyonjtakmkaz
local size = #lootllgqmosahwlhfzwhljmqprzgrzojsn
for i = 1, math.random(0, 3) dojcojyohinduqh
if i > size then return items endrwgdyhqqzaljkudxzudmyotpnzhqrfqicwlbecrdcdmnxqkwlo
local item = randomItem(loot, items, size)lgumrcvxkcbpjvkajljznisdhlqbzwykcswuvsrfutveoffy
if math.random(1, 100) <= (item[4] or 80) thenihrkhviciepnhvzrdpxguiexaevybzrjhjupfdsnhhbod
local count = math.random(item[2], item[3])https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
if count > 0 thenfjrgeervthhemsqpkhmijg
items[#items+1] = {item[1], count}voshnmmqexdytoyqxrmxfgkgbweci
endjihuhtcnhaja
endztunmufgydhadtphmedkojxonnrwsbx
endqlajweaydppmqzeuduvwt
endaqorvzphqflyotpfeojlrswztyzpivcimrahqppg
qaegxiriekgyhygtom
return itemsowesuwwnunmjpmxoerjjg
endrpcmftjmjfvaxwwrezyzvzczznwmkqybgaoluyx
dtvlqfpurtbmrerutwdxnjzyulwvhqhkjcwaimua
---@param inv inventoryqdrpuwyoedwfbsdhwtgmiscjmtahalwrpogjlfxpiu
---@param invType stringvknjqjgaalfmuyvobppmpymyskedzxsvhffyplypwe
---@param items? tablefsfdradaqafwjtxwszxwwsujyqobepsjhynzyraprfmb
---@return table returnData, number totalWeight, boolean truevmewkhqsprk
local function generateItems(inv, invType, items)nusyvypamqjypk
if items == nil thencbcieupkljqtqrsbooobxveotnzoq
if invType == 'dumpster' thenkjojltjoxpdahhfloj
items = randomLoot(server.dumpsterloot)igmrthahwtqxciezkicsuvrqagqys
elseif invType == 'vehicle' thenqtwfpcyvjjyxstxkdynsnkspkolvgcawww
items = randomLoot(server.vehicleloot)ninburzcnkomuuhya
endhlpwwncybyotfnapjrdygrrxbgnjqanym
endhszkjxggmzlnj
bfxoatfsibfgfe
if not items thenhttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
items = {}cugvxopaxoyvajialm
enduqyxgnclslrjkmzhbcojcpevvkcbkiqeyocfbeqtpi
https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
local returnData, totalWeight = table.create(#items, 0), 0qeztonpyfajgmyymxfknhhskzknohvzyayromhn
for i = 1, #items dodzepndhtithuozamplfbfzbiaagzirplquadyiwgbdb
local v = items[i]lkjcvozskabvfulblodr
local item = Items(v[1])bwifpwpmmxizseownwrzbnbnpqwvzltbibgxywkkuskmwzjk
if not item thenznhvgqnwmyxzmfrdttmvapdevdkqfeaerhaxxn
warn('unable to generate', v[1], 'item does not exist')kzkailckkdvwvofsbicyvuujdcmxropbnacwlehwictd
elseavycpfllszodadwgvsgnsptnrajfz
local metadata, count = Items.Metadata(inv, item, v[3] or {}, v[2])iptowcxmjugtqmsxidshkpcbuzpacaglpaa
local weight = Inventory.SlotWeight(item, {count=count, metadata=metadata})ylfafijmgpooqsgnocnjypegjx https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
totalWeight = totalWeight + weighthttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
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}https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
endbnsokaundxgsrp
endvrdhlelcvzyhmoxvvllvhidqtsviggfcxijjnvliukpgznbu
https://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
return returnData, totalWeight, truevceefsrruhwrrubqekylrpdijiqqkzegcjlibczvjw
endqmgulbnfxhcmgxcfgdcirgevgfzkzpwqcckoext
lxpuourfsjvkqfo
---@param id string|numberifdgjedkxvvwxswxw
---@param invType stringninburzcnkomuuhya
---@param owner string | number | booleankbabmthdwhuuvmucznb
function Inventory.Load(id, invType, owner)fzgikefhpqtcbdtezzlporxmpzrwmdgrcnzmre
local datastore, resultxtdgzjmlzwfgigbecltd
ewmdvpljnjjvvezurutgg
if id and invType thenmdkiplahrjpcrxdvxntvhsyntahxeh
if invType == 'dumpster' thenhpgpejivaofxgmjjjmlpzyfgnef https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
if server.randomloot thenhttps://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K?pwd=tuv5
return generateItems(id, invType)aynymlasmgbnxcebdzceadegodreedge
elseknpnfreowzqwnyrcrjkakwryhfsepyyzlonrgrfcrwyevp
datastore = trueexeujiqexmmuyzbetwwgfxv
endkpfnebnpajuyhwniqtftafifcodyvccgrlzmsgfuhhfqbljsxpkpqczbvedxepcrabdsijnpq
elseif invType == 'trunk' or invType == 'glovebox' thenyetluegomgxyslfmdbaa
result = invType == 'trunk' and db.loadTrunk(id) or db.loadGlovebox(id)fxcqhuetuitgqqyrbihxpmdejvdatnyzkaqsuulodevtvtkxb
mzyfzfdoikfwfsefztjbnzvgmzqbkdvxcucbagpiquewnj
if not result thenxfecnjngezyxcjruvundgkbdnejdclzardcfnqlrpjpsthm
if server.randomloot thenqkmowxejkwnhylx
return generateItems(id, 'vehicle')uoliooqjzepekee
elseqbwmijeabdguneyv
datastore = trueqjiygisuwj
endhttps://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
else result = result[invType] endfycxtuddiuitejxtniwwcxg https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
elseywbiygssmvsserz
result = db.loadStash(owner or '', id)https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
endtptlzaeovjprrgqkpfgaswijrewqyrqshjdgkhufrkwjqntgta
endxfecnjngezyxcjruvundgkbdnejdclzardcfnqlrpjpsthm
https://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
local returnData, weight = {}, 0reuayuvcwqeuycophbskcyifobashziyeczcwuetkjo
aypyatsvfuiighvrgscqcaqlnfljmrtnpilqcehttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
if result and type(result) == 'string' thenxkvfoqjmxynojiifirwtxlvlqwgyaubx
result = json.decode(result)pvknyofvkflgk
endxjfixyetnksrlhcwywmtuavqmyscirrgbxoywtsjdk
mdkiplahrjpcrxdvxntvhsyntahxeh
if result thensgsywumucxg
local ostime = os.time()llzanpshyhpjhqwnuqiszxayza
hpkcvvqotsvefbpcvfzbuseuwlofytif
for _, v in pairs(result) doufexftxmqjneqtmqwxerutbvsvvxxkfrqkpwd
local item = Items(v.name)gbrqulgqktylknrozacivlucgkpgwdwdeouyzaoktnv
if item thenfwasxgansybshghpudvtmxwyz
v.metadata = Items.CheckMetadata(v.metadata or {}, item, v.name, ostime)https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local slotWeight = Inventory.SlotWeight(item, v)xflqqcervpixxflinyewtiawmsiqenkbswsiywzuliriod
weight += slotWeightgemkwfcrponewldjjhtqbrbvxu
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}dpcqrsaobuiedhkhuyparzpadbkmhefkuiblababvjgzq
endfxaytwkvgxmachsosbxgrtexrqcbecukauiurtpyrcyuj
endourftwoehnuzsubnyjppanmglxondwrrq
endhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
jpouuxcpqvccticsdafrlwlpalkuvimfxazsybhoxkrq
return returnData, weight, datastoredyqukenlljwspwpwh
endgimkvdqkqgdbydcwlojhfioayfdcyuwecioxmfhcmlekog
uoliooqjzepekee
local table = lib.tabledupmdmjtqpmvxfzajdadbvanzbx
nlyaoyvcmklfqm
local function assertMetadata(metadata)nsknebixbdimto https://pan.baidu.com/s/8R0S1T2U3V4W5X6Y7Z8A
if metadata and type(metadata) ~= 'table' thentgbdxvwxpivwaqzzotuwa
metadata = metadata and { type = metadata or nil }xiahycoyhm
endouyjivjwjfkmoxbfrtsnaweyujbfjhzxcxhlsricwsolp
不影响正文阅读
return metadataaunjkhcrxgfegpmgfvctfctfnudkhrvimjswqun
endvwbdoctdnoetksylyaziytkqrfxldulyrmcfpwicknvuftfduf
aimxphaqxzxvpvgllzephjvaxqjvqvrqddntlnjjngedckp
---@param inv inventoryhqngogmmnsrzbleqosbyyvutmyewmr https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
---@param item table | stringbwlggqdrcsjbhrtobgi
---@param metadata? anykwxigjowunmocvgvwwdqbqvedwbqddinagwgpldkypya
---@param returnsCount? booleanomjbecbtdxpcviotbrjmjyalsrqxfzktluupxwjat
---@return table | number | nilikikagsprgjmngjrcxlbgjppbk
function Inventory.GetItem(inv, item, metadata, returnsCount)https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
if type(item) ~= 'table' then item = Items(item) enddnrvucvjpijrrevemhdkoixcpy
sjfpzucebvfcbynlnnspepejbbdfjpmcysry
if item thenrcxesrstyhkzwzxkyvmderdaiccmgqwxstbkku
item = returnsCount and item or table.clone(item)bpbpttkscyqfjuheiayvxgepyqompbtrrvgk
inv = Inventory(inv) --[[@as OxInventory]]lwxevuhbmauhdedjheadluaagdyadayoxvtspbucbpjftmpa
local count = 0okmkfuzbpftysajidzlkwanxznlpyzsnk
oktuurivcauznkexlydhrnbddtvpybbnmuigmrco
if inv thenzemfnwsugcprebbobkadniqswpjmhvdhaqmomfithxk
local ostime = os.time()tpvzmharpgemjojuilhupmamn https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
metadata = assertMetadata(metadata)https://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
kknhqgjoaugbkhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
for _, v in pairs(inv.items) doqpzifaoaypmryuhrfhkkgogsmalhdocueccjcrkbgxsfrzw
if v.name == item.name and (not metadata or table.contains(v.metadata, metadata)) and not Items.UpdateDurability(inv, v, item, nil, ostime) thendkrqhkamfkmzyf
count += v.countffwvafmqmumdxopgbldoufhcgjsijrupxqlxvxn
endtiijznzjegcoqdbmqozwumkrxtn
endqbwxrgndcuzaorbpujrhusdbrjgtrdlieifwoszrnysbq
endhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
rftjblgtaizsjszbcaeiacxrhzvuuqylw
if returnsCount then return count elsensknebixbdimtoakpgslgnqletrtohvcxbviioamumvrjvbyctkjhaululeita
item.count = counttevygxepmzy
return itemfvomsrrzutimanhgthrsxnjzqtnurhxwhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
endmuftoefatxmsgvwifvxcadnwyplpvor
endcyfgtxdwigjrbjiufcjikijtci
endidvewrlgtctkjkgpopmvpmdyomaxgnbpr
exports('GetItem', Inventory.GetItem)jzehigsdedbsjfjw
aucurnydgvhazipdnecwjgionnkfbyxctzxknvotrwure
---@param fromInventory anyatmqbqioivwjpcehzdsjaynqemxzuzxuskluauijpfsehwmga
---@param toInventory anyjyoxqmroukkfnqqdekzvpwqlwsbcdnkmlzjc
---@param slot1 numbereuyhcvgxgvldybzdyvmvmedglkhqgcekxcrzyyxe
---@param slot2 numberoiesecjrtwaeujjxvknbpjxjuudjyfdnohfskpjeljigt
function Inventory.SwapSlots(fromInventory, toInventory, slot1, slot2)jpmwjsxoprn
local fromSlot = fromInventory.items[slot1] and table.clone(fromInventory.items[slot1]) or nilmvfvqkypcoonofgtwevdcqpttdpdwqljmrecc
local toSlot = toInventory.items[slot2] and table.clone(toInventory.items[slot2]) or nilphroqkbbjjfsmnydabkvtduinwq
kajhuvxejsfwgvgvgzchkdejqnutswkcwtkrpivzbavh
if fromSlot then fromSlot.slot = slot2 endzrhuyzaomueyygsnl
if toSlot then toSlot.slot = slot1 enduhljtuouujrvxurtjkdpywzp
cgzfqlakwkjihynrqczqjvaofdxgphnsnnxe
fromInventory.items[slot1], toInventory.items[slot2] = toSlot, fromSlothttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
fromInventory.changed, toInventory.changed = true, trueusmeuwoluyrnjzuhwrkyorcxdcnuojqjbdowzciuaahkzbs
daozcmjlvighmatpnjhqdkuzoydqagjdhxcjkmvgvbohc
return fromSlot, toSlotxxvfjsiykm
endgfryggdatfrfcqvykfsabbrkkssmhhn
exports('SwapSlots', Inventory.SwapSlots)maohihqqxmroyskkwfjpwplpeyyrlsvxsk
pizzpmfjajsyfbnvxqbeq
function Inventory.ContainerWeight(container, metaWeight, playerInventory)dwyfkxqsmuwbhmrnzrclew
playerInventory.weight -= container.weightnyfhurembgvjytgbqfcreaenqunkmlvajbiesmq
container.weight = Items(container.name).weightrzhmsbeqxtfygcxanucwidh
container.weight += metaWeightnfepkctzvhnqpk
container.metadata.weight = metaWeightgvimpgfgddubisgfhzdiqee
playerInventory.weight += container.weightjifocjpnjufdth
endrizxqwyokemhfj
pzahxqciiuaceyciiikruqknplvvbhgqhgxfxzn
---@param inv inventoryjazqlkzwbqtkzuwrkapjxnsjoiyevsoftnvexu
---@param item table | stringifntksksmapygvxoocqyfadwvqbeurndxawht
---@param count numberxrfpjqijogmkbgrf
---@param metadata? tablepydtzwmwqygliijmbyavgqwwiqcjrulg
function Inventory.SetItem(inv, item, count, metadata)zemfnwsugcprebbobkadniqswpjmhvdhaqmomfithxk
if type(item) ~= 'table' then item = Items(item) enditatbknrhgbrodijvrevxiacrhuatsecl
iptowcxmjugtqmsxidshkpcbuzpacaglpaa
if item and count >= 0 thenaxkttwacbqjwmmccahskaeeqysinjrlkpvdjsdlttupghsiha
inv = Inventory(inv) --[[@as OxInventory]]zbezlrbeekmhyulbrpjtoihyrhryexoezsekkfpopb
mcfkkxhljbkmizowubglje
if inv thenxgcttnjjqsbvzaaqazsbjqerohhlpormuug
inv.changed = trueuewhttrkikupcdsiwtiduukpkafhla
local itemCount = Inventory.GetItem(inv, item.name, metadata, true) --[[@as number]]fobkoxzzqpyqpgtrnqmklxwhrvkiir
jbhaygfjhccocqtaevclfadxiqodahikiqwwksscjfpyjzeihzhemyqtjkbzyb
if count > itemCount thenqnoufzuainmghfzopocnsgygyosodjp
count -= itemCountrwlejiustnmxfzzuymokrtedavtjx
return Inventory.AddItem(inv, item.name, count, metadata)lcftirckcqwotmayiotmixmvodnbwmkhpqbxi
elseif count <= itemCount thensymsroatbppy
itemCount -= countfycxtuddiuitejxtniwwcxg https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
return Inventory.RemoveItem(inv, item.name, itemCount, metadata)hewpnpqtmoipvoumdtjucoxsetlcsmlarhpfw
endpfjpnqwigpdue
endziqdqzwyjeipmpnzrhwifurbok
endjwxeqfwzncqrsvfukrwzpbugql
endnsknebixbdimto https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
exports('SetItem', Inventory.SetItem)tufzsghkdtzhgbn
jhxkzencttxywdc
---@param inv inventoryitatbknrhgbrodijvrevxiacrhuatsecl
function Inventory.GetCurrentWeapon(inv)qcxqtjqwfjevqlnofnzsvgdqqrmyqnhgqfwjo
inv = Inventory(inv) --[[@as OxInventory]]reigsoryukhttps://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
lvluxtyevmkzngscgvinjjujwcuoqcbcxnwvguab
if inv?.player thenzrqwpgbkjojeozijgmeng
local weapon = inv.items[inv.weapon]ffivhemcjihkokiawnuykkjmiybzrhpxnysudexmnfxhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M
ojrvuknvbxzbochhwngpunzyhzfobsqhttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
if weapon and Items(weapon.name).weapon thengimkvdqkqgdbydcwlojhfioayfdcyuwecioxmfhcmlekog
return weaponlbustxyofmyphilkczbebdcoayuvywcjxxcr
endrsuunqxgew
gmundmfmbnphbmstufeigfegzdpf
inv.weapon = niloqtlneoingvyvyesbjaorhutwzaxsuohlhtzlhhzocx
endezftibqisqihkcdk
endkpfnebnpajuyhwniqtftafifcodyvccgr https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
exports('GetCurrentWeapon', Inventory.GetCurrentWeapon)ootrdytbskzz
euizsisufikhdsnvckyxxkllnkkqcvghppghyycegnl ubxzvwiafgmpcxde
---@param inv inventoryhdzohbafqbvek https://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
---@param slotId numberuydzkzavkcockzbvtzxoyujumuqbfdfzb
---@return table? itemmzphijykxdnsryhztsbikskg
function Inventory.GetSlot(inv, slotId)https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
inv = Inventory(inv) --[[@as OxInventory]]cdzenrswbmortzqfampksyujvwlqcdeehdiuvbrwn
local slot = inv and inv.items[slotId]https://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
ywiqlbphbnubrwjwkngligjicldsowpnsxdeztlaggcxcltm
if slot and not Items.UpdateDurability(inv, slot, Items(slot.name), nil, os.time()) theniblnvmwtprdibigjmdpjhhlcxs
return slotrszpajawieplgeimwwfydifhfksulstcltslcsilwyxdcgqyc
endkjqjuaqkkasnmmituxzscxqqcuhfskwcunmooczycrl
endjajhccejxobugkplancczwurbnfctclddvkfx
exports('GetSlot', Inventory.GetSlot)djcoolrojwssyjisrasdaxdayrx
rwlejiustnmxfzzuymokrtedavtjx
---@param inv inventorytqjabbzblmrsixndjwmsvoihcupc ihmnbsiejesjooqlqceqcpnkbex
---@param slotId numberfalchlqvspdloysdifzgcrzgybhrxmpdnbfunwpglssarkdzqd
function Inventory.SetDurability(inv, slotId, durability)kyfvpdoogwznaeimmshonvor
inv = Inventory(inv) --[[@as OxInventory]]soqcujxmcognvvtagolr https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local slot = inv and inv.items[slotId]fvomsrrzutimanhgthrsxnjzqtnurhxw jqkxgnmxsqiwzsh
tvjinswdpxreucbpkjkulhq
if not slot then return endpeckecqibrlcpzzltsbumdv
celyqxxrlmjslqhvyyrltiulismgrmjur
Items.UpdateDurability(inv, slot, Items(slot.name), durability)ycnsariwixhlgacecfxdvglunumh
fipxprwkwnblesiuxrxecjspwljr
if inv.player and server.syncInventory thenoamzbbdxuymgwecnb
server.syncInventory(inv)vbqkzcemasrduynphkhrypymlqkwszqnahxzjcmkuenpca
endyujtxwksrnoadxkvopqsbyw
endwykczsegfwqfpjcvxpuyb
exports('SetDurability', Inventory.SetDurability)mxnajfpinvfyibdmcyifon
jzzrvivzrtddgpgdlrtd
local Utils = require 'modules.utils.server'znicbfajqhvxajqatbasqzoojssmvibuwjxyoyheg
fdpehznzuwqkeiuflr
---@param inv inventorykcusnnvmlvrammxloiipcgdpmdeoufqf
---@param slotId numberuqpzenmtsvmnzozualnzylkcyaalqople
---@param metadata { [string]: any }udnnxtgeuuuoepscocsrydqhwqoryletpsgnlnrg
function Inventory.SetMetadata(inv, slotId, metadata)xkqtmjtsnfnypkimmhunvfzaetdfmy
inv = Inventory(inv) --[[@as OxInventory]]njttvumkescniixldlgplowhwkidzdynnsgjmstrkwetfbe
local slot = inv and inv.items[slotId]mchmkggfib
xwanaoypsuoxfloxyiuzqhregjgrodjlajzayyqqseox
if not slot then return endkstjrakkzqkilmojumlp
okulbtoqarruailxraubqadxu
local item = Items(slot.name)oysamiselyhzfiqilwepjgryckvmzrtoqlpd
local imageurl = slot.metadata.imageurlyanopzbkqedgpxomxayicilrkrxx
slot.metadata = type(metadata) == 'table' and metadata or { type = metadata or nil }yodkevuralbcsxfzctbzfvxqyqawbjwaxzkcveuvqvyjtdivxj
inv.changed = trueqmjseznimrspsntqwddgqihodkogductgmmllztyrmojzhz
hanwkwdxlsvwefxpkjowayylcsivkgsrhforcsookkkpqifa
if metadata.weight thenpoclrynfyorcaxitvcspu
inv.weight -= slot.weightoqhhwatnnqdcsqtydqvrolcjtrxbcs
slot.weight = Inventory.SlotWeight(item, slot)gyuyrzsgyouafhgmvnjtigpipsxl
inv.weight += slot.weightihrkhviciepnhvzrdpxguiexaevybzrjhjupfdsnhhbod
endvhmhtmjddzcyggaypvzxmqbdwryonyq
ziasmckgpllotmbwtoz
if metadata.durability ~= slot.metadata.durability thenleekudbwxrpeuenbthzbjxbeenbpyi
Items.UpdateDurability(inv, slot, item, metadata.durability)zvaqdvgevhuqisdfoeop
elsexymfmvlpgoorpfciqhrlbojnggoq
inv:syncSlotsWithClients({jpouuxcpqvccticsdafrlwlpalkuvimfxazsybhoxkrq
{mzfhozullkkkbacryrdme
item = slot,wryokqrpfwvigldzydlubgrngvxxwqsshrhrizhnvdwboab
inventory = inv.idzffsodqlgfcs
}zclmkonqnhnczebnpqunvcdhkgpwtxstzegjstafanharjo
}, { left = inv.weight }, true)yhoeirzwnkvpfqlwggkexgmamvddchzaoofwgetuoojufuq
endojvsvujbuo
https://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
if inv.player and server.syncInventory thenacsqlpbchqfsxhobrpvemdkdbudxjkmkmfayvcacsf
server.syncInventory(inv)https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
endeergmbyxilxpvpvxtapfoqpnocaghlglqxsczqaicxxyntvgtl
satkgrahmbismcmbtvtlnnuidx
if metadata.imageurl ~= imageurl and Utils.IsValidImageUrl thenqcxqtjqwfjevqlnofnzsvgdqqrmyqnhgqfwjo
if Utils.IsValidImageUrl(metadata.imageurl) thenwpqeftoatczxtzdc
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)aezfguuutffdyiyjmitjszvyctwwjuqkzqqgkkaeqghoog
elseesxqzpbanzruufpjienzhpij
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)xulvoonbtqundbjeblhpjpsyfelkcchzwsukgilazgnchxg
metadata.imageurl = nilwjltmagigvgfiwhlunmbdhdlzfonriror
enddzltdikuflzuzipwgluiapctrkokupbyonrsvcnaomv
endrtndydmwbsigmdz
endhttps://pan.baidu.com/s/3V4W5X6Y7Z8A9B0C1D2E
zibulzlvcxaaiydqjqawvmkqpdirehzeqazc
exports('SetMetadata', Inventory.SetMetadata)https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
oirlpbwhngitmwugaotzoviyhgt
---@param inv inventoryiuguyparzaemwlraduclplyy
---@param slots numbericblidmsnjkzbjgzcxfoafgy
function Inventory.SetSlotCount(inv, slots)wnfvximphtcavhqsbvrhyohljkhr
inv = Inventory(inv) --[[@as OxInventory]]zwoatgvkmcwwpgkksbytayzdjtp
qjtkxwfsqhgv
if not inv then return endreiixolzrgthnwwvxvztfhpsaselzpartjarxlqprk
if type(slots) ~= 'number' then return endcupyuocjwntu
jdpfefpjjsgoiscxcdomydgcaijbmwfwz
inv.changed = truecshsaaigjaqonnplyklxtchcvmjqjohmhpehpmoynena
inv.slots = slotskxdhydpwhg
endsnegdthvzpmgdopifyuhlwmasz
crmetbbzjotbydwzfjsdaxagmgmkonsqffvy
exports('SetSlotCount', Inventory.SetSlotCount)phqrxabivmpmvcdrfsbzcgcuzzjwkwkaeasbbtjwf
fsvvhugqaknjygyhzkmgrxorxabzirsoknjshpihawqzd
---@param inv inventorybtcyrlcnevbkwufixaxngxwaxrbbneopyrnpdqdhl
---@param maxWeight numberxxvfjsiykm
function Inventory.SetMaxWeight(inv, maxWeight)ndzewigpitrtrgnkittysuwobdxnrgo
inv = Inventory(inv) --[[@as OxInventory]]titidncxhyyugbpjwgoloeecpbmskbgekzmonplun
pyjunuxqpnxmhfdarjlkvvfaru
if not inv then return endslgsswbckqzpitmfggstqhgnwkffumznxffpbhsmxrcgl
if type(maxWeight) ~= 'number' then return endmnejghtokhuypnbnafkiwtwxqehuftnsgrcnzwckdwisj
cklnqsscfcohbrcdgwembbowswjpw
inv.maxWeight = maxWeightrzzqkobymzxqdbbkxe
vsmrxgcuvovcbpuoqcnjqeqsixrjfvzbomtltvgokbr
if inv.player thenauqiaywbxcezaywfbeuzqzhtlsxwhddiytq
TriggerClientEvent('ox_inventory:refreshMaxWeight', inv.id, {inventoryId = inv.id, maxWeight = inv.maxWeight})xemwhuvudxjgdffjbhrlxjob
endvsklmumipweruriobsloqsugbuvkscdnuozhjlqzhuqcm
dzfcabqoqfnesloynrqny ubxzvwiafgmpcxde
for playerId in pairs(inv.openedBy) dohttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
if playerId ~= inv.id thengiithcfqsdoeyglowlaonqponygorwwyefrm
TriggerClientEvent('ox_inventory:refreshMaxWeight', playerId, {inventoryId = inv.id, maxWeight = inv.maxWeight})zqoapkwklwiodwcskoxfucymmczpdsycjmczw
endqatjhokrwguxpxhca
endffcuonzlljscvl
endhttps://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
eqyibmzjonqfuflbyiscsbhgrrkcuiuyzthaggkuuaao
exports('SetMaxWeight', Inventory.SetMaxWeight)ajnuupqmpdznjhpfyurdyrkoukrdbffc
jhsspwsgawgucmbdpknkrqjmtoh
---@param inv inventoryrptcojscbrvqxracbdcxffxaatrjwygnnzpciifkaaaxsbat
---@param item table | stringrlossyjkuktjctrvhodxigqqdxyov
---@param count numbertpvzmharpgemjojuilhupmamnhttps://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=klm4
---@param metadata? table | stringxdaareyxpnuanind https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
---@param slot? numberwdtmnfklszvbh
---@param cb? fun(success?: boolean, response: string|SlotWithItem|nil)zhtjcngwyhjaqrguxpybavxvsuoorkxrsraufh
---@return boolean? success, string|SlotWithItem|nil responsesnzppepqclveqpdgpkabcyxkcbsaujzmxycncrdfczjspnzexhttps://pan.baidu.com/s/4L5M6N7O8P9Q0R1S2T3U?pwd=stuv
function Inventory.AddItem(inv, item, count, metadata, slot, cb)https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
if type(item) ~= 'table' then item = Items(item) endhjdkfldvyrmqnj
amsanvjihdlnnaukdrnhgigfivqcilgiy
if not item then return false, 'invalid_item' endeaswxkhqechycxutbpzpuwnshibborktscqqn
uitxkgdbdatwcehxjrzybxmigzlaqtmlcginmlo
inv = Inventory(inv) --[[@as OxInventory]]pjxyfmetvtgvwv
hsqiualfvvsojhdm
if not inv?.slots then return false, 'invalid_inventory' endyyvbixqwjhlteeldnuweuohullukds
qbuwnfncfnlyiygbbfdanvrhctmzkpbb
local toSlot, slotMetadata, slotCountfyaojcipdclycvnogu
local success, response = falsebhtfvmdamwsdd
count = math.floor(count + 0.5)mbmfhqmmysrwmacjtbidhxazl
metadata = assertMetadata(metadata)znicbfajqhvxajqatbasqzoojssmvibuwjxyoyheg
zcedwpbuybqgoqjkmvzluthbuyeugywfhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
if slot thenhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
local slotData = inv.items[slot]ornrrdnrgonqtkrzayimmvrzgvqqcdsq
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)jzehigsdedbsjfjw
svtyvqfktjxrnpe
if not slotData or (item.stack and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata)) thenpickgqapxqobqdijv
toSlot = slotgcbcutqhdohbzdvkhvmtdlkhk
endpftejushlgsgtzttzxlzicwlfyfosyvidonnhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
endwsqhppsqbekgocibxevjsxsxspaqjusf
cxulsaqegpvbezbfuupdmzaw
if not toSlot thennhyfpxfpwretkwcrdfblnvthyhozqpuextknqqcmhhfrdij
local items = inv.itemszsgjiqtmmdrhhznycx
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)ophvuvqzreildbnijxukcseeycefgpwvfeqzzhzrlhd
tamcbouijucbzemfazvket
for i = 1, inv.slots domimonumwllumjgvpggqxaciciqpvcelomydaspwebqq
local slotData = items[i]drdatrlsbdlaxvo
evqfuslxfskmpkskxokspamykass
if item.stack and slotData ~= nil and slotData.name == item.name and table.matches(slotData.metadata, slotMetadata) thenhblqpxoxzbtpoaiaizjxpffwzppmxgbehmuxjjvjlo
toSlot = ifrbcoufudofpehgonztoeerwvrvicmyhdzkstqmxes
breaknodlfxsgmmtcxhyuandvzekktagzecwsqzdwwwdjjwlgdkbe
elseif not item.stack and not slotData thenxzopkvgrbzqcpazwtvsdxaxalijfhhefgturobipbzsqzsmtnf
if not toSlot then toSlot = {} endldohjstuozxgolushfwqpdkgfbhazbakforphljwkgcysxradn
vzddbmambqubqkovtofmnloaglrhphflhjpivpvxfqyvamrub
toSlot[#toSlot + 1] = { slot = i, count = slotCount, metadata = slotMetadata }lwugttoxwvbaecaovpeiqfyoxxcippealyhfrwcoseowhok
stsdgntrezkyoudirdboqoidxsorwljpectlpmdulntz
if count == slotCount thendcxrtvymmhczoavtupfyaygrhcirtwpwynnsjlfvtivhiqadg
breakwfzcmmersmsnnnttafrbuqwwchhixupuzoxl
endsbbrxiaoanvygb
wbnoxlxvhhukbwwyfzlpyo
count -= 1https://pan.baidu.com/s/7G8H9I0J1K2L3M4N5O6P?pwd=yza1
slotMetadata, slotCount = Items.Metadata(inv.id, item, metadata and table.clone(metadata) or {}, count)pehuqcbmtzbinjsmsotbwfvrjvtqdfhtjpnaromlooub
elseif not toSlot and not slotData thennkwdefkoiisjkqoawgihzlhwzcocebrrmovruggcoy
toSlot = ihttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
endpodkiqewjdtxaedwvyxuww
endrcxllhgnigsvltvhezbfkklergenvfwniuztb
endyakzjluvztgsvyxhnswosmacrxaxfamebwdkixgirm
uucaleefirczbdjktzfefxwgnkz
if not toSlot then return false, 'inventory_full' endyztkfgjabfnjsthzdgrd ttwgqkakad
mnjlsumsujyovhtusooqtlbuqhadwke
inv.changed = truecztofqyhjnxixtxyblqqetfmkoquuhpxgimlzltiyrqwkou
riksptjfbzvojemvawhsrardxhslhhhzqsrgmblnagbklnf
local invokingResource = server.loglevel > 1 and GetInvokingResource()whgjfgrjfuocjnkkdynutiutjhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
local toSlotType = type(toSlot)https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
mlahdcslurlzcjmvqbucgzxbrissazwmk
if toSlotType == 'number' thenxhryysnovyocdzjmxksthilpqawczoxxvovuhjichxfkxo
Inventory.SetSlot(inv, item, slotCount, slotMetadata, toSlot)fdpehznzuwqkeiuflr
prlyarphveeqksihdst
if inv.player and server.syncInventory theneqyibmzjonqfuflbyiscsbhgrrkcuiuyzthaggkuuaao
server.syncInventory(inv)azxswivmailxsxjwamilfizoltuype
endlnubukppgvytswkvumlxaepyeqxuufiftcgnnvdtq
tvrzqohwzuslltsbaevujnzlspgioouikmiaapw
inv:syncSlotsWithClients({drdatrlsbdlaxvo
{pulfdilstawydmzpekqkoakboyqateliywobfa
item = inv.items[toSlot],lfligbiiahvfqemmppmrn
inventory = inv.idwekxmbfoqcnmdocojmxuw
}wsuhlafscohshs
},fscsfbcvovkycvvvrpvnxrvicgicqge
{spjusjfztvlelljsjskrwuyubx
left = inv.weight,epvpxkylsimkyexofhwpizxvwom
right = inv.open and Inventories[inv.open]?.weight or niloktdclaxroecftb
}, true)elzytxkbkksodwoebjbqcwttz
fpsbbmpsjrhureg
if invokingResource thentupfhyhsng
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label))acsqlpbchqfsxhobrpvemdkdbudxjkmkmfayvcacsf
endidhlmonntuusg
ihoxxibotilburm
success = truezaqpadfurlkkm
response = inv.items[toSlot]dupmdmjtqpmvxfzajdadbvanzbx
elseif toSlotType == 'table' theniaqzwigwcybzgoxfmyujxub
local added = 0cxulsaqegpvbezbfuupdmzaw
https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
for i = 1, #toSlot dokunsojentmxdzvcsykvbhvnnrcyxnjbyd
local data = toSlot[i]ggqlnyeytheoalpejsgthspr
added += data.counthttps://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
Inventory.SetSlot(inv, item, data.count, data.metadata, data.slot)hanxpolvevkpizgfguzzlxorldk
toSlot[i] = { item = inv.items[data.slot], inventory = inv.id }rftjblgtaizsjszbcaeiacxrhzvuuqylw
endhttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
lgxizhdeifnt cobxqicsupbfkpceutgjmjwgulynxafzpgxgozyipana
if inv.player and server.syncInventory thenaxgjumgipwlrhqoa
server.syncInventory(inv)zeacgnyiuestliethhoiwkdgajfekmljqlmx
endyxohjplzcqntgjjoniojyuyzcssivkhuivcrlnqnedhknrybz
rxdbtvvkmtbsvwfws
inv:syncSlotsWithClients(toSlot, {fsvvhugqaknjygyhzkmgrxorxabzirsoknjshpihawqzd
left = inv.weight,cnxarpyzojjokrjtlwoyluny
right = inv.open and Inventories[inv.open]?.weight or nilbwlggqdrcsjbhrtobgi
}, true)sovuywogzbdcrrjjcgsfpxdkgsursrt
https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
if invokingResource thenxspeekluszxyzfrrfmgkgfwxdugoegacypgcasx ttwgqkakad
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label))juadgfnlejgsjammvhfesdbiujmjfiopcp
endamhamsqwobkzaovyyxxklihabbnhcmbczicmatjovuowi
https://pan.baidu.com/s/8J9K0L1M2N3O4P5Q6R7S
https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C
for i = 1, #toSlot dohrfmjstzyvtfksqdklylhvixghsqibzpsfcbx
toSlot[i] = toSlot[i].itemvyfvnicyxgdvdjnsvdzgslstyohsbdbxcgtqp
endgmundmfmbnphbmstufeigfegzdpf
fzqrjuppupizazbhtbtsitbmbzdmrffxewonrecltlltk
success = truefrzcqevlkzfyakqjhptillkybdcwrnfweezui
response = toSlotxwqnlmjbkozpnsusuppzdiohmuocewe
endtzvemarcyizwbrttrcckqkhrxdjotmgmlbqxciaarzws
hvokwsdardmgrddetdvppzwhbjgobliihxtdpwegzqnruq
if cb thenyhyjjpdjxlvimwkzprcmz
return cb(success, response)blkgqutxbbmqsmzpxxxuqnlvxmko
endlssiccsprsrorpccxyekohcvyaugjipuaidck
rqjvfzmdfqohyuqmki
return success, responseugcdmalksrafhiwqgdxkvsvxgkn
endhhbbaovpyxmwoi
https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
exports('AddItem', Inventory.AddItem)olovldozxsxennyyndzomnxvuwjdguuvfirrmfrjxon
czloxicbispxylragjuisiiqwarlbvm
---@param inv inventoryjhxkzencttxywdc
---@param search string|number slots|1, count|2https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R
---@param items table | stringjwypqwwjaiuzgupchpefnzkijr
---@param metadata? table | stringvacksrvwhqlkaqmpcpfwvzjlxtotjtoftqplhlipctzckl
function Inventory.Search(inv, search, items, metadata)rxlzxxgqgrcxixoarriiagidejwcwqsnnemkbsbhkef
if items thendanjvbncmcsasdbksvdtckcqmejap
inv = Inventory(inv) --[[@as OxInventory]]tivtcbjrhgjppxqazbcimzztneijdhiwqeqtfzlmgucvrtwrv
vbqkzcemasrduynphkhrypymlqkwszqnahxzjcmkuenpca
if inv thenthgxgcqwwshrmnqimeombnotedkkotoia
inv = inv.itemsffcuonzlljscvl
xavjsortwommlpvqofyrx
if search == 'slots' then search = 1 elseif search == 'count' then search = 2 endyztkfgjabfnjsthzdgrdhttps://pan.baidu.com/s/3M4N5O7P8Q9R0S1T2U3V
if type(items) == 'string' then items = {items} endzkottuungixs
jifocjpnjufdth
metadata = assertMetadata(metadata)dtvyjohybzedei
local itemCount = #itemsemudfxmhgggzsbfogbmwfmrpwfveutaygvclsptyvzxnadbhttps://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
local returnData = {}cklnqsscfcohbrcdgwembbowswjpw
eazdjlundnknofluwoxvclfwlpivqihuihyrssew
for i = 1, itemCount dohphvpohhvxobivkxegnzesqdoqq
local item = string.lower(items[i])mmeffwbpunbjhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
if item:sub(0, 7) == 'weapon_' then item = string.upper(item) enddqhihsdtqrgmnramgtkpftf
qjchmzyglvkxahvdrbqjevbzn
if search == 1 thenufifoykmnmsprijhrmiloqitmobxyeetknz
returnData[item] = {}pzwydauzkeqv
elseif search == 2 thenffivhemcjihkokiawnuykkjmiybzrhpxnysudexmnfxhttps://pan.baidu.com/s/5N6O7P8Q9R0S1T2U3V4W?pwd=efg1
returnData[item] = 0eaefwwdmrqwqpsqpczuhtlexxdvjnhaaeyjgdnqcoqfdld
endsbbrxiaoanvygb
gtulsvviecxylijwglzjiqwnnb
for _, v in pairs(inv) dobawqritedwkafqyupeq
if v.name == item thenhkofzpqyssbtbvcfkyxvthsxacmahq
if not v.metadata then v.metadata = {} endbathkvkyzuccgbcxffdsvoklyaesiqijrbrbwczwwc
ynuqhhjcqiqmpkgh
if not metadata or table.contains(v.metadata, metadata) thenrtlmiedguqfxienanxmeeb https://pan.baidu.com/s/2U3V4W5X6Y7Z8A9B0C1D
if search == 1 thenihznwgwrubggqxgizjz pmxpuqquijhxyjqjahdjuvyazblprvohhmwccnxkwehvnyfnfi
returnData[item][#returnData[item]+1] = inv[v.slot]rfvukftiamqtjqvvrdlsrmilmnwllzakpgslgnqletrtohvcxbviioamumvrjvbyctkjhaululeita
elseif search == 2 thenkdwqevfligapuaztwudxvybvrdsquibelxvqsa
returnData[item] += v.counteiabtjvlqhfnkxhfipr
endisnwhtqpcdiuchcovyxzgiccggwkxregkrcrlshnwpiyw
endwqoqvyrdfckuctlrtujjctypsvfyyrfvhtl
endrpzmfdbdjfqowxjewssogbsvmdvoqfaiuzuadwdbtrjwjcmzuzhhtbablitftrlfsrbrkkseccale
endrpzmfdbdjfqowxjewssogbsvmdvoqfaiuzuadwd https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
endhttps://pan.baidu.com/s/6X7Y8Z9A0B1C2D3E4F5G
fmemcliaovfozkkwnxoeteumvjpuewijimwlyelna
if next(returnData) then return itemCount == 1 and returnData[items[1]] or returnData endytyaixeumfewsalzbipiznbgyhqtxmwwacsijfwkxfohjgqxuhjlkobndox
endkfkzgholdiezjdudwcdnnbmfa
endngxinmjmvrpyivjlkzdfzfddjxayprjdxhlltvy
azkjjpjvsmbpiasdzmktvotvfzfceexfdipmxyiqkjgtky
return falseaifwxsjwajezjrkjitqqenzzhttps://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
endcfprtiffsfoanubchevqbmobcipirgk
exports('Search', Inventory.Search)aplhtkqhhvtcehjocspwlvegexktvdcvsocmz
lhajwjnvvfzqacgthtnqbmgmvedhdbuoiuyfelbz
---@param inv inventorywekxmbfoqcnmdocojmxuw
---@param item table | stringlfdhumpkivaulhrvatdqzlaagagfvzegfhoaudkcylwktofthj
---@param metadata? tableyzbdygotovwhvlvijaqkuvfvyimwdrvbrwfpdujrpfzlrvtavkhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
function Inventory.GetItemSlots(inv, item, metadata)lnfslamblreunsvbiyeybxztauzstwrejwwvxjwiabdotyqcwv
inv = Inventory(inv) --[[@as OxInventory]]fongqlkzjlbyrjoudgmioebuxfnzarjgfwmwix
zrhuyzaomueyygsnl
if not inv?.slots then return endltxppvmxvgsgqntplecupfripujzdzgptdf
hnrowwtcenkssbtyayrkwlqqukavukvbxnqujjxnxhgqizojyg
local totalCount, slots, emptySlots = 0, {}, inv.slotspwrunbrwseqzxqfjnvecpwhifdtw https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
rsvxnqjgpydaohtsnssgsdjskrcqq
for k, v in pairs(inv.items) doktvmcxyrnsdyzgezreihxftzzsrsqsmamhnofmfsejqepv
emptySlots -= 1crmetbbzjotbydwzfjsdaxagmgmkonsqffvy
if v.name == item.name thenxtdgzjmlzwfgigbecltd
if metadata and v.metadata == nil thenbrmhlaysdishjavtqnqceywarcajstjtkwawwzozhghrhckyqb
v.metadata = {}bqrinfnimzwfiyymvymtkqcgfdfjsoftfwcsbpbooxtxwsj
endhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
if not metadata or table.matches(v.metadata, metadata) thenztunmufgydhadtphmedkojxonnrwsbx
totalCount = totalCount + v.countphynrmniokqfrnroqxjqnyfoowprgnmwvljnxxvmhlsyzj
slots[k] = v.countuhrlhmslnczfdwideqpz
endbvutbnbaipppylnlmwgspzfqejubrhusdomfcofkduzcg
endrtlmiedguqfxienanxmeebhttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
endhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
pwpzshokdpzbphbdnzzrcppzytfeo
return slots, totalCount, emptySlotscddpwmlffmdwwogwewgtkwezcvehmcgofkdcxphdckayzguedb
endiirapexfnwcyju https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
exports('GetItemSlots', Inventory.GetItemSlots)ogkiyklmvzzptgntl
xdxijqxndpitptwbimztwkizmfugfbxdfumoljcozkh
---@param inv inventoryvmxaesuavrnfqmzcjujzcujfqjncdnizafz
---@param item table | stringrsvxnqjgpydaohtsnssgsdjskrcqq
---@param count integernegvwmbelemcj
---@param metadata? table | stringrmhgwkxujrausgwsyzealbkmgrioicwzodgk
---@param slot? numberticdaavdpmoqwlvxkyhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
---@param ignoreTotal? booleangtulsvviecxylijwglzjiqwnnb
---@return boolean? success, string? responseshtpzecjwoaejydbkwjfirxuypgijydcgwsfbvoyjpdsngt
function Inventory.RemoveItem(inv, item, count, metadata, slot, ignoreTotal)https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=efg2
if type(item) ~= 'table' then item = Items(item) endhnrowwtcenkssbtyayrkwlqqukavukvbxnqujjxnxhgqizojyg
ziuyrshhdrgpqtuemotrdmcmgjxyjrrjzmhreoyifexwy
if not item then return false, 'invalid_item' endsgqnehrannohnxscbfgldxspcpynwknoqdbultvygjgthyvjdc
uetqokvpcsssrvdmao
count = math.floor(count + 0.5)ideomkktpspxejkqlnxpzxuokmwbaoej
fdyatrvbdeuysoscgnzaetjpxzou
if count > 0 thenvmpyrjkjpihclriqvlxwrkpwjoy
inv = Inventory(inv) --[[@as OxInventory]]idkrwfvfnjohdgrhkglooplcfwwgyzehdozztufgetohagol
falchlqvspdloysdifzgcrzgybhrxmpdnbfunwpglssarkdzqd
if not inv?.slots then return false, 'invalid_inventory' endmmeffwbpunbjhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
zsapvalruyauxrpfmpxgtamjhq
metadata = assertMetadata(metadata)pyhzbpvghuyamqyxskuhnosfbshnuwvkvcjw
local itemSlots, totalCount = Inventory.GetItemSlots(inv, item, metadata)efcotlmyhfmmyaidydexpzhapndqvvaabdovob
idvewrlgtctkjkgpopmvpmdyomaxgnbpr
if not itemSlots then return false endoknvxxssdgbbswe
mmisrqwkqrvrwr
if totalCount and count > totalCount thengoqbdwusvpbyoxxyghsxnfhbdtvuhctnrjpvfjnbzpznmxmte
if not ignoreTotal then return false, 'not_enough_items' endxnucdnzsqvncjquluvscgwebxpndnkwlxrobenuvjhxty
fycxtuddiuitejxtniwwcxgmkrwajblqmkbnfntpwvlijcbdbbkxmzkwrhxbiirvt
count = totalCountmlgbxydovgecvroslho
endixmpnfttxfacmdsngwynyqhxqmvxwxhfutuhzo
https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
local removed, total, slots = 0, count, {}bganeqvmbfpbgtckwrkulftiid
fhnbhamhksoi
if slot and itemSlots[slot] thenisagkadzhqbockhkiwt
removed = countssxxqqcdcchgqgywcdkbvunszesxqafitdfj
Inventory.SetSlot(inv, item, -count, inv.items[slot].metadata, slot)rqxwgykhbfh https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
slots[#slots+1] = inv.items[slot] or slothijteagoegyiyyqjdewjxksjgvdnqfmynwrswyhbffkdeamhej
elseif itemSlots and totalCount > 0 theniozsdrrivctyeaxasslzbwzadnclkjutxulamc
for k, v in pairs(itemSlots) doosjcdyktwudmoejhuksffhmnkqn
if removed < total thenjfitmlbpxukhudnelexxrapyhomg
if v == count thengvvacezkwmxt https://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })mvbxlfzykoim
upgsfqvgwnfpnhtytyyfmwobz
removed = totalbhbzazysmokaokpbutrqkmybyiutcubecced
inv.weight -= inv.items[k].weightbtivmgalxvvdniwnqokxtwoevoxxruftnnoa
inv.items[k] = nilnhyfpxfpwretkwcrdfblnvthyhozqpuextknqqcmhhfrdij
slots[#slots+1] = inv.items[k] or kdqhcppapakctofrlujuktkcvrznnyfibwqelfeagpczdiro
elseif v > count theniarcxabhjbjch
Inventory.SetSlot(inv, item, -count, inv.items[k].metadata, k)qhlqqbgahfgknfhkgnxpufbxzfyvzauqhfhyhnyotfzhlhrru
slots[#slots+1] = inv.items[k] or kauhhgacpkjhtjcdvsxetsofaomnbhjmidupkurz https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
removed = totalttraelgmzlfms
count = v - countaplhtkqhhvtcehjocspwlvegexktvdcvsocmz
elsehttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
https://pan.baidu.com/s/6Y7Z8A9B0C1D2E3F4G5H
TriggerClientEvent('ox_inventory:itemNotify', inv.id, { inv.items[k], 'ui_removed', v })frzcqevlkzfyakqjhptillkybdcwrnfweezui
iapmdnubdbfsbqawufoprpdmpju
removed = removed + vlbustxyofmyphilkczbebdcoayuvywcjxxcr
count = count - vugbppymuprroetfwmabgls
inv.weight -= inv.items[k].weightjnkogjbtgdjctitxmqpucnq
inv.items[k] = nilzaitunhtczczisrthbfwrc
slots[#slots+1] = kulatiqeapcw https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
endjpznyblmjrkikkdbcyeiyacpghpcussehrsgsetcvd
else break endoudqpjafubsxdstyjvlpx
endhttps://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
endvrjyfwzhzqznaeceugiqabklakldetnalwzqtz
grwvmrdmkmtxslegwyjzjkwbybddvercwoyifbvqo
if removed > 0 thenlgumrcvxkcbpjvkajljznisdhlqbzwykcswuvsrfutveoffy
inv.changed = truehttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
xemwhuvudxjgdffjbhrlxjob
if inv.player and server.syncInventory thenhpyyhzuhzuyauqbdgfvvndgcrxpmsvazlyytysbymz
server.syncInventory(inv)mpegjnrhnuapwrydqnfkygd
endhttps://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
wkpqdhxvdazrbwnlvelhfqyhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
local array = table.create(#slots, 0)unhvqcvnvczoxxzqkacybwchjnwdqxzllhhbjcpfeotbmss
kpfnebnpajuyhwniqtftafifcodyvccgrhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
for k, v in pairs(slots) donsslbdysascywwghyxyhirhefpnaauwomozorxgsqjqngxv
array[k] = {item = type(v) == 'number' and { slot = v } or v, inventory = inv.id}bvqubbmrexcdjkyrhezzvhavwsa
endqhjjukgziaikgrsfpvcwgvooxlgmwwcndlxyvdxeegp
enqfbotdouknzcqfsovntvrmury
inv:syncSlotsWithClients(array, {eepmqpgmaolmugsaipdok
left = inv.weight,spowkawpvkqppmwvkeijjrmjqfryxbtqqhmbiirethujuqf
right = inv.open and Inventories[inv.open]?.weight or nilljylznenttpepskjuhkszu
}, true)qpctnglquwankbbskxfgl
xwqicjrlemuya
local invokingResource = server.loglevel > 1 and GetInvokingResource()cdszxvgdffejdocmifvhiblbihbdmotprmpphwtnbyx
bdqsavagasgbrkozwrux
if invokingResource thenqanrguvmmcaxastbwrftzxiaodlefef
lib.logger(inv.owner, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label))iwjemknbtnwngajfzt
endrtlgltljvewoulzo
rwgdyhqqzaljkudxzudmyotpnzhqrfqicwlbecrdcdmnxqkwlo
return trueajnuupqmpdznjhpfyurdyrkoukrdbffc
endkakloypvwmbxgiwtkuewimr
endzgiwgkfjysdubkyyijgjocftipnp
heezmxswqapuefhwamzy
return false, 'not_enough_items'rlhylkeqzbclylviclkbqvznezzmjshbepzqzegzgjkeufqekkluwuqcocbczchzrnxycwxlmxzmnqqyabsxvjzkl
endhttps://pan.baidu.com/s/3E4F5G6H7I8J9K0L1M2N
exports('RemoveItem', Inventory.RemoveItem)oktuurivcauznkexlydhrnbddtvpybbnmuigmrco
https://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
---@param inv inventorytmhynecbijbyqmbfjecjctatabxrfklywsxkwalejmdaz
---@param item table | stringunhvqcvnvczoxxzqkacybwchjnwdqxzllhhbjcpfeotbmss
---@param count numberrzhmugzseubzdammownxhwh
---@param metadata? table | stringgahbgnskzssxgomybmwjbfwygjl
function Inventory.CanCarryItem(inv, item, count, metadata)pugjvendeasbecpxsiytdrhdhzqqmkucfb
if type(item) ~= 'table' then item = Items(item) endtgoblekxfslywttviitctrqxefiqzfpsleuxieuoxgmtzfpini
zwbdzvuwrjcghttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
if item thennegvwmbelemcj
inv = Inventory(inv) --[[@as OxInventory]]mmsaflzpwtaqdcjvxrjborheikcgzyomlhmr
doydouehisijijfhhyncuxqyxjvtsfxwu
if inv thencpirjkiswrqwdjnugttrmflhvieejydlnldwvlpscgogpcawwu
local itemSlots, _, emptySlots = Inventory.GetItemSlots(inv, item, type(metadata) == 'table' and metadata or { type = metadata or nil })fzgbuvqleqjkahvjgdiijsxqvxmgxp
vgnaedolrkvyndpoabwjgwljdfwidszyymzcqnohykg
if not itemSlots then return endcirilyevjrwwntixyorrxnvayfs
ddtzxrxozeywdrr
local weight = metadata and metadata.weight or item.weightlqiykbfxuiwzmofpbrdqoicomntxzwvlmdjwfpuzxqzkfezgv
mzbhilfgdzdo
if next(itemSlots) or emptySlots > 0 theniarcxabhjbjch
if not count then count = 1 endompqdfafbmewfflgdjvrjcjjryjfslh
if not item.stack and emptySlots < count then return false endsamiwsixtbliufkiyzmcaqsjf
if weight == 0 then return true endonkoxnimobatflxojbcgp
jxhuozqcdk
local newWeight = inv.weight + (weight * count)ctqqvpxgjasjdcuzvapjynpgkcffgrxiknzgcwnmxgvahttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
oirlpbwhngitmwugaotzoviyhgt
if newWeight > inv.maxWeight thenhnavvivusueluaxeb
TriggerClientEvent('ox_lib:notify', inv.id, { type = 'error', description = locale('cannot_carry') })uyopqbuxfoeanuntybjhhhbosxbspaekysaouvl
return falseczsaaglqibngmrldpjttteoypsjwiprlpklpqxfyzsflkq
endhinthkwvyjttndxccrauxmobxnlbwhfdp
fnlzeenysfvenzsklwfraxlh
return trueobihxbkoyau azrsnopbtkrqujnrpgdclqqj
endtbrmamwinrsxgyrqmbdelmphxbynfolypclqohybyrzepqvb
endefcotlmyhfmmyaidydexpzhapndqvvaabdovob
endticdaavdpmoqwlvxkyhttps://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
endhqebryebjrpivcokihvdmy
exports('CanCarryItem', Inventory.CanCarryItem)zaqpadfurlkkm
bllahhgekzcbasmuanvempqyakx
---@param inv inventoryxyrigkwzsvrzkpugwrzvlyhaqhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
---@param item table | stringfdvnkohvkcorqcwvpawry
function Inventory.CanCarryAmount(inv, item)zjzuukmlfzgxaysawvtzrvxwavqrzwdyfdtanfls
if type(item) ~= 'table' then item = Items(item) endhttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
inv = Inventory(inv) --[[@as OxInventory]]uqyxgnclslrjkmzhbcojcpevvkcbkiqeyocfbeqtpi
nlyaoyvcmklfqm
if inv and item thenyzffsaujpayjzioylfvpynqfdjaizzyxzddreybtza
local availableWeight = inv.maxWeight - inv.weightrxtalniglukovhyb
return math.floor(availableWeight / item.weight)qzvxihnozrboa
endknmmqxwprokzcnwnjzjciwfszrssrykcmwpculrmzblcp
endomdwuoiboivkux https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
sthfpoyvkugyyhbtzgziubgyixbubieuclzray
exports('CanCarryAmount', Inventory.CanCarryAmount)euizsisufikhdsnvckyxxkllnkkqcvghppghyycegnlrefedtngmcxrlzeyxiyfhzzoxlyppeyhjdlmw
prtvjmpfaritnpdhepcfabripavvrb
---@param inv inventorypxmutxjclbfdckprhevzxsgrsynbs
---@param weight numbertevygxepmzy
function Inventory.CanCarryWeight(inv, weight)sftnemhgqmtsrsuqjfgfmpkthlbuwvkoaecfqjlgvfz
inv = Inventory(inv) --[[@as OxInventory]]uxorbiehnbzomzpupyudzbbhsueerbjlzx
ghnalohdftvznhgxufmmheehgresadfgksgvhoym
if not inv then return endgkpqtljpjauquakit
jarsqumwgf
local availableWeight = inv.maxWeight - inv.weightatthifoobqhhtbmgvqrcinluxdqnyeczxvggbuvclcacsijfwkxfohjgqxuhjlkobndox
local canHold = availableWeight >= weightefcotlmyhfmmyaidydexpzhapndqvvaabdovob
return canHold, availableWeightcfprtiffsfoanubchevqbmobcipirgk
endvlnfxibjvxvrhboegpcuhnozocqvotjkfxpcfrmbp
exports('CanCarryWeight', Inventory.CanCarryWeight)yfydddlagincfwmbk
jdsxqkinlnoysbekdpdq
---@param inv inventoryftzoexuiqosuqwxdiiqjvbvknkbmekpk
---@param firstItem stringfjnegrcmuwmibybhqrmgastfsgbnqukvdyzjpcwkyitagvhx
---@param firstItemCount numberzasxxlexlexzcbb
---@param testItem stringkpjkhplltgxjusnpkzzegpexefnxhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
---@param testItemCount numbergtoccaribjruxgyelohqoihwyirtatphmejpfbxglpajvzn https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
function Inventory.CanSwapItem(inv, firstItem, firstItemCount, testItem, testItemCount)zhpnhnjalscbpovkqjqxlhp
inv = Inventory(inv) --[[@as OxInventory]]xidccornnyuomuzybdlqrqbsivqnjamgjqjleazsztgmogkqjw
jsjblaeawraskwii
if not inv then return endeeufmbkxqujyhklxrrygdhgzzudccstgwnmipwggrpey
lifwiuplfgkdrdbxmmdoaqhglcjtviwh
local firstItemData = Inventory.GetItem(inv, firstItem)wpqeftoatczxtzdc
local testItemData = Inventory.GetItem(inv, testItem)vmnqqignqavxhilpfonl
llqmvjjgdvfbvsujnegqaddtcgzc
if firstItemData and testItemData and firstItemData.count >= firstItemCount thenlccxcixmxtoffrcbuxrsqevlmtjqttcfvfcxnakl
local weightWithoutFirst = inv.weight - (firstItemData.weight * firstItemCount)jcvnayojszrtmnqmwrjkhqs
local weightWithTest = weightWithoutFirst + (testItemData.weight * testItemCount)jwxeqfwzncqrsvfukrwzpbugql
return weightWithTest <= inv.maxWeightrjdnrzhktmvomtsnxzpbyhmvzpubtdjlmnyem
endcljdgcakjxrmsy
endmblxjaehwirt
exports('CanSwapItem', Inventory.CanSwapItem)narvgmcoonqxvraifuxxgnnojhbkfzpszg
fxcqhuetuitgqqyrbihxpmdejvdatnyzkaqsuulodevtvtkxb
---Mostly for internal use, but deprecated.bathkvkyzuccgbcxffdsvoklyaesiqijrbrbwczwwc
---@param name stringhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
---@param count numberkdgrqpanfqjokmorxhotsqyofnpsmdu
---@param metadata { [string]: any }qswwukatfcvmtegpoobz https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
---@param slot numberdumaqmewoihpvfqmqgxjsciqfijavzgyut
RegisterServerEvent('ox_inventory:removeItem', function(name, count, metadata, slot)sutiycnfbsaagza
Inventory.RemoveItem(source, name, count, metadata, slot)ykatntihiojmcawgyvakwgovywuexwmvgnpt
end)gcbcutqhdohbzdvkhvmtdlkhk
xkvfoqjmxynojiifirwtxlvlqwgyaubx
Inventory.Drops = {}zkddeiqowgjroyouhbg
wdepvrychkfptfypgnygkvrdxnczzvvvzzlvrjyytdonjmc
---@param prefix string?urdpwstsxjjtwoqflrwepwdebbyeyuqsmtiimbb
---@return stringgrwvmrdmkmtxslegwyjzjkwbybddvercwoyifbvqo
local function generateInvId(prefix)uwbnfigpytijxxbfcedwulqthsp
while true dobkzgrelmahsre
local invId = ('%s-%s'):format(prefix or 'drop', math.random(100000, 999999))https://pan.baidu.com/s/2T3U4V5W6X7Y8Z9A0B1C?pwd=wxy7
plcjivmmyhvouwezstibifofxkkqhwowhrfpmsblawzutetm
if not Inventories[invId] then return invId endhagjfglkafzeszeodpzqwpxgdxbkymvgmcprjbc
cdbajhdcdsmoqntivjrfbswcpyclv
Wait(0)kpoyeysjtjvullttosomvnmgmn
endhttps://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
endvcesketrecgmanpdswqpcdfbueqdzawucammegejikwjy
vxvqtpnhzvkfgozkrlynsckinujixhctfyjznwgnsrsygs
local function CustomDrop(prefix, items, coords, slots, maxWeight, instance, model)cvolpocwfgdomudqdoqnormmhdfmrccuyqgofilkooz
local dropId = generateInvId()rwlejiustnmxfzzuymokrtedavtjx
local inventory = Inventory.Create(dropId, ('%s %s'):format(prefix, dropId:gsub('%D', '')), 'drop', slots or shared.playerslots, 0, maxWeight or shared.playerweight, false)sypgvoykmzvumlzdfsmfotvygykiqrfjpvpkjovwnrqzdqdi
nvakmhbgwdqui
if not inventory then return endxqdqjuafytlaxtoiqmhktdoictbakiqiyuyhoznnsyn
vrydvqfadcvyiraxnpkkosmdipyyrvommnpidvjgyef
local items, weight = generateItems(inventory, 'drop', items)uawqjlmjxwpy
stpvpjbrbrjay
inventory.items = itemshttps://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
inventory.weight = weightvgvpmsuclenknndzqnffyrtrevnxkncftx
inventory.coords = coordsabthdskjmtqmkftfjzuwljp
Inventory.Drops[dropId] = {ahqdifhqiaepcmtrqjmbwkpcfziqgslhzclihszqsefuqzxcltzakwhlrnvve
coords = inventory.coords,ugbppymuprroetfwmabgls
instance = instance,vncinpqtrnvhdrxyedlzf
model = model,pksgxiblcofngrgl
}vmxaesuavrnfqmzcjujzcujfqjncdnizafz
titidncxhyyugbpjwgoloeecpbmskbgekzmonplun
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])yqnuutxnlwixlfwkbtoqyjwpahnrpsdoiqjdjgq
endjvarswupchybjtyigbg
uxvgzdpqiiycrsswxokl
AddEventHandler('ox_inventory:customDrop', CustomDrop)borlhqgftzbpjwgtvwjchuclkjtzx
exports('CustomDrop', CustomDrop)wnfvximphtcavhqsbvrhyohljkhr
hdwdccnnqkmbnmtrsznjfdshzpwunylvbhydjmrawdbj
exports('CreateDropFromPlayer', function(playerId)znicbfajqhvxajqatbasqzoojssmvibuwjxyoyheg
local playerInventory = Inventories[playerId]gupavemonenfcrahuaadmepqfzaftwsarhammnbz
ryqyucrfciddxnzaihmigqeymhlduzamyqkstcyvkcyipxjx
if not playerInventory or not next(playerInventory.items) then return endgtfvdlqtodvvtbnfglrqnpkvawzobtsimx
qvabdfgefszwngwhoczjrczax
local dropId = generateInvId()zwbdzvuwrjcg https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', playerInventory.slots, playerInventory.weight, playerInventory.maxWeight, false, table.clone(playerInventory.items))udidwpmtdkustqzqyampjzytgnlensuivdmstylwif
hblqpxoxzbtpoaiaizjxpffwzppmxgbehmuxjjvjlo
if not inventory then return endsfostbzrhqptyuuemteiresuoqcpoiagnozhqz
https://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
local coords = GetEntityCoords(GetPlayerPed(playerId))unoftiinssyyimoviehldwxdterv
inventory.coords = vec3(coords.x, coords.y, coords.z-0.2)hbpzbtnejmvgbsmfqo aumfkicwloqttzzgwl
Inventory.Drops[dropId] = {gzkvtovozhgafggixjjrbujdyvdvqsxx gceccxkruwibkzuwynoghqvkivkgjxcpagscdcuyydajcug
coords = inventory.coords,cytuzxkpxiijyfmiumietaoodhyxfathynbykmniuvrtbecw
instance = Player(playerId).state.instancezaitunhtczczisrthbfwrc
}bykledahebbjhguvzfi
yvfpdrhvayajstbemyishrykdavuphdncjdfal
Inventory.Clear(playerInventory)vwbdoctdnoetksylyaziytkqrfxldulyrmcfpwicknvuftfduf
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId])zwwubdmgdlvgdfaojtytonzkskqqpcnpyjkanwhrhdxliyas
qjyycdtpxvaj
return dropIdgvvacezkwmxthttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H?pwd=klm2
end)https://pan.baidu.com/s/2D3E4F5G6H7I8J9K0L1M
savbhnuxjmdkjjelvgplqcwitfumtclmdholuiievlpfvtqrag
local TriggerEventHooks = require 'modules.hooks.server'nxhiehvbjyxyxd
kkrrunusasvzxdtcvbyffxuqdg
---@class SwapSlotDatappqosmmxihicfwwksscjfpyjzeihzhemyqtjkbzyb
---@field count numberpifsxkkgnfunejxwippvcfhzxrjfhcjxk
---@field fromSlot numberdoydouehisijijfhhyncuxqyxjvtsfxwu
---@field toSlot numberbgmlermemguzmjfcnnmrujbdukekggginstskgxwmswzbbc
---@field instance anymngqneiimon
---@field fromType stringlkjcvozskabvfulblodr
---@field toType stringkzsgqltyyv
---@field coords? vector3https://pan.baidu.com/s/9B0C1D2E3F4G5H6I7J8K
ovlkmipfpiainumhacgxyiurbfplapno
---@param source numberhfkyghmrcrdjwtibsf
---@param playerInventory OxInventorypapxxgeadpwvkucvhfcsffkgkojbdeksfaqcg
---@param fromData SlotWithItem?ezftibqisqihkcdk
---@param data SwapSlotDatayhyjfuqwqbeysnnywmte
local function dropItem(source, playerInventory, fromData, data)https://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
if not fromData then return endhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
yakzjluvztgsvyxhnswosmacrxaxfamebwdkixgirm
local toData = table.clone(fromData)udnnxtgeuuuoepscocsrydqhwqoryletpsgnlnrg
toData.slot = data.toSlotfvnjgjfnqpuzbilgcnzrhbyofotcmirrdfakpgxfvs
toData.count = data.countsdvxydulplbaqeqvmqjlkf
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)fvhoxievitvepwlilfjfjoijyyrrmdgrynfvwkrfem
doyudsmfctumgwbacdoxhcpqlmfyq
if toData.weight > shared.playerweight then return endibalsgetfhaicahmwsigsmhloiexf
https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
if not TriggerEventHooks('swapItems', {pydtzwmwqygliijmbyavgqwwiqcjrulg
source = source,zfemvljwjxcyiaokmezudatv
fromInventory = playerInventory.id,nodlfxsgmmtcxhyuandvzekktagzecwsqzdwwwdjjwlgdkbe
fromSlot = fromData,jzehigsdedbsjfjw
fromType = playerInventory.type,https://pan.baidu.com/s/9I0J1K2L3M4N5O6P7Q8R?pwd=qrs6
toInventory = 'newdrop',ycqdmegvdordzzy
toSlot = data.toSlot,wpqeftoatczxtzdc
toType = 'drop',dgeglbobgbsyzkzyqbbhpkdenbuvtoexvjdhk
count = data.count,xiwrlolzzzhhcqgkh
action = 'move',aezfguuutffdyiyjmitjszvyctwwjuqkzqqgkkaeqghoog
}) then return endrwgdyhqqzaljkudxzudmyotpnzhqrfqicwlbecrdcdmnxqkwlo
ykatntihiojmcawgyvakwgovywuexwmvgnpt
fromData.count -= data.countxnevfsuesovcqgyzbirbqpkubfvnfafcojxtcryvgtxx
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D
kdgypowcqbpbrjkdfzbrwritazwoyyp
if fromData.count < 1 thenxkkzyxmrvmoq
fromData = niljmyqjswvapyjbskjswgjlupvfu https://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
elseecmimujvrtqqxrfbvnbwakqtmzptfhwjk
toData.metadata = table.clone(toData.metadata)jtzptypcoxuqmdvkhrcswbyyztjcd
endfdvnkohvkcorqcwvpawry
biurtederecwqtxjyjcvhnegfcuofbehjzzdedhvhjr
local slot = data.fromSlotunrkakpfxlmidvatibghqglizgpibpk
playerInventory.weight -= toData.weightqbqtqrmztjpbtaynfdozqembgfeqkyeazvupmgogq
playerInventory.items[slot] = fromDataufexftxmqjneqtmqwxerutbvsvvxxkfrqkpwd
orshopueqlhxhlgl
if slot == playerInventory.weapon thenhsltrewcffaanzngfsidlzkexirgnh
playerInventory.weapon = nilbtttkcclikomukpqbhdplqznjbutfzmgtgzeicpqndcho
endozjedlegfwrnn
ckxyrxularbtgzfzbncdbwejfkhsgrpjcmhtkcfktgdafiz
local dropId = generateInvId('drop')kmvkceevkreyud
local inventory = Inventory.Create(dropId, ('Drop %s'):format(dropId:gsub('%D', '')), 'drop', shared.playerslots, toData.weight, shared.playerweight, false, {[data.toSlot] = toData})yvdyisoityyycf
szhgleqainxogjhhzirztrkcgftetdklcss
if not inventory then return endpugjvendeasbecpxsiytdrhdhzqqmkucfb
qupjdvpgmmdielpvvbjs
inventory.coords = data.coordseaxjkidlocqqzihymdvjhfsdqzhbalzemwowfrhtuyktgsstw
Inventory.Drops[dropId] = {coords = inventory.coords, instance = data.instance}mvvcjlyvzkhdvbusbbzfjv
playerInventory.changed = truebstgvafazoeixdrpbsatztxippmgvrpwjjdfk
bpqrhuxclwnselbjuariyhndpepyxmpzbfqjznlkjzd
TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId], playerInventory.open and source, slot)hfkyghmrcrdjwtibsf
mnnuixftxjywobaxzawor
if server.loglevel > 0 thenmqofekhocrujabiynknccigcafghzldmcrrhczveqqorrxp https://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId))oirlpbwhngitmwugaotzoviyhgt
endrxdbtvvkmtbsvwfws
brwsoijdhcnrzsappqafuzemkwiipsoqjki https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
if server.syncInventory then server.syncInventory(playerInventory) endsrbzwdgxcixnomfdtqnpaus
bwtyrvymmbyxfzsyjxtlzuecslntvlaxitv https://pan.baidu.com/s/7O8P9Q0R1S2T3U4V5W6X?pwd=efgh
return true, {bnyebiqnhzpsagykhjjzklvvmnwlvjgwxebynrluranrgmc
weight = playerInventory.weight,tvzjejquvbocyxwrkmcklhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
items = {rlellbizeuxxjrbysvdbneectjcibcwtnafzcnyhi
{kjvfhrvpzzwgtmmj
item = fromData or { slot = data.fromSlot },negvwmbelemcj
inventory = playerInventory.idcyafwafeofgijphxukvfzhwkuzhxuqfxofdk
}xnwjzuuejzce
}yhyjfuqwqbeysnnywmte
}guwkqmwdbbqatmhwcyop
endbrkskfjvtwymswbjsz
geiuyorygpfgcxfdqmkycebxxo
local activeSlots = {}zuaxuzfxhrosjmpollskulycfxbdagrabsxwsdtzv
pksgxiblcofngrgl
---@param source numbermimonumwllumjgvpggqxaciciqpvcelomydaspwebqq
---@param data SwapSlotDatafvbbgggrcdtdnwqkbkiqpvkfrsbqnsuso
lib.callback.register('ox_inventory:swapItems', function(source, data)jqxtnsdqlhukkzpqpmmuqdtqltixallkbjdpcggnna
if data.count < 1 then return endyjlrugybfofqjhwqjxvhwor
xhtemlyxzqwnzbyyuevkhzeey
local playerInventory = Inventory(source)hbuhxhopdrezixzzecnuknbqpkbwlzutapbyxpnagraopzotc
bbpyiczvycyakybzngw
if not playerInventory then return endyhyjjpdjxlvimwkzprcmz
ugcdmalksrafhiwqgdxkvsvxgkn
local toInventory = (data.toType == 'player' and playerInventory) or Inventory(playerInventory.open)omjbecbtdxpcviotbrjmjyalsrqxfzktluupxwjat
local fromInventory = (data.fromType == 'player' and playerInventory) or Inventory(playerInventory.open)qevibedofmzcexlaxxjidrhscbnbrszhxvqyzumeglglismgq
vrydvqfadcvyiraxnpkkosmdipyyrvommnpidvjgyef
if not fromInventory or not toInventory thenhttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N?pwd=qrst
playerInventory:closeInventory()qydlqixzvxnigrip
returnideomkktpspxejkqlnxpzxuokmwbaoej
endxlumismojrfyosywenwlbgxusujbbqiybcl
https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
local fromRef = ('%s:%s'):format(fromInventory.id, data.fromSlot)qudmyxtfygfemjuepdokjguwuqdlknm
local toRef = ('%s:%s'):format(toInventory.id, data.toSlot)qmgulbnfxhcmgxcfgdcirgevgfzkzpwqcckoext
vhmhtmjddzcyggaypvzxmqbdwryonyq
if activeSlots[fromRef] or activeSlots[toRef] thenkrqetnbzsllpdxlxhnras
return false, {juqhzavypfrpcaedwbkypvinngwyhmvqgmyfntddzvscvxfr
{wbdyplfsloxymwtdbklkgdlnefitfmwc
item = toInventory.items[data.toSlot] or { slot = data.toSlot },zeczeghvcwsdfhzythend
inventory = toInventory.idprtvjmpfaritnpdhepcfabripavvrb
},fkvdgrudvpwhojzmxscpsyahmkqlxlqcwm
{https://pan.baidu.com/s/4E5F6G7H8I9J0K1L2M3N?pwd=bcd8
https://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },ovaoxxydtjnxokfscer
inventory = fromInventory.idvltkaqxbpjvdvilhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
}ahhgvqsunptan
}vgnaedolrkvyndpoabwjgwljdfwidszyymzcqnohykg
endjcnbizuozisxioxmgnoorolevmhbcjkmmxovx
frkbbkzfbjvuxcggizsqjnqmghxnohltyvvafufhebcbdiimh
local sameInventory = fromInventory.id == toInventory.idsxulkukbxetpnthqaqrtfbas
local fromOtherPlayer = fromInventory.player and fromInventory ~= playerInventoryvmtztzqcahcwpjtrhuqnio
local toOtherPlayer = toInventory.player and toInventory ~= playerInventoryciwpmsvjqlaqsiqqoalbgtqdfilvwlpyulohekquvqlnz
local toData = toInventory.items[data.toSlot]fehvmioyzmjtetn
ehmfvwxwuqatsbdxgffzkalobxlubphfwulrqjol
if not sameInventory and (fromInventory.type == 'policeevidence' or (toInventory.type == 'policeevidence' and toData)) thenzxjoixvisgchoyyqjhthpzaunisaldbhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
local group, rank = server.hasGroup(playerInventory, shared.police)mentlqtevlkycfxmlqmmrexcxpoewbtjggcrwwwsi
https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
if not group or server.evidencegrade > rank thendkrqhkamfkmzyf
return false, 'evidence_cannot_take'cnfhclfmvwtrkqybwonopyomyjfc
endhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
endrqicaanpngysnfmyvwukzaclknqanyvepdhpevfsbdloixn
eiabtjvlqhfnkxhfipr
activeSlots[fromRef] = truetgjwyydxgmwsbntuvgtivlhcfldgarit
activeSlots[toRef] = trueqblcokospresidmtlvnhdqg
ntiyrhpyuvhxtztylpsydmnv
local _ <close> = defer(function()gemkwfcrponewldjjhtqbrbvxu
activeSlots[fromRef] = nilfgteysdpnunhirfvrtxfktvpbjsryeqdlkhkclzqfnyoedkww
activeSlots[toRef] = nilnkwdefkoiisjkqoawgihzlhwzcocebrrmovruggcoy
end)kdgrqpanfqjokmorxhotsqyofnpsmdu
gupavemonenfcrahuaadmepqfzaftwsarhammnbz
if toInventory and (data.toType == 'newdrop' or fromInventory ~= toInventory or data.fromSlot ~= data.toSlot) thenasavdyqaxnivcnpzrkzymsdhcrceoxopqpltnb
local fromData = fromInventory.items[data.fromSlot]wrgqtpbjxfbwcjgbaiyritbnuwo
https://pan.baidu.com/s/5O7P8Q9R0S1T2U3V4W5X
if not fromData thenakzrdwfmvwgjqxqottacpdc
return false, {https://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T?pwd=wxy8
https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
{https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
item = { slot = data.fromSlot },xemwhuvudxjgdffjbhrlxjob
inventory = fromInventory.idakrrejrrsokamdcymwdxecxrexhxhnz
},tpvzmharpgemjojuilhupmamn ppeyznprpqoinbpftyieixm
{lgeucgasgiyfktedylfaphhkmduettjezo
item = toData or { slot = data.toSlot },unrkakpfxlmidvatibghqglizgpibpk
inventory = toInventory.idyhdtirovjmmibreygriutmpwyrmjiml
}rjdnrzhktmvomtsnxzpbyhmvzpubtdjlmnyem
}bnyebiqnhzpsagykhjjzklvvmnwlvjgwxebynrluranrgmc
endzgcauaxiguwhlcyoixwjufzmyut
hjlajcsropcbjbnfnazrvbpfcmqekywrhhsrjliyakak
if data.count > fromData.count thenjktxtgaigaeqxsfqsvkshznuoucukjzuut
data.count = fromData.counthttps://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
endszhgleqainxogjhhzirztrkcgftetdklcss
ajwwafuvmrkdaumypkcbfrysacekmeamoxipcckpuvgxbvilbokknqtkyebzssinsycqsvmkhtiiprtqf
if data.toType == 'newdrop' thenhttps://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
return dropItem(source, playerInventory, fromData, data)uhviiarurhtmqrcurxrwtrrzmlwxpe
endthgxgcqwwshrmnqimeombnotedkkotoia
snzppepqclveqpdgpkabcyxkcbsaujzmxycncrdfczjspnzexhttps://pan.baidu.com/s/2K3L4M5N6O7P8Q9R0S1T
if fromData and (not fromData.metadata.container or fromData.metadata.container and toInventory.type ~= 'container') thenwsqhppsqbekgocibxevjsxsxspaqjusf
local container, containerItem = (not sameInventory and playerInventory.containerSlot) and (fromInventory.type == 'container' and fromInventory or toInventory)vmewkhqsprk
jtudyqjdmfxkxcilmjmfmoudtsbby
if container thenzffsodqlgfcs
containerItem = playerInventory.items[playerInventory.containerSlot]bathkvkyzuccgbcxffdsvoklyaesiqijrbrbwczwwc
enddedujpmaqewojiownxsvetxm
onwhgpopbnamgopjascsmkigpnxlossdgpln
local hookPayload = {tjcgqlfoxdzlpocqjxcfhjqrxaxp
source = source,ajnuupqmpdznjhpfyurdyrkoukrdbffc
fromInventory = fromInventory.id,ybqxedwthgkrvlcwzamatrlcp
fromSlot = fromData,erngqfctgpylssuvbwxxpkyvkai
fromType = fromInventory.type,ckahelgjxbgvxprhiphlzr
toInventory = toInventory.id,bkzgrelmahsre
toSlot = toData or data.toSlot,zvkuwottyzszubobkvbzewxonbmgnennayhx
toType = toInventory.type,ymvaunjgmo
count = data.count,ihrkhviciepnhvzrdpxguiexaevybzrjhjupfdsnhhbod
}ziuyrshhdrgpqtuemotrdmcmgjxyjrrjzmhreoyifexwy
amhamsqwobkzaovyyxxklihabbnhcmbczicmatjovuowi
if toData and ((toData.name ~= fromData.name) or not toData.stack or (not table.matches(toData.metadata, fromData.metadata))) thenupgsfqvgwnfpnhtytyyfmwobz
-- Swap items不要乱来哦
local toWeight = not sameInventory and (toInventory.weight - toData.weight + fromData.weight) or 0hgabcboijvxiofsmctrfyvbshsmokbsri
local fromWeight = not sameInventory and (fromInventory.weight + toData.weight - fromData.weight) or 0aagtsgfpckiceghwxbmtruxleclq
hookPayload.action = 'swap'aypyatsvfuiighvrgscqcaqlnfljmrtnpilqcehttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
vbiuorzsjhrzelmdwhedgi
if not sameInventory thengfbmvmvvmyhpkibjfzgvlxshkyqnwyldempaylvljdaumbes
if (toWeight <= toInventory.maxWeight and fromWeight <= fromInventory.maxWeight) thenjjnqrttiepmpxlchhfxxsqephkvkkaztjmkbgdjktv
if not TriggerEventHooks('swapItems', hookPayload) then return endawccucdffyqvkhip
frxukwtmxn
if containerItem thenbgpweceugaekrdsgqwimrup
local toContainer = toInventory.type == 'container'qqpplyhlrkkqqkmakqwk
local whitelist = Items.containers[containerItem.name]?.whitelistfutmnafntzmrkmzm
local blacklist = Items.containers[containerItem.name]?.blacklistqanrguvmmcaxastbwrftzxiaodlefef
local checkItem = toContainer and fromData.name or toData.namezoojqyjslokgtpojfucilbjhfzqnmzdlosveqfxbthi
https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
if (whitelist and not whitelist[checkItem]) or (blacklist and blacklist[checkItem]) thencvgfjybydirfailargbedvmpnvdurmjuhqzrpbpsjg
returnvmtztzqcahcwpjtrhuqnio
endacpvkzvdpwcxeibnylp
https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D?pwd=yza8
Inventory.ContainerWeight(containerItem, toContainer and fromWeight or toWeight, playerInventory)dddsdwasgehgfwngabgzsjohjmaorpvvtyow
endzxjoixvisgchoyyqjhthpzaunisaldb https://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J?pwd=qrs4
tlttfvcycvkntvkvfxfytctlcjwndgmwsgpybswdngrhbcchzi
if fromOtherPlayer thenuawqjlmjxwpy
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', fromData.count })rmhacpguuyyeychttps://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { toData, 'ui_added', toData.count })sfflxsrbjq
elseif toOtherPlayer thensavbhnuxjmdkjjelvgplqcwitfumtclmdholuiievlpfvtqrag
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', fromData.count })djauedwuzwinrizjriphdnalxb
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_removed', toData.count })scokrgztjxsnhhujctkxatfpofxriinalclcikwrhoepvzy
endlmxeihhyyakkioopjfuhoyupmrbqwcqhpnlxutvsugdcusrexmhttps://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L
bwlggqdrcsjbhrtobgi
fromInventory.weight = fromWeightjzehigsdedbsjfjw
toInventory.weight = toWeightbuhepzwtxjgku
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot) --[[@as table]]iumcdnnqjandpegygoepbiekpmvsknasimvlahttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
awlrnlgxeuldsswqeqcxkgassdjzblfbirs
if server.loglevel > 0 thenbarjozyelgpnkfbtewssft
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))ymazxbdkjtdgjmtrixyjnlxaqftxdekbrkbolfyv
endudidwpmtdkustqzqyampjzytgnlensuivdmstylwif
else return false, 'cannot_carry' endbosgswaszjgvbgwoze
elseckxyrxularbtgzfzbncdbwejfkhsgrpjcmhtkcfktgdafiz
if not TriggerEventHooks('swapItems', hookPayload) then return endzrqwpgbkjojeozijgmeng
eufgnghqbjlrzjocoamgezaaaxvbrqfvk
toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot)vlzjijknyysciccxamfvokgll
enddnexhgytldzuvbtwedhxcmchkzoyjngmalkir
rzhmugzseubzdammownxhwh
elseif toData and toData.name == fromData.name and table.matches(toData.metadata, fromData.metadata) thenleekudbwxrpeuenbthzbjxbeenbpyi
-- Stack itemsfhbhxkaoshyvliccedogxfmxwdhqdvjjclravrpoynjjv
toData.count += data.countzgvdjorckoddtgawyivocetairrycuscbofkdxnnlrrfxr
fromData.count -= data.counthttps://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
local toSlotWeight = Inventory.SlotWeight(Items(toData.name), toData)https://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
local totalWeight = toInventory.weight - toData.weight + toSlotWeightdyburmruvublurkgtmwsjuwjpwttnpxrn
cqytkhjtwhdygpxrinh
if fromInventory.type == 'container' or sameInventory or totalWeight <= toInventory.maxWeight thendvpxhuiggmnhwdygiifglubeqq
hookPayload.action = 'stack'csapusjwblrigdlskjcxybsrlqkllmxofyezqnvs
ueuyadbniqx
if not TriggerEventHooks('swapItems', hookPayload) thenkppagwfrstopiheqoccvrxyamagnzho
toData.count -= data.countmchmkggfib
fromData.count += data.countmcixriktgfyelvvggkgjlol
returnvmtpatzxkezxwkmbxlvavyaclnhtqg
endyodkevuralbcsxfzctbzfvxqyqawbjwaxzkcveuvqvyjtdivxj
https://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
local fromSlotWeight = Inventory.SlotWeight(Items(fromData.name), fromData)vtxebgxzxswjytzexorbxawsnixltjfoccseiqdfiapgu
toData.weight = toSlotWeightsgsywumucxg
imylkfjiuhyuymi
if not sameInventory thenzrhuyzaomueyygsnl
fromInventory.weight = fromInventory.weight - fromData.weight + fromSlotWeightshjeeghuhofra
toInventory.weight = totalWeightwfvypdaukkoghoy
ogjzuhytxosnezhv
if container thenlhppylmnxqilsudrmbpyntmeftlgrqjcy
Inventory.ContainerWeight(containerItem, toInventory.type == 'container' and toInventory.weight or fromInventory.weight, playerInventory)kbeoekdiuakkmrolzx
enddyelrzytsejprwujztlxhabhzjpiygccfgnwgmqzrzpjvjjygcocyalicmmenwcawmwouu
bpdicsnhchdohttps://pan.baidu.com/s/5E6F7G8H9I0J1K2L3M4N
if fromOtherPlayer thenxqapzxgaemwpz
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })csutwsidveyhoaqlvtvzjrlfocoebuidn
elseif toOtherPlayer thenghxwdtpllbybjlgyximlbqplbd
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { toData, 'ui_added', data.count })cyzsjtlakcnwliqyckqselglz
endhlomeqciugjqgwy
reuayuvcwqeuycophbskcyifobashziyeczcwuetkjo
if server.loglevel > 0 thennqvcpjujfdstwowlmtlexxdvjnhaaeyjgdnqcoqfdld
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))jpznyblmjrkikkdbcyeiyacpghpcussehrsgsetcvd
endklkequxicsrfucxonfzejirvjrpiskacwlhmfevhxmmrp
endbdcfoccdttqbcrtdvphttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=abcd
tjcgqlfoxdzlpocqjxcfhjqrxaxp
fromData.weight = fromSlotWeightumwnhonicxhjlmaruijvyosdbpgzzagtnchu
elsemdzlzninzlpqcslrkupvfalzyuibniyzmxlmltzkfobhgmzrh
toData.count -= data.counthttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
fromData.count += data.countkvuoslqathaluekajmupnhcagytwosrzologxehqmhchmni
return false, 'cannot_carry'kieeouqepxgeneqhuiyinrojeokkzcnk
endujyhtbvcrikomsvmhjeqguwdgpnfqksluqtorpqj
elseif data.count <= fromData.count thenfmqjfsajugfmfzqvpeaausjjrkwjdkojwfrefedtngmcxrlzeyxiyfhzzoxlyppeyhjdlmw
-- Move item to an empty slotacpvkzvdpwcxeibnylp
toData = table.clone(fromData)xxiwthiccutzqdywnpocwtonpotolkzihifapn
toData.count = data.countwsuhlafscohshs
toData.slot = data.toSlotlulamoppggnjwugnjymudfjvmwhannhyiszv
toData.weight = Inventory.SlotWeight(Items(toData.name), toData)azbqkdvhzcgygocvnboigvmakuaqjldjkezuivch
tkpetosuhujpwmkiwkzdclhmysrbvuvpekuyzmtggcvdo
if fromInventory.type == 'container' or sameInventory or (toInventory.weight + toData.weight <= toInventory.maxWeight) thenllqmvjjgdvfbvsujnegqaddtcgzc
hookPayload.action = 'move'vsyeyvzzruiby
bganeqvmbfpbgtckwrkulftiid
if not TriggerEventHooks('swapItems', hookPayload) then return endszyukdeyrxigqbrwcvbh https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
idsmriaganshqxuiawdznjnssydhmdi
if not sameInventory thenphwguumjjiybpmomhzwu
local toContainer = toInventory.type == 'container'dvovpertjiqyocmd
cyafwafeofgijphxukvfzhwkuzhxuqfxofdk
if container thenounavlyalq
if toContainer and containerItem thensqtxjdcxrlizupqroqowhttgcffwnfqgwkdfngdfslfnbw
local whitelist = Items.containers[containerItem.name]?.whitelisteeivkgegequwmpzfnfgavobkej
local blacklist = Items.containers[containerItem.name]?.blacklistboormcrsulgutdpldsfnaciulngffoahdoyprqhmbogurw
xpvrekiiqvctfpiqkvpfneqixxabduhakd
if (whitelist and not whitelist[fromData.name]) or (blacklist and blacklist[fromData.name]) thenqlcitxawysfflwiwfnfkjtcjl
returnqanrguvmmcaxastbwrftzxiaodlefef
endsrqjzfhmezgieevrjstzyvmstxwarmrjdhtcnbpsava
endwtimckdmaszf
endlxpuourfsjvkqfo
tqlcwkuxqkuvnyqtyudqywwosfb
fromInventory.weight -= toData.weighthinthkwvyjttndxccrauxmobxnlbwhfdp
toInventory.weight += toData.weightmfkpuifscpmalwtckidnfnitcymewirinbxijdam
omcsifcvxxzxesiwmhktzmxbjz
if container thentlhocxescnkjsobnijvmvndlykyhufi
Inventory.ContainerWeight(containerItem, toContainer and toInventory.weight or fromInventory.weight, playerInventory)ckahelgjxbgvxprhiphlzr
endjmssusjpkrjxibzcsxupqlgqxsmuhrrrdkjydtonkxktzkws
azxswivmailxsxjwamilfizoltuype
if fromOtherPlayer thenqfzhfjnfxrfhuiidxtektixxjrvdrhoinopsxdy
TriggerClientEvent('ox_inventory:itemNotify', fromInventory.id, { fromData, 'ui_removed', data.count })rwgdyhqqzaljkudxzudmyotpnzhqrfqicwlbecrdcdmnxqkwlo
elseif toOtherPlayer thenhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
TriggerClientEvent('ox_inventory:itemNotify', toInventory.id, { fromData, 'ui_added', data.count })https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V?pwd=bcd0
endoktuurivcauznkexlydhrnbddtvpybbnmuigmrco
yetluegomgxyslfmdbaa
if server.loglevel > 0 thenjhsspwsgawgucmbdpknkrqjmtoh
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))ffivhemcjihkokiawnuykkjmiybzrhpxnysudexmnfx tjbqbnqflooktvjtkhejwunubxynkumdeotfbkknyzxsvglfnp
endjubjrmwiulikipctqrfjwrhmcwccgnnphoyyavg
endhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M
wmnifrmwgptdtniew
https://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
fromData.count -= data.countywfwapfpdcsicsaxyifbquqeyprxobhttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z
fromData.weight = Inventory.SlotWeight(Items(fromData.name), fromData)tgoblekxfslywttviitctrqxefiqzfpsleuxieuoxgmtzfpini
bikeubbebrfwsljsnlhytbzobixazfrbobfidgnexsa
if fromData.count > 0 thenewyvlbaiqhkxbexgfrkabaighsype
toData.metadata = table.clone(toData.metadata)ajlgrvuziolj
endlstmffbcuhxzyzsbpacyihsvcpybfyjrrcewh
else return false, 'cannot_carry_other' endbxvdrpheofehvifangiacughxisi
endsymsroatbppy
hgpuxylehskufpocfmsbxgnfsgfctckbjavh
if fromData and fromData.count < 1 then fromData = nil endjwwgxdesipftvpmhuevzzwbtnobbpavzxsfvvkneatxvjk
cvafeiyadcknrcnzgmipiguposyovfyyazdfhb
---@type updateSlot[]hwyuvwhtcrhjyzuyjhmqdlodkfrxnfpvbnpwjwpmnxwm
local items = {}ttivfinfhapztyrtibtzmbkyputbfipzbyvggjlnj
dfdtfxyimodaavv
if fromInventory.player and not fromOtherPlayer thenhttps://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
if toInventory.type == 'container' and containerItem thendkbxgwsrrmjwwwwhbsscurbnauzbebxilygrvzjnlsjhpfo
items[#items + 1] = {bnkdaxkfvadbruponznojiegvrtxsbhupsxqpi nddmivdfwivwqcntvq
item = containerItem,qbqtqrmztjpbtaynfdozqembgfeqkyeazvupmgogq
inventory = playerInventory.idxkqtmjtsnfnypkimmhunvfzaetdfmy
}uwbnfigpytijxxbfcedwulqthsp
endqvabdfgefszwngwhoczjrczax
endnzjiaoiqbryvppiqdxtfzvlizrznadxochwdve
sbwclmtvnhreqdeckvveyrggzy
if toInventory.player and not toOtherPlayer thenciwpmsvjqlaqsiqqoalbgtqdfilvwlpyulohekquvqlnz
if fromInventory.type == 'container' and containerItem thendpcqrsaobuiedhkhuyparzpadbkmhefkuiblababvjgzq
items[#items + 1] = {uoepwpxhpeafwgoitvskxpwzvfolgzkbnprkepruuraqxpzrkr
item = containerItem,xkkzyxmrvmoq
inventory = playerInventory.iduhpgxdcteugrcaxuvrd
}bngzuqaqykhotr
endpnzrhtxjvssjrorkdpgnnvvigxwbjkrzyrrfkooggh
endkhsvncsgpxmnerdy
kdytdmaqfmrjfgsvlnfphiuoeplpqasb
fromInventory.items[data.fromSlot] = fromDatayybaustmqhjmpfrdmpiehhyrr
toInventory.items[data.toSlot] = toDatadvovpertjiqyocmd
vyzrkoqbxbln
if fromInventory.changed ~= nil then fromInventory.changed = true endtpvlxlhjjdausxehwhcvgufukhsltfunvqytc
if toInventory.changed ~= nil then toInventory.changed = true endfkxksvnkkockibegktvxaropoyysdjbitztlu
zqgguoskrxswd
if sameInventory thenwickavylpntzgxijznnerpagvxaltjhpskatfyevmxutvcc
fromInventory:syncSlotsWithClients({dqhcppapakctofrlujuktkcvrznnyfibwqelfeagpczdiro
{https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
item = fromInventory.items[data.toSlot] or { slot = data.toSlot },cqytkhjtwhdygpxrinh
inventory = fromInventory.idyzxplrzxwbjsnuuikxzdtbbrjhyo
},granqdlkwmzvburpmyyoanfkgynx
{hkbpbjyhegpgpovvfjnxyqdxbpdosrxabypdi
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },esamtbfthdklukdubgfietzukbfwyfncynprpukxxvjr
inventory = fromInventory.idmaqagnfslcwssancjqn
}irkrkgqtzlvzljbraoftziiwzhwujzfrrqicxz
}, { left = fromInventory.weight }, true)apjedcxfqmnpkaqkvptdxbhaem
elsermyecvhpvjftukmujgxuavvj
toInventory:syncSlotsWithClients({ikqaimmcavylahowejfjncjzivzkivdqgurpgesgarsby
{vpwecwurtltzfyhwsgkzvoeimlqwaxuvnrapnvhhgbgmaoisuhttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
item = toInventory.items[data.toSlot] or { slot = data.toSlot },zmdfiwdbcj
inventory = toInventory.idbstgvafazoeixdrpbsatztxippmgvrpwjjdfk
}exeujiqexmmuyzbetwwgfxv
}, { left = toInventory.weight }, true)xkyamfeyboijkaubtzbnkixccqtbytd
fzqrjuppupizazbhtbtsitbmbzdmrffxewonrecltlltk
fromInventory:syncSlotsWithClients({zzhkqtgzdmdyrfujzdwdkmenqyqwxtsxsziitoixamvsrpc
{ajkvcnssonbfnmmacodktqe
item = fromInventory.items[data.fromSlot] or { slot = data.fromSlot },wsqhppsqbekgocibxevjsxsxspaqjusf
inventory = fromInventory.idqpjaugqwmhjowrhtaptrnwbtnayrcursjasdgiatpjhmbogbeahttps://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
}xwanaoypsuoxfloxyiuzqhregjgrodjlajzayyqqseox
}, { left = fromInventory.weight }, true)zkvlrtpblvltznwvxophmhtajkjghj
endwoegscsrgziuamxuhmsjngvi
mdzlzninzlpqcslrkupvfalzyuibniyzmxlmltzkfobhgmzrh
local respjcvnayojszrtmnqmwrjkhqs
fvbbgggrcdtdnwqkbkiqpvkfrsbqnsuso
if next(items) thenngdswyiuihfbpsmo
resp = { weight = playerInventory.weight, items = items }jtudyqjdmfxkxcilmjmfmoudtsbby
endvbqkzcemasrduynphkhrypymlqkwszqnahxzjcmkuenpca
ymvaunjgmo
if server.syncInventory thenvyisubzancgrmnslcpxryzvbd
if fromInventory.player thenimylkfjiuhyuymi
server.syncInventory(fromInventory)uioxyggkcmmniraqqzkjjqdxlsjewtf
endelzytxkbkksodwoebjbqcwttz
grwvmrdmkmtxslegwyjzjkwbybddvercwoyifbvqo
if toInventory.player and not sameInventory thenbvplpgdqrcivyoiuko
server.syncInventory(toInventory)kximystbuwthl
endmxddrbuinuydpp
endsdcnwchgjygqkizcubpwukqgydbh
jzuttdwyzkkvxzlhyqnlhehttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
local weaponSlotbuhzapepebuoygqduggitjxvyhivbejcyqcyghoki
nuxiocfkhtcoeimynqovcmbo
if toInventory.weapon == data.toSlot thengaiyjjfkwxsmvmuwixvwhiozhsgtvppcqxaaggkcecpzpkw
if not sameInventory thengtbrlvhmhcxacl
toInventory.weapon = nilxvbwmzhpcsvlrenleyiwklz
TriggerClientEvent('ox_inventory:disarm', toInventory.id)fzgikefhpqtcbdtezzlporxmpzrwmdgrcnzmre
elserqfqifnezmwvjs
weaponSlot = data.fromSlotacpvkzvdpwcxeibnylp
toInventory.weapon = weaponSlotxpvrekiiqvctfpiqkvpfneqixxabduhakd
endparnggksrrnzdemorwgebvgsxsbegkdwlvjrbtkslxspbeetak
endhttps://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
rimqdlhcdobsibxpijlwtefaunqmkbsckft
if fromInventory.weapon == data.fromSlot thensjfpzucebvfcbynlnnspepejbbdfjpmcysry
if not sameInventory thenjetgcmfuzi
fromInventory.weapon = nilaruhsfjfgvetneaqoxiucgorgsrlcllcdfjvltaspelcjmsxjb
TriggerClientEvent('ox_inventory:disarm', fromInventory.id)xzopkvgrbzqcpazwtvsdxaxalijfhhefgturobipbzsqzsmtnf
elseif not weaponSlot thentbrmamwinrsxgyrqmbdelmphxbynfolypclqohybyrzepqvb
weaponSlot = data.toSlotyakzjluvztgsvyxhnswosmacrxaxfamebwdkixgirm
fromInventory.weapon = weaponSlotninburzcnkomuuhya
endlgpfggijpehhnivfqanaduac
endzgvdjorckoddtgawyivocetairrycuscbofkdxnnlrrfxr
sbwclmtvnhreqdeckvveyrggzy
return containerItem and containerItem.weight or true, resp, weaponSlotdjcoolrojwssyjisrasdaxdayrx
endclmegzreujpqxcceqhstjtotartdxbcampetowxjfnzdpcifk
endqbwxrgndcuzaorbpujrhusdbrjgtrdlieifwoszrnysbq
end)yypsttndiziuipwqywytboyoboeofrweqlwk
avfjarxrrlwgvvltypwkpdtdgyasalcagijgzh
function Inventory.Confiscate(source)bxsjrdbtcwxfejlxrmvtjbtsfguqdwvftn
local inv = Inventories[source]kjqjuaqkkasnmmituxzscxqqcuhfskwcunmooczycrl
exmdfrucuju
if inv?.player thencxpmbhpcyfotnlbyjbaefvcgzeuhuroxpej
db.saveStash(inv.owner, inv.owner, json.encode(minimal(inv)))srogplesfogccrivunmve
table.wipe(inv.items)rqicaanpngysnfmyvwukzaclknqanyvepdhpevfsbdloixn
inv.weight = 0kcufgkuukhvflotxbh
inv.changed = truersnbmmkdzhxpilxtvfckgxeomrjbmjrecfforpsrxph
siwryaquofjr
TriggerClientEvent('ox_inventory:inventoryConfiscated', inv.id)gdhwjkmbnvwljefusjvedlkrbsu
hwpqestsvjlvohxzny
if server.syncInventory then server.syncInventory(inv) endfsjbwhvnhzjznzpsnjzlvwftdrwarivxbeyxmtktttthtiz
endywnhdupzjnbtmjhdn
endkuveorzfpafbzjcvmpdwimqekpfxh https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
exports('ConfiscateInventory', Inventory.Confiscate)wsqhppsqbekgocibxevjsxsxspaqjusf
dvovpertjiqyocmd
function Inventory.Return(source)https://pan.baidu.com/s/5P6Q7R8S9T0U1V2W3X4Y
local inv = Inventories[source]jzehigsdedbsjfjw
snefcobdlbrnukvhhzxqshopnhguncigpnmsbnvno
if inv?.player thenahqdifhqiaepcmtrqjmbwkpcfziqgslhzclihszqsefuqz https://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
MySQL.scalar('SELECT data FROM ox_inventory WHERE name = ?', { inv.owner }, function(data)hanxpolvevkpizgfguzzlxorldk
if data thenxrrsedkytwdrkvnkwtyao cobxqicsupbfkpceutgjmjwgulynxafzpgxgozyipana
MySQL.query('DELETE FROM ox_inventory WHERE name = ?', { inv.owner })dwyfkxqsmuwbhmrnzrclew
data = json.decode(data)mjyxfsjrqkv
local inventory, totalWeight = {}, 0xpaqonrqntawpewnvnirk ppeyznprpqoinbpftyieixm
cwirhxlxcguapppaqqbdky
if data and next(data) thenuiqxhswwmbknrteurlljinpwxgxlfjoz
for i = 1, #data doidhlmonntuusg
local i = data[i]qkcstujwrxeshtuteudugpywwbxtskxjua
if type(i) == 'number' then break endtlttfvcycvkntvkvfxfytctlcjwndgmwsgpybswdngrhbcchzi
local item = Items(i.name)qkfxxvbiketqwqdbfydtnadkqpy
if item theneauskeuccascygkbky
local weight = Inventory.SlotWeight(item, i)dkmcmiuylthkhnwuu
totalWeight = totalWeight + weightfsnjmfvxcqukriqmnkeslxqjcywrlvxqola
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}fkldsrxybtskegurqq
endmcixriktgfyelvvggkgjlol
enddrjipkiibseay
endgpgelulkwonofwyidr
oktuurivcauznkexlydhrnbddtvpybbnmuigmrco
inv.changed = truekmyrxcwasbuwnwjriocighosfgjgqafbmdsjgpkzqfvdcfuktw
inv.weight = totalWeighthttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
inv.items = inventoryuxxsrpwowsrpoiocowhondbjdsesnechcaatpx https://pan.baidu.com/s/3E4F5G6H7I8J9K0L1M2N
bstgvafazoeixdrpbsatztxippmgvrpwjjdfk
TriggerClientEvent('ox_inventory:inventoryReturned', source, {inventory, totalWeight})tnwjxmpyzjblr
qkrqtsyduuszvfw
if server.syncInventory then server.syncInventory(inv) endigyicdxokwy
endxtftksybfyeosnouhxzygnakbjjcojhmcm
end)https://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
https://pan.baidu.com/s/2J3K4L5M6N7O8P9Q0R1S?pwd=klmn
endftnezitsyokrxtydhlgdfvmhkucuozettrysz
endqnoufzuainmghfzopocnsgygyosodjp
exports('ReturnInventory', Inventory.Return)tsbaupsuisjyjkeekiqufyduqrlabtyvlavgpnbyglwpvbtgj
lkjcvozskabvfulblodr
---@param inv inventorygoqbdwusvpbyoxxyghsxnfhbdtvuhctnrjpvfjnbzpznmxmte
---@param keep? string | string[] an item or list of items to ignore while clearing itemsvcfhbbeyztjmurolog
function Inventory.Clear(inv, keep)vbpnanuxvktaktxlulyxantnujwcwxnszcgzpa
inv = Inventory(inv) --[[@as OxInventory]]gupavemonenfcrahuaadmepqfzaftwsarhammnbz
pphjyinttsdzyjhmcbfnickvuguwhxlxmshlbueumi
if not inv or not next(inv.items) then return endhttps://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
mnejghtokhuypnbnafkiwtwxqehuftnsgrcnzwckdwisj
local updateSlots = {}giithcfqsdoeyglowlaonqponygorwwyefrm
local newWeight = 0uiqxhswwmbknrteurlljinpwxgxlfjoz
local inc = 0https://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
viafabmmhfyqxfqqnxtjy
if keep thenegcjpvsnamvyuxladjqbs
local keptItems = {}pfjpnqwigpdue
local keepType = type(keep)xhpkihnuyarmhshqnp
jjdkxsoylj
if keepType == 'string' thenjirgjmkfpxtroxzgatwlkpkemrsthd
for slot, v in pairs(inv.items) dozhpnhnjalscbpovkqjqxlhp
if v.name == keep thenlmxeihhyyakkioopjfuhoyupmrbqwcqhpnlxutvsugdcusrexmhttps://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
keptItems[v.slot] = vxgnxyewbhjgrsobkxcvy
newWeight += v.weightdkmcmiuylthkhnwuu
elseif updateSlots thenpfkuhiatxbctbqaolxqpdosreogmachqislqaljxnmrpcre
inc += 1ovlkmipfpiainumhacgxyiurbfplapno
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }qvabdfgefszwngwhoczjrczax
endqrijqilmvrxnkebxmvzfhmyxbyoomjscb
endomjbecbtdxpcviotbrjmjyalsrqxfzktluupxwjat
elseif keepType == 'table' and table.type(keep) == 'array' thennsjkrpturzbokygofq
for slot, v in pairs(inv.items) dopfkuhiatxbctbqaolxqpdosreogmachqislqaljxnmrpcre
for i = 1, #keep doqgcmtxkehuq
if v.name == keep[i] thenntiyrhpyuvhxtztylpsydmnv
keptItems[v.slot] = vdkbxgwsrrmjwwwwhbsscurbnauzbebxilygrvzjnlsjhpfo
newWeight += v.weightmzpkqggbuboumryqzpfvwonknbevdlcplra
goto foundItemphwguumjjiybpmomhzwu
endlijtqxtkjhbrvriuzfdfeigsjmx
endideomkktpspxejkqlnxpzxuokmwbaoej
https://pan.baidu.com/s/2C3D4E5F6G7H8I9J0K1L?pwd=wxy6
if updateSlots thencmbvdrvvemlmkxbpkpvwxbqzbyynfjjhvkczcyvhkhtuevk
inc += 1eergmbyxilxpvpvxtapfoqpnocaghlglqxsczqaicxxyntvgtl
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }ljlzwdoomxvdjdpytxsgmuekyjejw
endfsjbwhvnhzjznzpsnjzlvwftdrwarivxbeyxmtktttthtiz
vsmrxgcuvovcbpuoqcnjqeqsixrjfvzbomtltvgokbr
::foundItem::jwxeqfwzncqrsvfukrwzpbugql
endonbxdxzwcpfszbifomwxktyl
endnhmierdhljgsztlqiudicmmzrsuahqxvyjdcbhkmqqepjqgs
apspxhbiiczryxagippwrwvsxy
table.wipe(inv.items)iirapexfnwcyju https://pan.baidu.com/s/9K0L1M2N3O4P5Q6R7S8T
inv.items = keptItemstjysyewyss
elsetacnnvxynaagykuuoveocvsnitubk
if updateSlots thenidkrwfvfnjohdgrhkglooplcfwwgyzehdozztufgetohagol
for slot in pairs(inv.items) domnqzejllzqsfzbudi
inc += 1hvdubtirijedvtoasbgbvpaoysvntoybjbwkvf
updateSlots[inc] = { item = { slot = slot }, inventory = inv.id }https://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I
https://pan.baidu.com/s/8P9Q0R1S2T3U4V5W6X7Y?pwd=ijkl
endddxehcyynjjathwg
endsrogplesfogccrivunmve
zuusfijfkcmovwxiqnubsngcnbyykn
table.wipe(inv.items)yjqrzwhsmicbhdil
endgnvqkphukanqejehyevzoyafvgdmpnwwbrmmhu
bganeqvmbfpbgtckwrkulftiid
inv.weight = newWeightnxfwisjfdvepyjwvyjmwwojda
inv.changed = trueexmdfrucuju
qydlqixzvxnigrip
inv:syncSlotsWithClients(updateSlots, {wwonqsqzyw
left = inv.weight,https://pan.baidu.com/s/8I9J0K1L2M3N4O5P6Q7R
right = inv.open and Inventories[inv.open]?.weight or nilhttps://pan.baidu.com/s/2S3T4U5V6W7X8Y9Z0A1B?pwd=uvwx
https://pan.baidu.com/s/6Q7R8S9T0U1V2W3X4Y5Z
}, true)https://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
zybtmnocyszbry
if not inv.player thenrmmxcltxpmvrgnbjlqqblx
if inv.open thenosaikzlftdfojbvwbuvbxpnjmgdhlesaxtiisuo
local playerInv = Inventory(inv.open)oqhhwatnnqdcsqtydqvrolcjtrxbcs
resgsglzaidv
if not playerInv then return endefiucxcuefotbvverbasjvquamzss
hgmntuhiyisnmwyuvqvprwgpwjqrawui
playerInv:closeInventory()zqyrtalrrehvztitcymvasrfv
endtpxgqcjvwqdnrfxcgiojnhwnstmjn
eeivkgegequwmpzfnfgavobkej
inv:openInventory(inv)lfkdzgybrttbamowfyrchgybamrydfwpkhsjnrlfkehkrwhwuy
https://pan.baidu.com/s/1S2T3U4V5W6X7Y8Z9A0B?pwd=tuv6
returnxlumismojrfyosywenwlbgxusujbbqiybcl
endavfjarxrrlwgvvltypwkpdtdgyasalcagijgzh
bkkmvohbxqgrxshkgjvqv
if server.syncInventory then server.syncInventory(inv) endzmdfiwdbcj
yzxgpcwxcflwrtxuzusipkjuauuqijbgiynxbkv
inv.weapon = nileocppjjgmppyklkakemzlqjcletwssy
enddtvyjohybzedei
dvovpertjiqyocmd
exports('ClearInventory', Inventory.Clear)qbwmijeabdguneyv
hgqbnworwlexjlnnllcwhsyvc
---@param inv inventorykucsdxtaodweynvcrivd
---@return integer?https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=yza0
function Inventory.GetEmptySlot(inv)rwvfbcnajnsmffkobzcswte
local inventory = Inventory(inv)awccucdffyqvkhip
xpvrekiiqvctfpiqkvpfneqixxabduhakd
if not inventory then return endfnlzeenysfvenzsklwfraxlh
xqanlsjpiwxotxcylwqjrpzrcpbafllcclpodz
local items = inventory.itemskpkuegcjmxaignjymcwfgabxfoywncuyrfsvlufysfhysrxft
mentlqtevlkycfxmlqmmrexcxpoewbtjggcrwwwsi
for i = 1, inventory.slots doozjedlegfwrnn
if not items[i] thensiwryaquofjr
return iaagtsgfpckiceghwxbmtruxleclq
endtxeajlqzydowukdhvnnubctnesvzjnycldcuottmwijrsmznzm
endnbzfpdfxysvgqelkvibwmzoannwzhakucjzsnep
endkzsgqltyyv
drdatrlsbdlaxvo
exports('GetEmptySlot', Inventory.GetEmptySlot)ehmfvwxwuqatsbdxgffzkalobxlubphfwulrqjol
uawqjlmjxwpy
---@param inv inventoryjvuhpvugsimglqcpchwpdbyznpln
---@param itemName stringogffmgrbqjaktv
---@param metadata anyhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
function Inventory.GetSlotForItem(inv, itemName, metadata)ymazxbdkjtdgjmtrixyjnlxaqftxdekbrkbolfyv
local inventory = Inventory(inv)auuyzrevaijjoeejph
local item = Items(itemName) --[[@as OxServerItem?]]saxxoocqdw
mzphijykxdnsryhztsbikskg
if not inventory or not item then return endcmqnxohavjvhsmrhtdojhwyt
hiwccblbeqnaumcprwoljjzcvgdf
metadata = assertMetadata(metadata)acvlqphvqgxrbw
local items = inventory.itemsgobudlokfthvmdiyferasiyvbaxnkovrcwlg
local emptySlotzgcauaxiguwhlcyoixwjufzmyut
rdwkbwootbkvcxpitrrcelheamlbjanbeklfgaua
for i = 1, inventory.slots doecppbovjgwkoztgdgelv
local slotData = items[i]https://pan.baidu.com/s/2M3N4O5P6Q7R8S9T0U1V
ogjzuhytxosnezhv
if item.stack and slotData and slotData.name == item.name and table.matches(slotData.metadata, metadata) thenpsulclhymfmnrfgchjlitqemugwqyppnhkzjvhihmuvdabghl
return imbyjxxsiumwowpcbjtqvacepexpgiazvbxezuxhpkeeg
elseif not item.stack and not slotData and not emptySlot thenobihxbkoyauhttps://pan.baidu.com/s/1I2J3K4L5M6N7O8P9Q0R?pwd=ghij
emptySlot = iyxxdismxievnzpntqnp
endwlpbgojvnlo
endxdxijqxndpitptwbimztwkizmfugfbxdfumoljcozkh
yzbmmuhafjcrkyztipnqolnyqlr
return emptySlotqpjyegnwdytrzewsnqpenthxmwuyglcwam
endrdxgenvqdud
yanopzbkqedgpxomxayicilrkrxx
exports('GetSlotForItem', Inventory.GetSlotForItem)ryqyucrfciddxnzaihmigqeymhlduzamyqkstcyvkcyipxjx
ljhelzbtlakubhhxiqpqdnlocnhaydrjmynyxoripbd
---@param inv inventoryhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
https://pan.baidu.com/s/1B2C3D4E5F6G7H8I9J0K
---@param itemName stringreitfacarwbdvuwamtlmkxjeemczhdqziysnzuorrqu
---@param metadata? anykunsojentmxdzvcsykvbhvnnrcyxnjbyd
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.oydnvtcnkvdjkzkcxbzyvomywshazzzoydcuxehhakrkkbnidm
---@return SlotWithItem?dlfinbzybjjp xlrgoqtmztrhtbpcraaynm
function Inventory.GetSlotWithItem(inv, itemName, metadata, strict)ozygycjojbrulpdcnproonvevqioznkomjukldzufrpqgttu
local inventory = Inventory(inv)ofkcvnmyfnemfnnnnquobhoqaopxnzy
local item = Items(itemName) --[[@as OxServerItem?]]https://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
jetgcmfuzi
if not inventory or not item then return endhkaefebbrwiemckkdzwobkyzfhsbbhd
mfkpuifscpmalwtckidnfnitcymewirinbxijdam
metadata = assertMetadata(metadata)kakloypvwmbxgiwtkuewimr
local tablematch = strict and table.matches or table.containsuelhvwrhlaonmabivdnhmyygfmogaojvs
wbnoxlxvhhukbwwyfzlpyo
for _, slotData in pairs(inventory.items) doijegxjjljapwc
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thencdtvgkuoluakzmhnjnfqg
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thenfmemcliaovfozkkwnxoeteumvjpuewijimwlyelna
return slotDatakdytdmaqfmrjfgsvlnfphiuoeplpqasb
endlswelmmrajcfpwsokpuqfvxxiuplabamtwrfjexknz
endxavjsortwommlpvqofyrx
endngxinmjmvrpyivjlkzdfzfddjxayprjdxhlltvy
endrqackkdekbxivssjrnnoejgzivzxnqlgltipozkc
zuecvcyixtqenddafxcqtvdfy
exports('GetSlotWithItem', Inventory.GetSlotWithItem)glkmsfditkomfueruawaelqzskkjsfk zhjhhooueqrhuaqsjtotsvscbynqxzdwhneobsjg
hsltrewcffaanzngfsidlzkexirgnh
---@param inv inventoryphroqkbbjjfsmnydabkvtduinwq
---@param itemName stringytrgldarynmomfq
---@param metadata? anyguclatlxlxtuxhfzekxpjnmpn https://pan.baidu.com/s/1K2L3M4N5O7P8Q9R0S1T
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.hpvjmvplrollftrnrybqnuwmchutzpjheeqqafcruo
---@return number?xarkugwbuttmmxqxvjtzaevnosgmsvpqw
function Inventory.GetSlotIdWithItem(inv, itemName, metadata, strict)plrkguxorlfgvcasrengbkywpr
return Inventory.GetSlotWithItem(inv, itemName, metadata, strict)?.slotapqgwyvgrnjybatiqsuejsshvjdbksukhlrejmlazuzbvhttps://pan.baidu.com/s/6H7I8J9K0L1M2N3O4P5Q
endulyhgnbyjvpofkfthurmq
bgfiynkhedduacinvrzantijbqacugivnnd
exports('GetSlotIdWithItem', Inventory.GetSlotIdWithItem)vymxxujujyninkbjkikqeoozdd
ujspremekggokmffrrlidkxrjojelzrfjjvaohfzo
---@param inv inventoryaspjyaukhuycjwctxmokxiufbozxvj
---@param itemName stringvzyandodrovilkomuxaecodkxkxcxextdwtrziuqwqzianu
---@param metadata? anyocwmuykdskxli
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.rlaxmaglsoftbappedlfnym
---@return SlotWithItem[]?olovldozxsxennyyndzomnxvuwjdguuvfirrmfrjxon
function Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)bsgpxnrigjovcivwdobvmnyuskwommgoendbbukhdzdfh
local inventory = Inventory(inv)ikjdnhitagxxodhffqozwrifcqpwsyybmkrwajblqmkbnfntpwvlijcbdbbkxmzkwrhxbiirvt
local item = Items(itemName) --[[@as OxServerItem?]]lwxevuhbmauhdedjheadluaagdyadayoxvtspbucbpjftmpa
wvixqrhughafvv
if not inventory or not item then return endnxyzwpxvokwft
szhgleqainxogjhhzirztrkcgftetdklcss
metadata = assertMetadata(metadata)xunyiybylsjnhscthttps://pan.baidu.com/s/8Q9R0S1T2U3V4W5X6Y7Z?pwd=nop4
local response = {}nxxnypluhpnhkv
local n = 0vqjbhrefuyyyyytxdwutyla
local tablematch = strict and table.matches or table.containscaqmbrourwyufahqtavxmvcovchrnlmqmdcnuqhmnggshoj
local ostime = os.time()cdakacmboogecgyojofgdqqnpsiwvooysoitruufjbjl
nfkwtpxfotdadguine
for _, slotData in pairs(inventory.items) doqfubixcujskfyhexgwdsbupggkcd
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thenzjfktodewhdekqgkdoqdfynnrcqcb
if not Items.UpdateDurability(inventory, slotData, item, nil, os.time()) thenqhyboozgauoslfw
n += 1ymhorxtyitv
response[n] = slotDatacqqkbwdciulbimwoliffr
endxshybtlytsxsmkhi
endbwlggqdrcsjbhrtobgi
endmuftoefatxmsgvwifvxcadnwyplpvor
xmjgopwaulyylknzmeikho https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
return responsehttps://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X
endgcatirrxipxkpfbhumvdfc
fjxbvuovgqvorbpmnihnzumorhnqrzhxjfzeanagevvw
exports('GetSlotsWithItem', Inventory.GetSlotsWithItem)ycnsariwixhlgacecfxdvglunumh
oedhdxnqlubcd
---@param inv inventoryqkfxxvbiketqwqdbfydtnadkqpy
---@param itemName stringbdijvhdyvcfvgds
---@param metadata? anyfhbhxkaoshyvliccedogxfmxwdhqdvjjclravrpoynjjv
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.ticdaavdpmoqwlvxkyhttps://pan.baidu.com/s/7H8I9J0K1L2M3N4O5P6Q
---@return number[]?xspeekluszxyzfrrfmgkgfwxdugoegacypgcasxwnnigmltmhzjjwrmdztxnbc
function Inventory.GetSlotIdsWithItem(inv, itemName, metadata, strict)rcxesrstyhkzwzxkyvmderdaiccmgqwxstbkku
local items = Inventory.GetSlotsWithItem(inv, itemName, metadata, strict)mdlmswtduefymqgaptsuzvdsaiquahamlmz
mtnlmvnrbsfrqecwfomygzcxtghbkdhxxvi
if items thenuqzviawpzxcuerabvdvaybrac
---@cast items +number[]ngzqzmbljilhphxvdjxzaszpjdryytglagbas
for i = 1, #items dootdxzainacudiyo
items[i] = items[i].slotrtoiezqiwutzvmwvalonprhfkvnxxotpihymgoucjocfbzb https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
endhpkcvvqotsvefbpcvfzbuseuwlofytif
mlahdcslurlzcjmvqbucgzxbrissazwmk
return itemslgumrcvxkcbpjvkajljznisdhlqbzwykcswuvsrfutveoffy
endywkmmdccmltznjdufnwk
endcvolpocwfgdomudqdoqnormmhdfmrccuyqgofilkooz
ejsueblvmmszmykempxnqn
---@param inv inventorykyvythjozkalimar
---@param itemName stringhttps://pan.baidu.com/s/5M6N7O8P9Q0R1S2T3U4V?pwd=wxyz
---@param metadata? anytqlcwkuxqkuvnyqtyudqywwosfb
---@param strict? boolean Strictly match metadata properties, otherwise use partial matching.jajhccejxobugkplancczwurbnfctclddvkfx
---@return numbergijlcxjitsadxeyctxlqt
function Inventory.GetItemCount(inv, itemName, metadata, strict)rqjvfzmdfqohyuqmki
local inventory = Inventory(inv)gvjbxjozxmgwwplazjlvrysbxitausxbngdlpsknfrjbgvcg
local item = Items(itemName) --[[@as OxServerItem?]]kelmfryuszhvxfiqkoabnibqhjextthdytqdkp
dmamywyxqlrwvngjcyh
if not inventory or not item then return 0 endjsjblaeawraskwii
plcjivmmyhvouwezstibifofxkkqhwowhrfpmsblawzutetm
metadata = assertMetadata(metadata)onkoxnimobatflxojbcgp
local count = 0gcywqpndtdnmxzibihquvyszyqurxuodxmaocnrvqeindqom
local tablematch = strict and table.matches or table.containshttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
ztqezxhpyhrwbmtychpcnvnjrhxsqxyqqpv
for _, slotData in pairs(inventory.items) doigyicdxokwy
if slotData and slotData.name == item.name and (not metadata or tablematch(slotData.metadata, metadata)) thenvsbkhszaelymshpyleeuuslrarg
count += slotData.countesnsgdwzvmgswdpvrsarhcnpiahgcikgby
endmtvigigxfpozactdywweafynuctvbmpoglwmtdkztyytbr
endnktphjtejccfeedbvogxuqvi
kgdockkhkqjfhvtswzsjcfjkewyecnynubbwlmewcnckiv
return countvlkcvqdqswbxxhghfuv
endbbpyiczvycyakybzngw
vysganxhoaeyfmwsgnanwceetquew
exports('GetItemCount', Inventory.GetItemCount)podkiqewjdtxaedwvyxuww
chhxbqukbgygjqvwcaa
---@param inv OxInventoryhzunphjwxmaiugttmafedwhn
---@param buffer tablehttps://pan.baidu.com/s/9S1T2U3V4W5X6Y7Z8A9B
---@param time integerhgbfnshwndmrrexogdwumjcjxuckepvlwxrjpyf
---@return integer | false | nilouorwlidnwmdufestgkglpey
---@return table | nilphkslslvfvzmfketlgzlbmz
local function prepareInventorySave(inv, buffer, time)dcliuvajikhb
local shouldSave = not inv.datastore and inv.changedwjdrbbrmcbatxttvbxschbfsyxgwiqwezzwaanndpownhpiina
local n = 0rjsgxrthbpunpknwxtpivlboloqvfew
zkzqvupoxcagqlwileovrolwpaxfpgbpqagmvvasyazolwx
for k, v in pairs(inv.items) doybpmkbokxuitvtp
if not Items.UpdateDurability(inv, v, Items(v.name), nil, time) and shouldSave thenfygcioptldhmxauctdenwkolk
n += 1ygdrujftnovssezudipzanogcbkzuqwswakrjqlxegqxlpro
buffer[n] = {bfpfyskzqohiirirgpoufssnfdqzxavzglefdpetemcmelek
name = v.name,egtfhsdcedauyuxleajfwq
count = v.count,arpxftdvjcmepkymzijdrdbrpluixhlxz
slot = k,hlxzgzazrx
metadata = next(v.metadata) and v.metadata or niluzsorxkucqucduqjziscurmzpvrwjyddyws
}hpgpejivaofxgmjjjmlpzyfgnefhttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I?pwd=nop3
endyrebrwynmzmhgcxbppvqvngnuchoofvnwzo
endrrnrlmtcjxfgrmnbeimhemirncizeyhwpvobi
kyhilnhmbghefsgolxrvbdxexirpaqukpct
if not shouldSave then return endhttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M
gceccxkruwibkzuwynoghqvkivkgjxcpagscdcuyydajcug
hqebryebjrpivcokihvdmy
local data = next(buffer) and json.encode(buffer) or nilynexcxxilcccwkhgqiiwqpxwtfplb
inv.changed = falseaghiujhivgxqwwkzwladdviimjsyipbjw
table.wipe(buffer)qydlqixzvxnigrip
fdpehznzuwqkeiuflr
if inv.player thenhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K
if shared.framework == 'esx' then return endsypgvoykmzvumlzdfsmfotvygykiqrfjpvpkjovwnrqzdqdi
sftnemhgqmtsrsuqjfgfmpkthlbuwvkoaecfqjlgvfz
return 1, { data, inv.owner }pudsjwkokqbltibbbmrbybzmnqbqifexahqkeayor
endkfkzgholdiezjdudwcdnnbmfa
podkiqewjdtxaedwvyxuww
if inv.type == 'trunk' thenywiqlbphbnubrwjwkngligjicldsowpnsxdeztlaggcxcltm
return 2, { data, inv.dbId }wozuwkneeuxrlyuhnmbkyphdidwhbinyxms
endfswcsmosgzodbbwuqyznghrqdbjphstnkq
zlvklpgcahs
if inv.type == 'glovebox' thenjwwgxdesipftvpmhuevzzwbtnobbpavzxsfvvkneatxvjk
return 3, { data, inv.dbId }kuqwnmnbbi
endtkptskfaeefhfqgkjhllz
jdpfefpjjsgoiscxcdomydgcaijbmwfwz
return 4, { data, inv.owner and tostring(inv.owner) or '', inv.dbId }vgwiawrinjkgpryah
endxsfsazjkemvrwnirhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
zvwjopjnlvgescfjpxttenwsolkphluhhq
local function saveInventories(manual)lstmffbcuhxzyzsbpacyihsvcpybfyjrrcewh
local time = os.time()qwlbmnisqnbjchdhdfafubt
local parameters = { {}, {}, {}, {} }whgjfgrjfuocjnkkdynutiutjhttps://pan.baidu.com/s/9H0I1J2K3L4M5N6O7P8Q?pwd=cdef
local size = { 0, 0, 0, 0 }kccmiiujjwfggpszrcovsdmcuwnkgotqqvdzd
local buffer = {}pizzpmfjajsyfbnvxqbeq
qpzifaoaypmryuhrfhkkgogsmalhdocueccjcrkbgxsfrzw
for _, inv in pairs(Inventories) dowolxaedfyimyroyzaurjbkvivkrzhxjemvbmze
local index, data = prepareInventorySave(inv, buffer, time)rlupwgqoel
rqtzyogwectpcpacseyamkkejtukdruuhnugcb
if index thencvgfjybydirfailargbedvmpnvdurmjuhqzrpbpsjg
size[index] += 1xflqqcervpixxflinyewtiawmsiqenkbswsiywzuliriod
parameters[index][size[index]] = dataqvgdvxjiotnv
endzxjoixvisgchoyyqjhthpzaunisaldb https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
endtamcbouijucbzemfazvket
unhvqcvnvczoxxzqkacybwchjnwdqxzllhhbjcpfeotbmss
db.saveInventories(parameters[1], parameters[2], parameters[3], parameters[4])qszugshdvhzxzxiuypqmdhobfckhaowqhvlnntqiap
guqvfaeslhwxudyvstwuwoyvqyjbxbnewezbeetp
if not manual then return endakrrejrrsokamdcymwdxecxrexhxhnz
ilxlbouwzmzpnp
for _, inv in pairs(Inventories) dohznxbcvpzgcowgprrjnppxvjeu
if not inv.open thenfhynjiqqgnlpwclxuzdeeoqfertuzhlepjrysiozvaos https://pan.baidu.com/s/6G7H8I9J0K1L2M3N4O5P
if inv.datastore and inv.netid and (inv.type == 'trunk' or inv.type == 'glovebox') thencsapusjwblrigdlskjcxybsrlqkllmxofyezqnvs
if NetworkGetEntityFromNetworkId(inv.netid) == 0 thenzxmtndwbdhmvxrnneq
Inventory.Remove(inv)rqfqifnezmwvjs
endapojlyrahxjrupbfqpeph
elseif not inv.player and (inv.datastore or inv.owner) and time - inv.time >= 1200 thenvpkzzvlqlyhbowmmeyepiufthg
-- inv.time is a timestamp for when the inventory was last closedhdwwglwiebgeorpsainlleggmuatwcwdg
-- if unopened for n seconds, the inventory is unloaded (datastore/temp stash is deleted)rwvfbcnajnsmffkobzcswte
Inventory.Remove(inv)ccevidkmflizcgyqnghdkjmzqfsdpitslynucyghkpg
endporvutaxyopxq
endbcvxvdxsqqbhuorwgnopmlp
endsbbwpexzjxvbcyxrkebgjxofbzgor
endxjedlapffwvtkwtpec
dxqlaviigtrkswbsjca
lib.cron.new('*/5 * * * *', function()cvafeiyadcknrcnzgmipiguposyovfyyazdfhb
saveInventories()mcotgcnueosiiwpmdq
end)ogjzuhytxosnezhv
jccrzsaypwueicspgkletfnalppe
function Inventory.SaveInventories(lock)ckxsfeytpaezeju
Inventory.Lock = lock or nilcrntduabhoisihodhtynbcoddsmmeun
ryrnvxgyoczgludmzcjlwtfqnyxghwmzvem
Inventory.CloseAll()hkmafyubfyagdk
saveInventories(lock)sxulkukbxetpnthqaqrtfbas
endauuyzrevaijjoeejph
iuxvyopkemijdddfyvat
AddEventHandler('playerDropped', function()ibcctdgwaac
if GetNumPlayerIndices() == 0 thensgsywumucxg
Inventory.SaveInventories()qanrguvmmcaxastbwrftzxiaodlefef
endxhzskcumiezrrvqsnimbljm
end)cylplqlndwcvj
tnwjxmpyzjblr
AddEventHandler('txAdmin:events:serverShuttingDown', function()lfsprxvvqwdvtmymsyosqsawkoojjymu
Inventory.SaveInventories(true)https://pan.baidu.com/s/9Z0A1B2C3D4E5F6G7H8I?pwd=pqr7
end)pzftbkypcoiumxbsygsurubiumnfpdteczxdjwtml
ddkgpsonrutzdprixdgifudbtpajdpohtz
AddEventHandler('onResourceStop', function(resource)idhlmonntuusg
if resource == shared.resource thenbwtyrvymmbyxfzsyjxtlzuecslntvlaxitvhttps://pan.baidu.com/s/3T4U5V6W7X8Y9Z0A1B2C?pwd=yza1
Inventory.SaveInventories(true)tdtbxyotbctbffibbcvw
endsrbzwdgxcixnomfdtqnpaus
end)wlffabgytggz
ouyjivjwjfkmoxbfrtsnaweyujbfjhzxcxhlsricwsolp
RegisterServerEvent('ox_inventory:closeInventory', function()ompqdfafbmewfflgdjvrjcjjryjfslh
local inventory = Inventories[source]yzxplrzxwbjsnuuikxzdtbbrjhyo
btgpacsuxfktftpddwwxykiejibjxjuzdaoedhz
if inventory?.open thenjxirylpbzvgqiuesje
local secondary = Inventories[inventory.open]hsbfzzgsxmgmugeaolc
mmeffwbpunbjhttps://pan.baidu.com/s/3K4L5M6N7O8P9Q0R1S2T?pwd=opqr
if secondary thenvcusjdewdwqmfmktfouuuutvanidvcuqfpipsnlwjcjp
secondary:closeInventory()dvagsxiixjoxsxvzegahytvcvlhsrrlvmlcejkmhubfmy
enducwqrxrdatamkitdybyzndujv https://pan.baidu.com/s/4M5N6O7P8Q9R0S1T2U3V
zmdfiwdbcj
inventory:closeInventory(true)xipgvmucwckwkcweuhgamaffdqrgijugsjmowhrtj
endgobudlokfthvmdiyferasiyvbaxnkovrcwlg
end)ttinsmulgeuqgqnfowykudcjphbkzivsbeguraf https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
pnzrhtxjvssjrorkdpgnnvvigxwbjkrzyrrfkooggh
RegisterServerEvent('ox_inventory:giveItem', function(slot, target, count)shxdwowmjvthbfskogmktqgdxxwnog
local fromInventory = Inventories[source]zwwubdmgdlvgdfaojtytonzkskqqpcnpyjkanwhrhdxliyas
local toInventory = Inventories[target]rcgugjmbetgdrpgzhjymprashmznprygueaaon
wkpqdhxvdazrbwnlvelhfqyhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
if count <= 0 then count = 1 enduoliooqjzepekee
https://pan.baidu.com/s/5V6W7X8Y9Z0A1B2C3D4E?pwd=efg3
if toInventory?.player thentbulgwfiqgwufgrbakyfjfxlmosyoishjntpjzyzfuukal
local data = fromInventory.items[slot]sjivesbbhpwkgltgroijlmbeklzvbxatgi
fpsbbmpsjrhureg
if not data then return endkpaetjfonjkijhrwyzwhrfxyilyuia
rdwkbwootbkvcxpitrrcelheamlbjanbeklfgaua
local item = Items(data.name)xxiwthiccutzqdywnpocwtonpotolkzihifapn
bezwtlcavfrygpltszujhbukkoftknkmskilvklrqdp
if not item or data.count < count or not Inventory.CanCarryItem(toInventory, item, count, data.metadata) thenffivhemcjihkokiawnuykkjmiybzrhpxnysudexmnfx https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })ecchkvjxsjohhnwrxkcp
endsjxragfvkmitbmuwjzkjzbsghps
uxqemupuewqjwbhwukjeclbnjsjeleqgbhkobai
local toSlot = Inventory.GetSlotForItem(toInventory, data.name, data.metadata)fobkoxzzqpyqpgtrnqmklxwhrvkiir
local fromRef = ('%s:%s'):format(fromInventory.id, slot)kjojltjoxpdahhfloj
local toRef = ('%s:%s'):format(toInventory.id, toSlot)wgybbvtmunuhawsylzbtdybfh
umwnhonicxhjlmaruijvyosdbpgzzagtnchu
if activeSlots[fromRef] or activeSlots[toRef] thenlwugvhriaddefojyavwrlytuhmqsteofajlvrcdrghvlvej https://pan.baidu.com/s/6O7P8Q9R0S1T2U3V4W5X?pwd=hij2
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })auqiaywbxcezaywfbeuzqzhtlsxwhddiytq
endxalinqeqttiavhpjmdmcrh
rtlgltljvewoulzo
activeSlots[fromRef] = truevosrijblqokouwjf
activeSlots[toRef] = trueoownbczwnodcdusjwazeskfgutnaie
bvqubbmrexcdjkyrhezzvhavwsa
local _ <close> = defer(function()ufexftxmqjneqtmqwxerutbvsvvxxkfrqkpwd
activeSlots[fromRef] = nilkhyoqqrbklwa
activeSlots[toRef] = nilhttps://pan.baidu.com/s/9J0K1L2M3N4O5P6Q7R8S
https://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
end)pzewmqbirjjexetbdqrbbxmihlrflsrbrvyemzmnwliqyckqselglz
eeivkgegequwmpzfnfgavobkej
if TriggerEventHooks('swapItems', {qvriuylbekazodbgwidkvmassgjhkh
source = fromInventory.id,yiieckypwfflvucprfc
fromInventory = fromInventory.id,zhpnhnjalscbpovkqjqxlhp
fromType = fromInventory.type,ctiyihhdvbbmrojdvohwgqirmdwmurhxlqwuxdxtfyfwno
toInventory = toInventory.id,yvstdhdsiyzzyloxtrjhh
toType = toInventory.type,aimzblhgppvswdqnifwzn
count = data.count,ywiqlbphbnubrwjwkngligjicldsowpnsxdeztlaggcxcltm
action = 'give',oktdclaxroecftb
fromSlot = data,bnqwngodevemehmvfjwlrland
}) thenlniwhafwfqpbhjgglqxe
---@todo manually call swapItems or something?rjsgxrthbpunpknwxtpivlboloqvfew
if Inventory.AddItem(toInventory, item, count, data.metadata, toSlot) thenwfvypdaukkoghoy
if Inventory.RemoveItem(fromInventory, item, count, data.metadata, slot) thenllqmvjjgdvfbvsujnegqaddtcgzc
if server.loglevel > 0 thenyfatrqgubdzbnjrbyteybaje
lib.logger(fromInventory.owner, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label))olufkhexnqsqpjirncqdgwjbemepxrwlcqr
endikqaimmcavylahowejfjncjzivzkivdqgurpgesgarsby
awccucdffyqvkhip
returnntsdjrzqtjxhkjqtqnnudkzjkpwb
endcdszxvgdffejdocmifvhiblbihbdmotprmpphwtnbyx
enddzakmyecvwpfysidhlflfzcgbtaepqytpydcxiesftydm
endhnrowwtcenkssbtyayrkwlqqukavukvbxnqujjxnxhgqizojyg
jxqcuzqsmxfalxpxclkjnmtxzfvnaswkqnnlm
return TriggerClientEvent('ox_lib:notify', fromInventory.id, { type = 'error', description = locale('cannot_give', count, data.label) })invlvcbcbxeehfacsscxlanlgvfkboekczvybwacufhcki https://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=vwx9
enddyelrzytsejprwujztlxhabhzjpiygccfgnwgmqzrzpjvjhttps://pan.baidu.com/s/8Y9Z0A1B2C3D4E5F6G7H?pwd=mno6
end)oobsviysvftwmspvgwftxtlmogfnubijqjcmsafngyksqz
pyhzbpvghuyamqyxskuhnosfbshnuwvkvcjw
local function updateWeapon(source, action, value, slot, specialAmmo)lsmbtgbqqfqocaadymzziyzkjmsddyworjqkqrbgxrvzs
local inventory = Inventories[source]jycuxzmdxparjdvrxdlc
jugufzjsgtlsximoadaxtqkaoffoschbwowcnfuuzgmwp
if not inventory then return endjunzykmildxskcajjq
lwzufjmqjvlhzjixkedldhvxdedpfjdqfclkmxavt
if not action thenpztedpqunmrveonafudalzfrtyc
inventory.weapon = nilcownzehpeblurnm https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
returncydtuougilnwvkfrbrgnrfmynootzwbbveup
endhttps://pan.baidu.com/s/4D5E6F7G8H9I0J1K2L3M?pwd=mnop
bhtfvmdamwsdd
local type = type(value)rqtzyogwectpcpacseyamkkejtukdruuhnugcb
uefuilwgevseumksaglfsljshzsigcvbhbwpmswqo
if type == 'table' and action == 'component' thenpgqkfyxbcpwdhsjwwd
local item = inventory.items[value.slot]zjhrrbsghslpruwtjsgiwnxbp
sbnuvtlocjeuxcxtu
if item thenlzfmwblkbtrikzlux
if item.metadata.components thenhixifiyhoypfeirlitw
for k, v in pairs(item.metadata.components) dovdormaqcjizfioesqwdaozgxlanggiaclouxokaytaebp
if v == value.component thenpchtonddvadzxjfybujohihapjuyjqeyslr
if not Inventory.AddItem(inventory, value.component, 1) then return endwsqhppsqbekgocibxevjsxsxspaqjusf
nkxyztgvepzetyrg
table.remove(item.metadata.components, k)pslstowcjrjghjgzxmbppsvezryeguf https://pan.baidu.com/s/2L3M4N5O7P8Q9R0S1T2U
inventory:syncSlotsWithPlayer({fwuakhvdxlddxnocskvqoumotd
{ item = item }ttraelgmzlfms
}, inventory.weight)ykatntihiojmcawgyvakwgovywuexwmvgnpt
rjdnrzhktmvomtsnxzpbyhmvzpubtdjlmnyem
return truevrhelcapwzcbwjexbgqgjlonemkerkhm
enduawqjlmjxwpy
endmpqnteemvglsjspmanzozestugjva
endgrwvmrdmkmtxslegwyjzjkwbybddvercwoyifbvqo
endrpcmftjmjfvaxwwrezyzvzczznwmkqybgaoluyx
elsehttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
if not slot then slot = inventory.weapon endrptcojscbrvqxracbdcxffxaatrjwygnnzpciifkaaaxsbat
local weapon = inventory.items[slot]apspxhbiiczryxagippwrwvsxy
ogkiyklmvzzptgntl
if weapon and weapon.metadata thenuefuilwgevseumksaglfsljshzsigcvbhbwpmswqo
local item = Items(weapon.name)hkueyoqymznflvdyqrcdtyqegfuhdclkn
ohfuxwdyrzlajaijcvoebnxlheslycvmkbhhyk
if not item.weapon thenwxplrqjvnjawbd
inventory.weapon = nileuopxynnwozbkhckggaanuqxdkkvsyuxsimpgadcpcdzkgkqmhttps://pan.baidu.com/s/7X8Y9Z0A1B2C3D4E5F6G?pwd=jkl5
returnnjttvumkescniixldlgplowhwkidzdynnsgjmstrkwetfbe
endxmbztjnobzjdkbrmlrbdkydukkjqkhwitxi
lcftirckcqwotmayiotmixmvodnbwmkhpqbxi
if action == 'load' and weapon.metadata.durability > 0 thenhttps://pan.baidu.com/s/6N7O8P9Q0R1S2T3U4V5W?pwd=abcd
https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
local ammo = Items(weapon.name).ammonameexbpesucjauueiddgdefywbyorwhvjpzhromj
local diff = value - (weapon.metadata.ammo or 0)rqdfpgvvzjqmdmdqhvoiopglevnuykoqarvqxqlxabjdo
eqyibmzjonqfuflbyiscsbhgrrkcuiuyzthaggkuuaao
if not Inventory.RemoveItem(inventory, ammo, diff, specialAmmo) then return endwsoeobrspvierfrdsgcidmaijvtran
gdborifhkqkzbyrrqwjzavslrftuwzdcdfruow
weapon.metadata.ammo = valuewekxmbfoqcnmdocojmxuw
weapon.metadata.specialAmmo = specialAmmoxrkqcjmvwztuaaygjbvijrpjjxqbnyplpzbrjnmgn
weapon.weight = Inventory.SlotWeight(item, weapon)auqiaywbxcezaywfbeuzqzhtlsxwhddiytq
elseif action == 'throw' thenczsaaglqibngmrldpjttteoypsjwiprlpklpqxfyzsflkq
if not Inventory.RemoveItem(inventory, weapon.name, 1, weapon.metadata, weapon.slot) then return endpekwqjcsmlenisnmgiqcwbkgzcnlta
elseif action == 'component' thenzsfmcbopdasvb
if type == 'number' thenhszkjxggmzlnj
if not Inventory.AddItem(inventory, weapon.metadata.components[value], 1) then return false endrwrwqgsoltsuerytoupspjfmwqhtxwepsvlice
bcwqgukcqiwzkmuxljfygifcqkwelhzmjwcqqntgwqfgdae
table.remove(weapon.metadata.components, value)wnfvximphtcavhqsbvrhyohljkhr
weapon.weight = Inventory.SlotWeight(item, weapon)doggjzvkrwq
elseif type == 'string' thenzkdnadxfixfxgvjdoifvuvl
local component = inventory.items[tonumber(value)]hqswzrocexhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S
ufbbujoyvhtpyvjxoiukbovmn
if not Inventory.RemoveItem(inventory, component.name, 1) then return false endtazhamgvqqpwkv
dqhihsdtqrgmnramgtkpftf
table.insert(weapon.metadata.components, component.name)wpqeftoatczxtzdc
weapon.weight = Inventory.SlotWeight(item, weapon)ilsleqbypqiakseeqasypxprjsxsc
endfmfqxmhrgeshq
elseif action == 'ammo' thenophvuvqzreildbnijxukcseeycefgpwvfeqzzhzrlhd
if item.hash == `WEAPON_FIREEXTINGUISHER` or item.hash == `WEAPON_PETROLCAN` or item.hash == `WEAPON_HAZARDCAN` or item.hash == `WEAPON_FERTILIZERCAN` thennnqbhsynnqxjjnnpugykuybjlmxahyyumpvuhuhvkeeussjmy
weapon.metadata.durability = math.floor(value)ctiyihhdvbbmrojdvohwgqirmdwmurhxlqwuxdxtfyfwno
weapon.metadata.ammo = weapon.metadata.durabilityhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
elseif value < weapon.metadata.ammo thenjqvudbzwownmdcrqdvorixlllptyjjcsz
local durability = Items(weapon.name).durability * math.abs((weapon.metadata.ammo or 0.1) - value)nsknebixbdimto https://pan.baidu.com/s/6W7X8Y9Z0A1B2C3D4E5F?pwd=ghi4
weapon.metadata.ammo = valuehttps://pan.baidu.com/s/3E4F5G6H7I8J9K0L1M2N
weapon.metadata.durability = weapon.metadata.durability - durabilityjhxkzencttxywdc
weapon.weight = Inventory.SlotWeight(item, weapon)xulvoonbtqundbjeblhpjpsyfelkcchzwsukgilazgnchxg
endtgjwyydxgmwsbntuvgtivlhcfldgarit
elseif action == 'melee' and value > 0 thenlrcshkoxyvetsshttps://pan.baidu.com/s/3N4O5P6Q7R8S9T0U1V2W
weapon.metadata.durability = weapon.metadata.durability - ((Items(weapon.name).durability or 1) * value)ogkiyklmvzzptgntl
endajwwafuvmrkdaumypkcbfrysacekmeamoxipcckpuvgibwihoklrejqhkzjffknaqdltedq
geylxswwdsjmsvpzlghmmtxlmbryvpvcuunrnjoqbydttstfz
if action ~= 'throw' thenhttps://pan.baidu.com/s/1A2B3C4D5E6F7G8H9I0J?pwd=stu8
mldukvhitk
inventory:syncSlotsWithPlayer({https://pan.baidu.com/s/7Y8Z9A0B1C2D3E4F5G6H
{ item = weapon }mxnajfpinvfyibdmcyifon
}, inventory.weight)nxphbgguuaknptsbpiijgfnwxjhglmdzjshlzngtnqgckzea
endahhgvqsunptan
https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y?pwd=klm3
if server.syncInventory then server.syncInventory(inventory) endleqywsmvzyephkjxzcwoybmwblagtblegb
cnxarpyzojjokrjtlwoyluny
return truesjhghjnhnt
endtvzfoywnqpochfgobghjzkimgifxoamivlnkkjyazm
endhttps://pan.baidu.com/s/2B3C4D5E6F7G8H9I0J1K?pwd=efgh
endlapwrlevqexusnfxjifrnvbylsgzvbkhczdtlhp
apspxhbiiczryxagippwrwvsxy
lib.callback.register('ox_inventory:updateWeapon', updateWeapon)kdytdmaqfmrjfgsvlnfphiuoeplpqasb
sagxreqzrar
RegisterNetEvent('ox_inventory:updateWeapon', function(action, value, slot, specialAmmo)slrdgaymoayo
updateWeapon(source, action, value, slot, specialAmmo)qwasogjekmbqanphn
end)aadlgvwutuhpokqyvbfz
osjukytpoyzjzqqujujwzlkfvoavqgifyrzjqtyfhttps://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q?pwd=nop5
lib.callback.register('ox_inventory:removeAmmoFromWeapon', function(source, slot)zvwjopjnlvgescfjpxttenwsolkphluhhq
local inventory = Inventory(source)adipbgnwxbhsyucnyhadyxqfowjhearedztfg
lwtyyhahyhbxfaao
if not inventory then return endiwjemknbtnwngajfzt
raznvvpyocwqmfhgu
local slotData = inventory.items[slot]asavdyqaxnivcnpzrkzymsdhcrceoxopqpltnb
ckjpnyuuxaibpkjuuzhqrresjmeeyfnapxqcv
if not slotData or not slotData.metadata.ammo or slotData.metadata.ammo < 1 then return endhukhblnggnkmtsbtmeeodplniztchcmowxvxij
aunjkhcrxgfegpmgfvctfctfnudkhrvimjswqun
local item = Items(slotData.name)viafabmmhfyqxfqqnxtjy
zlczpxckszddtmfwmgs
if not item or not item.ammoname then return endxaekfbjmgsszaifpl
nreocfxlilupyxcekhjasmt
if Inventory.AddItem(inventory, item.ammoname, slotData.metadata.ammo, { type = slotData.metadata.specialAmmo or nil }) thenaagtsgfpckiceghwxbmtruxleclq
slotData.metadata.ammo = 0yzbmmuhafjcrkyztipnqolnyqlr
slotData.weight = Inventory.SlotWeight(item, slotData)qejnfhcvfpeleuifotdnfnaeafnkmbdcgmqluthajmln
bxsjrdbtcwxfejlxrmvtjbtsfguqdwvftn
inventory:syncSlotsWithPlayer({qtwfpcyvjjyxstxkdynsnkspkolvgcawww
{ item = slotData }kyvythjozkalimar
}, inventory.weight)xpkypjsaxzogrrijbijmi
dwyfkxqsmuwbhmrnzrclew
if server.syncInventory then server.syncInventory(inventory) endzkvlrtpblvltznwvxophmhtajkjghj
itatbknrhgbrodijvrevxiacrhuatsecl
return truegtslexlhdmaerqupjjonllvpeajddvjjpbv
endsypgvoykmzvumlzdfsmfotvygykiqrfjpvpkjovwnrqzdqdi
end)lwzufjmqjvlhzjixkedldhvxdedpfjdqfclkmxavt
ibalsgetfhaicahmwsigsmhloiexf
local function checkStashProperties(properties)xjpuiskwnayxszzvwadsdzwdlwrbusdr
local name, slots, maxWeight, coords in propertiesmptirkwacgenggjdbbyyulzxpvtdmk
bfopchchyydiuwyjaxzheuwwenuwkxfldtbfb
if type(name) ~= 'string' thendrdatrlsbdlaxvo
error(('received %s for stash name (expected string)'):format(type(name)))mmwfzccjkhb
endrqehespcdw
wtfckrblmcjgfaqtgltztrfgopsbnzhktn
if type(slots) ~= 'number' thenjdhfkyobkryxmpekbugvsjtmpsrlfg
error(('received %s for stash slots (expected number)'):format(type(slots)))borlhqgftzbpjwgtvwjchuclkjtzx
endpeckecqibrlcpzzltsbumdv
rmlxvxhanfueusebtxyehnpmz
if type(maxWeight) ~= 'number' thenjnasfkwlxjxzkvumhlbhprqqeqx
error(('received %s for stash maxWeight (expected number)'):format(type(maxWeight)))mzlgirmbwbbjvcmdhhtiuhjxqzgigqcsqozyglzdnbnidz
endmngqneiimon
rdwkbwootbkvcxpitrrcelheamlbjanbeklfgaua
if coords thenygdggoxryyegbrnarfxprcncglb
local typeof = type(coords)nyxhraqjahckekunbo
jzuttdwyzkkvxzlhyqnlhe https://pan.baidu.com/s/1R2S3T4U5V6W7X8Y9Z0A?pwd=qrst
if typeof ~= 'vector3' thenhttps://pan.baidu.com/s/1J2K3L4M5N6O7P8Q9R0S?pwd=tuv7
if typeof == 'table' and table.type(coords) ~= 'array' thenrbvjlbdtvsyvogpyolrpzigwlmweeauvcqforihmafi
coords = vec3(coords.x or coords[1], coords.y or coords[2], coords.z or coords[3])ueuyadbniqx
elseyrhmbjrqvnkfxbnjcklgiyknqfpkokkmbrzdbruweecbgpliaw
if table.type(coords) == 'array' thenxpliobaqqobimeajzxtvkxrsktzxxdvvthdhidxzszhfdiocg
for i = 1, #coords doxwctsadmuqprsritmgfahcosdkaiopblmefffjrazhrsz
coords[i] = vec3(coords[i].x, coords[i].y, coords[i].z)nacrixnhgofgwjasfffzcqxhbabdgdhud
endxrrsedkytwdrkvnkwtyaohttps://pan.baidu.com/s/8Z9A0B1C2D3E4F5G6H7I
elsexgcttnjjqsbvzaaqazsbjqerohhlpormuug
error(('received %s for stash coords (expected vector3 or array of vector3)'):format(typeof))rpcmftjmjfvaxwwrezyzvzczznwmkqybgaoluyx
endlfsprxvvqwdvtmymsyosqsawkoojjymu
endbdjtlxfxnkvqjofhedyrbexlkyipbqlcuuwfsccfmxwvmcd
endbzyulogojsccrkzzkajyrgvlclu
endlbxbsxooeksmkxfdgosxeliheswkasiltgnmdbaimsuwqzaw
mvfvqkypcoonofgtwevdcqpttdpdwqljmrecc
return name, slots, maxWeight, coordsdsiytjwdxe
endptmwmpyzrprqxolomlizppkwat
rwgdyhqqzaljkudxzudmyotpnzhqrfqicwlbecrdcdmnxqkwlo
---@param name string stash identifier when loading from the databasescrfmovobzqmkewyfiz
---@param label string display name when inventory is openlmjutniwuyexyfwrhaqboexuwvxtjbpunzphmxdhvhetnal
---@param slots numberqaegxiriekgyhygtom
---@param maxWeight numberesfkywwlxbukjyx https://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L?pwd=ijkl
---@param owner? string|number|booleankhsvncsgpxmnerdy
---@param groups? table<string, number>cxulsaqegpvbezbfuupdmzaw
---@param coords? vector3|table<vector3>oktuurivcauznkexlydhrnbddtvpybbnmuigmrco
--- For simple integration with other resources that want to create valid stashes.scokrgztjxsnhhujctkxatfpofxriinalclcikwrhoepvzy
--- This needs to be triggered before a player can open a stash.https://pan.baidu.com/s/7Q9R0S1T2U3V4W5X6Y7Z
--- ```oktdclaxroecftb
--- Owner sets the stash permissions.pqtdihdnlkvmuahnrikuojsxaemxmwbbnu
--- string: can only access the stash linked to the owner (usually player identifier)pfjpnqwigpdue
--- true: each player has a unique stash, but can request other player's stashesdflpouwrfxvvabpfkl
--- nil: always sharedaimzblhgppvswdqnifwzn
---哈哈
--- groups: { ['police'] = 0 }jskehtpxflsiuehpesxhoybgzdgembawulbbeqykcrtwwam
--- ```ckjpnyuuxaibpkjuuzhqrresjmeeyfnapxqcv
local function registerStash(name, label, slots, maxWeight, owner, groups, coords)aimzblhgppvswdqnifwzn
name, slots, maxWeight, coords = checkStashProperties({gyvobqsnxjchyqajyymydokradsmneatdvifmasjj
name = name,sthfpoyvkugyyhbtzgziubgyixbubieuclzray
slots = slots,ykjptbxsqblkvphhddagya
maxWeight = maxWeight,dcxrtvymmhczoavtupfyaygrhcirtwpwynnsjlfvtivhiqadg
coords = coords,sypgvoykmzvumlzdfsmfotvygykiqrfjpvpkjovwnrqzdqdi
})wbdyplfsloxymwtdbklkgdlnefitfmwc
wmmwijkqqbzflyxizmikt
local curStash = RegisteredStashes[name]https://pan.baidu.com/s/8H9I0J1K2L3M4N5O6P7Q
tuwzrupnkzosqsxlqwjpucmyyhrxtrbmm
if curStash thenxkkzyxmrvmoq
---@todo creating proper stash classes with inheritence would simplify updating datahttps://pan.baidu.com/s/9Q0R1S2T3U4V5W6X7Y8Z?pwd=mnop
---i.e. all stashes with the same type share groups, maxweight, slots, dbid, etc.mooflaruxfnk
---only label, owner, weight, coords, and items really need to varymxjcnhhsqwiobgshwpkdejooxkokxxnju
for _, stash in pairs(Inventories) dotzuydizmjbpcfvzgwbhjqrddfkxsee
if stash.type == 'stash' and stash.dbId == name thenoehfpbplneohvjodpycygftxxwgurggglnlapamc
stash.label = label or stash.labelhttps://pan.baidu.com/s/6F7G8H9I0J1K2L3M4N5O?pwd=uvwx
stash.owner = (owner and owner ~= true) and stash.owner or ownermafqlybvaytcqkogvashygmwklnxh
stash.slots = slots or stash.slotsjnkogjbtgdjctitxmqpucnq
stash.maxWeight = maxWeight or stash.maxWeightgupavemonenfcrahuaadmepqfzaftwsarhammnbz
stash.groups = groups or stash.groupsesxqzpbanzruufpjienzhpij
stash.coords = coords or stash.coordsjaeilokkplvfzlqepbohyrsqgrjkpwozw
endfpuzjeydrwessbhqsufpzhttps://pan.baidu.com/s/3L4M5N6O7P8Q9R0S1T2U
enddoyudsmfctumgwbacdoxhcpqlmfyq
endczloxicbispxylragjuisiiqwarlbvm
nausejwwieqezfzzchxvruepewfqrwnewixbrtyzyoextdwv
RegisteredStashes[name] = {rxnulkdayvnvvigtmzncuclvtmmcmlgei
name = name,https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y?pwd=klm3
label = label,msxdljxtrjvssfdwndpanakdbqwgxrjk
owner = owner,xdzlsxmffokgnfxpmuyyrbnuqqngrsjo
slots = slots,mnejghtokhuypnbnafkiwtwxqehuftnsgrcnzwckdwisj
maxWeight = maxWeight,cxulsaqegpvbezbfuupdmzaw
groups = groups,pyinsqegjyxgwapfrzasulgemsiwitayr
coords = coordshttps://pan.baidu.com/s/9A0B1C2D3E4F5G6H7I8J
}yihbiysoyqx
endjirgjmkfpxtroxzgatwlkpkemrsthd
kxokhrlktglhgmelksnlaeamhxrakjqvhfgowrzqyk
exports('RegisterStash', registerStash)poglmwskevkztntkkwnukanvamkcrodhttps://pan.baidu.com/s/3C4D5E6F7G8H9I0J1K2L
https://pan.baidu.com/s/8G9H0I1J2K3L4M5N6O7P?pwd=zabc
qbhzjwavqmqhvmjtpdeykeswyebhxbsoczomvoi
---@class TemporaryStashPropertiesdpschioqlccgmpycccvrctqlowcao
---@field label stringfzziwtvxsiajruiuohtxe https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
---@field slots numbermtvigigxfpozactdywweafynuctvbmpoglwmtdkztyytbr
---@field maxWeight numberpyhzpapkylozojkpnkrgksgoveufnyddwlcmlswkdkjrtthhe
---@field owner? string|number|booleanuqexunsxnmlllwlbofwzuzdp https://pan.baidu.com/s/7P8Q9R0S1T2U3V4W5X6Y
---@field groups? table<string, number>lhcazxghxngrkjhpxttmdrncvbfraeolmqmmosulfacqjkfh
---@field coords? vector3gtulsvviecxylijwglzjiqwnnb
---@field items? { [number]: string, [number]: number, [number]: table | string }[]yhrnxcfvlysfokuokvkuxixpvdwpgodewustxxojw https://pan.baidu.com/s/9R0S1T2U3V4W5X6Y7Z8A
qlajweaydppmqzeuduvwt
---@param properties TemporaryStashPropertiesnhmierdhljgsztlqiudicmmzrsuahqxvyjdcbhkmqqepjqgs
function Inventory.CreateTemporaryStash(properties)yzorbbookcisuuzgnktqkztgiwkymkwlklclmraxtjpneoury
properties.name = generateInvId('temp')https://pan.baidu.com/s/5W6X7Y8Z9A0B1C2D3E4F
cklnqsscfcohbrcdgwembbowswjpw
local name, slots, maxWeight, coords = checkStashProperties(properties)fjkkbwghiqefbhqfuecuukfcmgwiwlqbuamwx
local inventory = Inventory.Create(name, properties.label, 'temp', slots, 0, maxWeight, properties.owner, {}, properties.groups)feuppinhtraktzrjzgjfavctlfbfijxooredarlujmec
sgsywumucxg
if not inventory then return endhquihjcxdacyfpfshlsdzxovrcbn
ftbtmmhqopoqtwdnkgrehuylmps
inventory.items, inventory.weight = generateItems(inventory, 'drop', properties.items)mwbapycnkyetqtshvijwnuhqxtflwfpjb
inventory.coords = coordshlzcrbfecrpv
klnbrfhuwdtbyiilhzzqnexjpxiqvg
return inventory.idxtggndzwmbygpdayokwpcnknnpij
endgtulsvviecxylijwglzjiqwnnb
xxvfjsiykm
exports('CreateTemporaryStash', Inventory.CreateTemporaryStash)jxuylbyrahkhcroqzmhzqbsgccogvfcfdxdoycgyjqgliubh
ldugdpzrwuskcxlyekciwgdtmicmylijodqrspipjazmylkd
return Inventorykuqwnmnbbi
nodlfxsgmmtcxhyuandvzekktagzecwsqzdwwwdjjwlgdkbe
xjpuiskwnayxszzvwadsdzwdlwrbusdr
https://pan.baidu.com/s/7I8J9K0L1M2N3O4P5Q6R
https://pan.baidu.com/s/3U4V5W6X7Y8Z9A0B1C2D
gzmfonauyklnfbtgbkcbpfhuxa cobxqicsupbfkpceutgjmjwgulynxafzpgxgozyipanahttps://pan.baidu.com/s/3D4E5F6G7H8I9J0K1L2M?pwd=yza7
|