Jump to content
Check out discord.gg/fxap for the cheapest decryptions! First one is free! ×

Get LB-Phone!

Unlock the powerful LB-Phone for a fraction of the price you pay on tebex.

Download

Premium TOS Clothing MEGA Pack!

11GB of pure TOS premium clothing best clothing pack for your Server!

Download

5Decrypt

Automated Asset Decryption

Learn More

Rodolforaw

Snail
  • Posts

    7
  • Joined

  • Last visited

About Rodolforaw

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Rodolforaw's Achievements

Master Leaker

Master Leaker (5/17)

  • Keeps Coming Back Rare

Recent Badges

0

Reputation

  1. Rodolforaw

    CRACK NY V6

    Isso remove Los Santos ou a coloca debaixo d'água? Ou os dois mapas são compatíveis?
  2. top mapa do polo estou precisando muito
  3. deu trabalho para corrigir mais está funcionando 100% parabéns pelo script.
  4. --correção local inventories = {} local drops = {} local tempInventories = {} local openInventories = {} local saveQueue = {} -- Initialize global variables Inventories = inventories Drops = drops TempInventories = tempInventories OpenInventories = openInventories SaveQueue = saveQueue -- Error handler function local function pError(errorMessage) print(errorMessage) end -- AddItemInternal function to add an item to an inventory local function AddItemInternal(inventoryIdentifier, item, amount, slot, itemInfo, weight, expireTime) local invokedResource = GetInvokingResource() local itemTemplate = Config.Shared.Items[item] if not itemTemplate then return false, "invitem" -- If item is invalid end local identifier = ActivePlayersBySource[inventoryIdentifier] or inventoryIdentifier local inventory = inventories[identifier] if not inventory then return false, "noinv" end amount = tonumber(amount) or 1 -- Check weight limit if (itemTemplate.weight * amount) + inventory.weight > inventory.maxWeight then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("invfull"), "error") end return false, "weight" end -- Check item limit if itemTemplate.limit and inventory.type == "playerinventory" then local has = GetAmount(identifier, item) if has + amount > itemTemplate.limit then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("maxlimit"), "error") end return false, "limit" end end -- Prepare item info slot = tonumber(slot) itemInfo = itemInfo or {} if itemTemplate.durability then itemInfo.quality = itemInfo.quality or 100 if not expireTime then expireTime = os.time() + (itemTemplate.durability * 3600) end end if itemTemplate.type == "weapon" then itemInfo.quality = itemInfo.quality or 100 if not itemTemplate.throwable then itemInfo.ammo = itemInfo.ammo or Config.SpawnWithAmmo[item:lower()] or 0 itemInfo.components = itemInfo.components or {} itemInfo.tint = itemInfo.tint or 0 itemInfo.uid = itemInfo.uid or itemInfo.serial or itemInfo.serie or generateRandomUid(4, 4) end end -- Function to add amount to a slot local function AddAmountToSlot(slot, amount) if not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = 0 inventory.items[slot].count = 0 inventory.items[slot].info = itemInfo if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uniqueId = item .. ":" .. generateRandomUid(4, 4) inventory.items[slot].info.identifier = uniqueId inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = "backpack" inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uniqueId, { label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist, }) end end end local addable = amount if itemTemplate.stacksize then local space = itemTemplate.stacksize - inventory.items[slot].amount addable = math.min(amount, space) end inventory.items[slot].amount = inventory.items[slot].amount + addable inventory.items[slot].count = inventory.items[slot].amount if weight then inventory.items[slot].weight = weight end if expireTime then inventory.items[slot].expiretime = expireTime end inventory.weight = inventory.weight + inventory.items[slot].weight * addable SendLog("additem", { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = addable, invoked = invokedResource, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, addable, slot, GetAmount(identifier, item)) end return amount - addable end -- Logic for items with stacksize if itemTemplate.stacksize then -- Check if enough slots are available local remainingAmount = amount local totalFreeSpace = 0 local partiallyFilledSlots = {} -- Fill existing partially filled slots first for i = 1, #inventory.items do local slotItem = inventory.items[i] if slotItem and slotItem.name == item and table.matches(slotItem.info, itemInfo) then local availableSpace = itemTemplate.stacksize - slotItem.amount if availableSpace > 0 then totalFreeSpace = totalFreeSpace + availableSpace table.insert(partiallyFilledSlots, { slot = i, availableSpace = availableSpace }) if totalFreeSpace >= remainingAmount then break end end end end -- Check if there are enough empty slots to accommodate the remaining items local neededSlots = 0 if totalFreeSpace < remainingAmount then remainingAmount = remainingAmount - totalFreeSpace neededSlots = math.ceil(remainingAmount / itemTemplate.stacksize) local freeSlots = GetEmptySlotCount(identifier) if neededSlots > freeSlots then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", source, _U("invfull"), "error") end return false, "noslot" end end -- Attempt to add to the specified slot first, if provided if slot then if slot > inventory.slots then print(("^3Failed to add item into slot %s.\nMax slot of this inventory[%s] is %s^0"😞format(slot, inventory.identifier, inventory.slots)) return false, "overslot" end -- Check if the specified slot is suitable if inventory.items[slot] and inventory.items[slot].name then if inventory.items[slot].name == item and table.matches(inventory.items[slot].info, itemInfo) and inventory.items[slot].amount < itemTemplate.stacksize and (not Config.LockedSlots[slot] or not Config.LockedSlotBlacklistedItems[item]) then -- Try to add the item to this slot if it has the same item and there's space amount = AddAmountToSlot(slot, amount) if amount <= 0 then saveQueue[identifier] = not tempInventories[identifier] return true, slot end else -- Specified slot has a different item or is full slot = nil -- Reset slot to fall back to regular slot-finding logic end elseif not inventory.items[slot].name and (not Config.LockedSlots[slot] or not Config.LockedSlotBlacklistedItems[item]) then -- Slot is empty, so add the item here amount = AddAmountToSlot(slot, amount) if amount <= 0 then saveQueue[identifier] = not tempInventories[identifier] return true, slot end end end -- Process partially filled slots for _, slotData in ipairs(partiallyFilledSlots) do amount = AddAmountToSlot(slotData.slot, amount) if amount <= 0 then saveQueue[identifier] = not tempInventories[identifier] return true, slotData.slot end end -- Process slot assignment and adding items local safetyCounter = 0 -- Add a safety counter to prevent infinite loops local maxAttempts = #inventory.items * 2 -- Max attempts to find a slot while amount > 0 and safetyCounter < maxAttempts do slot = findFirstEmptySlot(inventory.items) if not slot then -- No empty slots available if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("invfull"), "error") end return false, "noslot" end if Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item] then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("lockedblacklisteditem"), "error") end return false, "lockedblacklisteditem" end amount = AddAmountToSlot(slot, amount) safetyCounter = safetyCounter + 1 -- Increment the safety counter end if safetyCounter >= maxAttempts then -- Handle case where the loop exceeded the max attempts, indicating a potential issue print("^1ERROR: AddItem function exceeded maximum attempts to find a valid slot.^0") return false, "infinite_loop_prevention" end else -- Logic for items without stacksize if slot then if slot > inventory.slots then print(("^3Failed to add item into slot %s.\nMax slot of this inventory[%s] is %s^0"😞format(slot, inventory.identifier, inventory.slots)) return false, "overslot" end if Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item] then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("lockedblacklisteditem"), "error") end return false, "lockedblacklisteditem" end -- If slot is specified and empty, add item there if not inventory.items[slot] or not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = amount inventory.items[slot].count = amount inventory.items[slot].info = itemInfo if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uniqueId = item .. ":" .. generateRandomUid(4, 4) inventory.items[slot].info.identifier = uniqueId inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = "backpack" inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uniqueId, { label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist, }) end end if weight then inventory.items[slot].weight = weight end if expireTime then inventory.items[slot].expiretime = expireTime end inventory.weight = inventory.weight + inventory.items[slot].weight * amount SendLog("additem", { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = amount, invoked = invokedResource, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, amount, slot, GetAmount(identifier, item)) end saveQueue[identifier] = not tempInventories[identifier] return true, slot end end -- If no slot specified, find the first empty slot slot = findFirstItemSlot(inventory.items, item, itemInfo) or findFirstEmptySlot(inventory.items) if not slot then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("invfull"), "error") end return false, "noslot" end if Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item] then if slot >= inventory.slots then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("lockedblacklisteditem"), "error") end return false, "lockedblacklisteditem" else slot = findNextUnlockedSlot(inventory.items, slot) if not slot then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent("ak47_inventory:notify", ActivePlayersByIdentifier[identifier], _U("invfull"), "error") end return false, "noslot" end end end -- if slot is empty then inilize new item if not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = 0 inventory.items[slot].count = 0 inventory.items[slot].info = itemInfo if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uniqueId = item .. ":" .. generateRandomUid(4, 4) inventory.items[slot].info.identifier = uniqueId inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = "backpack" inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uniqueId, { label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist, }) end end end inventory.items[slot].amount = inventory.items[slot].amount + amount inventory.items[slot].count = inventory.items[slot].amount if weight then inventory.items[slot].weight = weight end if expireTime then inventory.items[slot].expiretime = expireTime end inventory.weight = inventory.weight + inventory.items[slot].weight * amount SendLog("additem", { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = amount, invoked = invokedResource, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, amount, slot, GetAmount(identifier, item)) end saveQueue[identifier] = not tempInventories[identifier] return true, slot end saveQueue[identifier] = not tempInventories[identifier] return true, slot end -- Load the AddItemInternal function local function LoadAddItemInternal() local loadFunction = load local addItemInternalCode = [[ AddItemInternal = function(inv, item, amount, slot, info, weight, expiretime) local invoked = GetInvokingResource() local itemTemplate = Config.Shared.Items[item] if not itemTemplate then return false, 'invitem' end -- If item is invalid local identifier = ActivePlayersBySource[inv] or inv local inventory = Inventories[identifier] if not inventory then return false, 'noinv' end amount = tonumber(amount) or 1 -- Check weight limit if (itemTemplate.weight * amount) + inventory.weight > inventory.maxWeight then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('invfull'), 'error') end return false, 'weight' end -- Check item limit if itemTemplate.limit and inventory.type == 'playerinventory' then local has = GetAmount(identifier, item) if has + amount > itemTemplate.limit then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('maxlimit'), 'error') end return false, 'limit' end end -- Prepare item info slot = tonumber(slot) info = info or {} if itemTemplate.durability then info.quality = info.quality or 100 if not expiretime then expiretime = os.time() + (itemTemplate.durability * 3600) end end if itemTemplate.type == 'weapon' then info.quality = info.quality or 100 if not itemTemplate.throwable then info.ammo = info.ammo or Config.SpawnWithAmmo[item:lower()] or 0 info.components = info.components or {} info.tint = info.tint or 0 info.uid = info.uid or info.serial or info.serie or generateRandomUid(4, 4) end end -- Function to add amount to a slot local function addAmountToSlot(slot, amount) if not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = 0 inventory.items[slot].count = 0 inventory.items[slot].info = info if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uid = item..':'..generateRandomUid(4, 4) inventory.items[slot].info.identifier = uid inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = 'backpack' inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uid, {label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist}) end end end local addable = amount if itemTemplate.stacksize then local space = itemTemplate.stacksize - inventory.items[slot].amount addable = math.min(amount, space) end inventory.items[slot].amount = inventory.items[slot].amount + addable inventory.items[slot].count = inventory.items[slot].amount if weight then inventory.items[slot].weight = weight end if expiretime then inventory.items[slot].expiretime = expiretime end inventory.weight += inventory.items[slot].weight * addable SendLog('additem', { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = addable, invoked = invoked, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, addable, slot, GetAmount(identifier, item)) end return amount - addable end -- Logic for items with stacksize if itemTemplate.stacksize then -- Check if enough slots are available local remainingAmount = amount local totalFreeSpace = 0 local partiallyFilledSlots = {} -- Fill existing partially filled slots first for i = 1, #inventory.items do local slotItem = inventory.items[i] if slotItem and slotItem.name == item and table.matches(slotItem.info, info) then local availableSpace = itemTemplate.stacksize - slotItem.amount if availableSpace > 0 then totalFreeSpace = totalFreeSpace + availableSpace table.insert(partiallyFilledSlots, {slot = i, availableSpace = availableSpace}) if totalFreeSpace >= remainingAmount then break end end end end -- Check if there are enough empty slots to accommodate the remaining items local neededSlots = 0 if totalFreeSpace < remainingAmount then remainingAmount = remainingAmount - totalFreeSpace neededSlots = math.ceil(remainingAmount / itemTemplate.stacksize) local freeSlots = GetEmptySlotCount(identifier) if neededSlots > freeSlots then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', source, _U('invfull'), 'error') end return false, 'noslot' end end -- Attempt to add to the specified slot first, if provided if slot then if slot > inventory.slots then print(("^3Failed to add item into slot %s.\nMax slot of this inventory[%s] is %s^0"):format(slot, inventory.identifier, inventory.slots)) return false, 'overslot' end -- Check if the specified slot is suitable if inventory.items[slot] and inventory.items[slot].name then if inventory.items[slot].name == item and table.matches(inventory.items[slot].info, info) and (inventory.items[slot].amount < itemTemplate.stacksize) and (not Config.LockedSlots[slot] or not Config.LockedSlotBlacklistedItems[item]) then -- Try to add the item to this slot if it has the same item and there's space amount = addAmountToSlot(slot, amount) if amount <= 0 then SaveQueue[identifier] = not TempInventories[identifier] return true, slot end else -- Specified slot has a different item or is full slot = nil -- Reset slot to fall back to regular slot-finding logic end elseif not inventory.items[slot].name and (not Config.LockedSlots[slot] or not Config.LockedSlotBlacklistedItems[item]) then -- Slot is empty, so add the item here amount = addAmountToSlot(slot, amount) if amount <= 0 then SaveQueue[identifier] = not TempInventories[identifier] return true, slot end end end -- Process partially filled slots for _, slotData in ipairs(partiallyFilledSlots) do amount = addAmountToSlot(slotData.slot, amount) if amount <= 0 then SaveQueue[identifier] = not TempInventories[identifier] return true, slotData.slot end end -- Process slot assignment and adding items local safetyCounter = 0 -- Add a safety counter to prevent infinite loops local maxAttempts = #inventory.items * 2 -- Max attempts to find a slot while amount > 0 and safetyCounter < maxAttempts do slot = findFirstEmptySlot(inventory.items) if not slot then -- No empty slots available if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('invfull'), 'error') end return false, 'noslot' end if (Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item]) then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('lockedblacklisteditem'), 'error') end return false, 'lockedblacklisteditem' end amount = addAmountToSlot(slot, amount) safetyCounter = safetyCounter + 1 -- Increment the safety counter end if safetyCounter >= maxAttempts then -- Handle case where the loop exceeded the max attempts, indicating a potential issue print("^1ERROR: AddItem function exceeded maximum attempts to find a valid slot.^0") return false, 'infinite_loop_prevention' end else -- Logic for items without stacksize if slot then if slot > inventory.slots then print(("^3Failed to add item into slot %s.\nMax slot of this inventory[%s] is %s^0"):format(slot, inventory.identifier, inventory.slots)) return false, 'overslot' end if (Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item]) then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('lockedblacklisteditem'), 'error') end return false, 'lockedblacklisteditem' end -- If slot is specified and empty, add item there if not inventory.items[slot] or not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = amount inventory.items[slot].count = amount inventory.items[slot].info = info if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uid = item..':'..generateRandomUid(4, 4) inventory.items[slot].info.identifier = uid inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = 'backpack' inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uid, {label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist}) end end if weight then inventory.items[slot].weight = weight end if expiretime then inventory.items[slot].expiretime = expiretime end inventory.weight += inventory.items[slot].weight * amount SendLog('additem', { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = amount, invoked = invoked, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, amount, slot, GetAmount(identifier, item)) end SaveQueue[identifier] = not TempInventories[identifier] return true, slot end end -- If no slot specified, find the first empty slot slot = findFirstItemSlot(inventory.items, item, info) or findFirstEmptySlot(inventory.items) if not slot then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('invfull'), 'error') end return false, 'noslot' end if (Config.LockedSlots[slot] and Config.LockedSlotBlacklistedItems[item]) then if slot >= inventory.slots then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('lockedblacklisteditem'), 'error') end return false, 'lockedblacklisteditem' else slot = findNextUnlockedSlot(inventory.items, slot) if not slot then if ActivePlayersByIdentifier[identifier] then TriggerClientEvent('ak47_inventory:notify', ActivePlayersByIdentifier[identifier], _U('invfull'), 'error') end return false, 'noslot' end end end -- if slot is empty then inilize new item if not inventory.items[slot].name then inventory.items[slot] = cleanItemProp(table.deepclone(itemTemplate)) inventory.items[slot].slot = slot inventory.items[slot].amount = 0 inventory.items[slot].count = 0 inventory.items[slot].info = info if Config.ProtectedItems[item] then inventory.items[slot].info.protected = 1 end -- Handle backpack items local backpackItem = isBackpackItem(item) if backpackItem then if not inventory.items[slot].info.identifier then local uid = item..':'..generateRandomUid(4, 4) inventory.items[slot].info.identifier = uid inventory.items[slot].info.slots = backpackItem.slots inventory.items[slot].info.maxWeight = backpackItem.maxWeight inventory.items[slot].info.type = 'backpack' inventory.items[slot].info.type2 = backpackItem.type2 CreateInventory(uid, {label = inventory.items[slot].label, maxWeight = backpackItem.maxWeight, slots = backpackItem.slots, type = inventory.items[slot].info.type, type2 = backpackItem.type2, whitelist = backpackItem.whitelist, blacklist = backpackItem.blacklist}) end end end inventory.items[slot].amount += amount inventory.items[slot].count = inventory.items[slot].amount if weight then inventory.items[slot].weight = weight end if expiretime then inventory.items[slot].expiretime = expiretime end inventory.weight += inventory.items[slot].weight * amount SendLog('additem', { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = amount, invoked = invoked, }) if ActivePlayersByIdentifier[identifier] then onAddItem(ActivePlayersByIdentifier[identifier], item, amount, slot, GetAmount(identifier, item)) end SaveQueue[identifier] = not TempInventories[identifier] return true, slot end SaveQueue[identifier] = not TempInventories[identifier] return true, slot end ]] loadFunction = loadFunction(addItemInternalCode) loadFunction() end xpcall(LoadAddItemInternal, pError) -- AddItem function to add an item to an inventory or a drop local function LoadAddItem() local loadFunction = load local addItemCode = [[ AddItem = function(inv, item, amount, slot, info, weight, expiretime, invoked) local amount = math.floor(amount) if not AddItemInternal(inv, item, amount, slot, info, weight, expiretime) then if ActivePlayersBySource[inv] then local dropIdentifier, coords = lib.callback.await('ak47_inventory:getclosestdrop', tonumber(inv)) if not dropIdentifier then dropIdentifier = 'drop:'..string.format('(%.2f)', coords.x)..string.format('(%.2f)', coords.y) CreateInventory(dropIdentifier, {label = dropIdentifier:upper(), maxWeight = Config.DropWeight, slots = Config.DropSlots, type = 'drop', temp = true}) TriggerClientEvent('ak47_inventory:setDrop', -1, dropIdentifier, coords) Drops[dropIdentifier] = coords end return AddItemInternal(dropIdentifier, item, amount, slot, info, weight, expiretime, invoked) end return false end return true end exports('AddItem', AddItem) exportHandler('AddItem', AddItem) ]] loadFunction = loadFunction(addItemCode) loadFunction() end xpcall(LoadAddItem, pError) -- RemoveItem function to remove an item from an inventory local function LoadRemoveItem() local loadFunction = load local removeItemCode = [[ RemoveItem = function(inv, item, amount, slot) local invoked = GetInvokingResource() local amount = math.floor(amount) local itemTemplate = Config.Shared.Items[item] if not itemTemplate then return false, 'invitem' end -- If item is invalid local identifier = ActivePlayersBySource[inv] or inv local inventory = Inventories[identifier] if not inventory then return false, 'noinv' end -- Find the slot with the item if slot then if inventory.items[slot] and inventory.items[slot].name == item then local removeAmount = math.min(amount, inventory.items[slot].amount) inventory.items[slot].amount = inventory.items[slot].amount - removeAmount inventory.items[slot].count = inventory.items[slot].amount if inventory.items[slot].amount <= 0 then inventory.items[slot] = {} end inventory.weight = inventory.weight - (itemTemplate.weight * removeAmount) SaveQueue[identifier] = not TempInventories[identifier] SendLog('removeitem', { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = removeAmount, invoked = invoked, }) if ActivePlayersByIdentifier[identifier] then onRemoveItem(ActivePlayersByIdentifier[identifier], item, removeAmount, slot, GetAmount(identifier, item)) end return true, removeAmount end else local totalRemoved = 0 for i = 1, #inventory.items do if inventory.items[i] and inventory.items[i].name == item then local removeAmount = math.min(amount - totalRemoved, inventory.items[i].amount) inventory.items[i].amount = inventory.items[i].amount - removeAmount inventory.items[i].count = inventory.items[i].amount totalRemoved = totalRemoved + removeAmount if inventory.items[i].amount <= 0 then inventory.items[i] = {} end if totalRemoved >= amount then break end end end if totalRemoved > 0 then inventory.weight = inventory.weight - (itemTemplate.weight * totalRemoved) SaveQueue[identifier] = not TempInventories[identifier] SendLog('removeitem', { identifier = inventory.identifier, invLabel = inventory.label, itemLabel = itemTemplate.label, amount = totalRemoved, invoked = invoked, }) if ActivePlayersByIdentifier[identifier] then onRemoveItem(ActivePlayersByIdentifier[identifier], item, totalRemoved, nil, GetAmount(identifier, item)) end return true, totalRemoved end end return false, 'noitem' end exports('RemoveItem', RemoveItem) exportHandler('RemoveItem', RemoveItem) ]] loadFunction = loadFunction(removeItemCode) loadFunction() end xpcall(LoadRemoveItem, pError)
    muito bom tirou onda
×
×
  • Create New...

Important Information

By continuing on Launcherleaks.net, you agree to our Terms of Use, Guidelines & Privacy Policy