From 02695ab5cb63a98aec4c4213c7efec74c6e29aa4 Mon Sep 17 00:00:00 2001 From: Kakarot <57848836+GhzGarage@users.noreply.github.com> Date: Sun, 29 Oct 2023 22:41:19 -0500 Subject: [PATCH] Update crafting This removes the hassle of adding code in the client/main for crafting --- .gitignore | 5 - .vscode/extensions.json | 9 - .vscode/settings.json | 4 - client/main.lua | 512 ++++++++++++++++++++-------------------- config.lua | 436 +++++++++++++++------------------- 5 files changed, 440 insertions(+), 526 deletions(-) delete mode 100644 .gitignore delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 405dc4a77..000000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Ignore any IDE derived project configs -.idea -.vscode/* -!.vscode/extensions.json -!.vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index be54ebf9e..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "recommendations": [ - "sumneko.lua", - "fivem-vscode.fivem-vscode", - "ihyajb.qbcore-code-snippets", - "eamodio.gitlens", - "GitHub.vscode-pull-request-github" - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4d79df9aa..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Lua.runtime.nonstandardSymbol": ["/**/", "`", "+=", "-=", "*=", "/="], - "Lua.runtime.version": "Lua 5.4" -} \ No newline at end of file diff --git a/client/main.lua b/client/main.lua index 7e99fa3e9..20bf1a107 100644 --- a/client/main.lua +++ b/client/main.lua @@ -28,7 +28,7 @@ local function HasItem(items, amount) local totalItems = #items local count = 0 local kvIndex = 2 - if isTable and not isArray then + if isTable and not isArray then totalItems = 0 for _ in pairs(items) do totalItems += 1 end kvIndex = 1 @@ -36,7 +36,7 @@ local function HasItem(items, amount) for _, itemData in pairs(PlayerData.items) do if isTable then for k, v in pairs(items) do - local itemKV = {k, v} + local itemKV = { k, v } if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) or (not isArray and itemData.amount >= v) or (not amount and isArray)) then count += 1 end @@ -53,7 +53,7 @@ local function HasItem(items, amount) return false end -exports("HasItem", HasItem) +exports('HasItem', HasItem) ---Gets the closest vending machine object to the client ---@return integer closestVendingMachine @@ -75,10 +75,10 @@ end ---Opens the vending machine shop local function OpenVending() local ShopItems = {} - ShopItems.label = "Vending Machine" + ShopItems.label = 'Vending Machine' ShopItems.items = Config.VendingItem ShopItems.slots = #Config.VendingItem - TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems) + TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems) end ---Draws 3d text in the world on the given position @@ -91,10 +91,10 @@ local function DrawText3Ds(x, y, z, text) SetTextFont(4) SetTextProportional(1) SetTextColour(255, 255, 255, 215) - SetTextEntry("STRING") + SetTextEntry('STRING') SetTextCentre(true) AddTextComponentString(text) - SetDrawOrigin(x,y,z, 0) + SetDrawOrigin(x, y, z, 0) DrawText(0.0, 0.0) local factor = string.len(text) / 370 DrawRect(0.0, 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75) @@ -124,7 +124,7 @@ local function FormatWeaponAttachments(itemdata) for key, value in pairs(exports['qb-weapons']:getConfigWeaponAttachments(itemdata.name)) do if value.component == v.component then local item = value.item - attachments[#attachments+1] = { + attachments[#attachments + 1] = { attachment = key, label = QBCore.Shared.Items[item].label --label = value.label @@ -147,8 +147,8 @@ end ---Opens the trunk of the closest vehicle local function OpenTrunk() local vehicle = QBCore.Functions.GetClosestVehicle() - LoadAnimDict("amb@prop_human_bum_bin@idle_b") - TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "idle_d", 4.0, 4.0, -1, 50, 0, false, false, false) + LoadAnimDict('amb@prop_human_bum_bin@idle_b') + TaskPlayAnim(PlayerPedId(), 'amb@prop_human_bum_bin@idle_b', 'idle_d', 4.0, 4.0, -1, 50, 0, false, false, false) if IsBackEngine(GetEntityModel(vehicle)) then SetVehicleDoorOpen(vehicle, 4, false, false) else @@ -159,8 +159,8 @@ end ---Closes the trunk of the closest vehicle local function CloseTrunk() local vehicle = QBCore.Functions.GetClosestVehicle() - LoadAnimDict("amb@prop_human_bum_bin@idle_b") - TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "exit", 4.0, 4.0, -1, 50, 0, false, false, false) + LoadAnimDict('amb@prop_human_bum_bin@idle_b') + TaskPlayAnim(PlayerPedId(), 'amb@prop_human_bum_bin@idle_b', 'exit', 4.0, 4.0, -1, 50, 0, false, false, false) if IsBackEngine(GetEntityModel(vehicle)) then SetVehicleDoorShut(vehicle, 4, false) else @@ -169,15 +169,15 @@ local function CloseTrunk() end ---Checks weight and size of the vehicle trunk local function GetTrunkSize(vehicleClass) - local trunkSize = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace["default"] + local trunkSize = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace['default'] return trunkSize[vehicleClass].maxweight, trunkSize[vehicleClass].slots end -exports("GetTrunkSize", GetTrunkSize) +exports('GetTrunkSize', GetTrunkSize) ---Closes the inventory NUI local function closeInventory() SendNUIMessage({ - action = "close", + action = 'close', }) end @@ -194,7 +194,7 @@ local function ToggleHotbar(toggle) } SendNUIMessage({ - action = "toggleHotbar", + action = 'toggleHotbar', open = toggle, items = HotbarItems }) @@ -203,108 +203,103 @@ end ---Plays the opening animation of the inventory local function openAnim() LoadAnimDict('pickup_object') - TaskPlayAnim(PlayerPedId(),'pickup_object', 'putdown_low', 5.0, 1.5, 1.0, 48, 0.0, 0, 0, 0) + TaskPlayAnim(PlayerPedId(), 'pickup_object', 'putdown_low', 5.0, 1.5, 1.0, 48, 0.0, 0, 0, 0) end ----Setup item info for items from Config.CraftingItems local function ItemsToItemInfo() - local itemInfos = { - [1] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 22x, " ..QBCore.Shared.Items["plastic"]["label"] .. ": 32x."}, - [2] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 30x, " ..QBCore.Shared.Items["plastic"]["label"] .. ": 42x."}, - [3] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 30x, " ..QBCore.Shared.Items["plastic"]["label"] .. ": 45x, "..QBCore.Shared.Items["aluminum"]["label"] .. ": 28x."}, - [4] = {costs = QBCore.Shared.Items["electronickit"]["label"] .. ": 2x, " ..QBCore.Shared.Items["plastic"]["label"] .. ": 52x, "..QBCore.Shared.Items["steel"]["label"] .. ": 40x."}, - [5] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 10x, " ..QBCore.Shared.Items["plastic"]["label"] .. ": 50x, "..QBCore.Shared.Items["aluminum"]["label"] .. ": 30x, "..QBCore.Shared.Items["iron"]["label"] .. ": 17x, "..QBCore.Shared.Items["electronickit"]["label"] .. ": 1x."}, - [6] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 36x, " ..QBCore.Shared.Items["steel"]["label"] .. ": 24x, "..QBCore.Shared.Items["aluminum"]["label"] .. ": 28x."}, - [7] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 32x, " ..QBCore.Shared.Items["steel"]["label"] .. ": 43x, "..QBCore.Shared.Items["plastic"]["label"] .. ": 61x."}, - [8] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 50x, " ..QBCore.Shared.Items["steel"]["label"] .. ": 37x, "..QBCore.Shared.Items["copper"]["label"] .. ": 26x."}, - [9] = {costs = QBCore.Shared.Items["iron"]["label"] .. ": 60x, " ..QBCore.Shared.Items["glass"]["label"] .. ": 30x."}, - [10] = {costs = QBCore.Shared.Items["aluminum"]["label"] .. ": 60x, " ..QBCore.Shared.Items["glass"]["label"] .. ": 30x."}, - [11] = {costs = QBCore.Shared.Items["iron"]["label"] .. ": 33x, " ..QBCore.Shared.Items["steel"]["label"] .. ": 44x, "..QBCore.Shared.Items["plastic"]["label"] .. ": 55x, "..QBCore.Shared.Items["aluminum"]["label"] .. ": 22x."}, - [12] = {costs = QBCore.Shared.Items["iron"]["label"] .. ": 50x, " ..QBCore.Shared.Items["steel"]["label"] .. ": 50x, "..QBCore.Shared.Items["screwdriverset"]["label"] .. ": 3x, "..QBCore.Shared.Items["advancedlockpick"]["label"] .. ": 2x."}, - } - - local items = {} - for _, item in pairs(Config.CraftingItems) do - local itemInfo = QBCore.Shared.Items[item.name:lower()] - items[item.slot] = { - name = itemInfo["name"], - amount = tonumber(item.amount), - info = itemInfos[item.slot], - label = itemInfo["label"], - description = itemInfo["description"] or "", - weight = itemInfo["weight"], - type = itemInfo["type"], - unique = itemInfo["unique"], - useable = itemInfo["useable"], - image = itemInfo["image"], - slot = item.slot, - costs = item.costs, - threshold = item.threshold, - points = item.points, - } - end - Config.CraftingItems = items + local items = {} + for i = 1, #Config.CraftingItems do + local craftingItem = Config.CraftingItems[i] + local itemInfo = QBCore.Shared.Items[craftingItem.name:lower()] + if itemInfo then + local itemCost = {} + for material, amount in pairs(craftingItem.costs) do + local materialInfo = QBCore.Shared.Items[material:lower()] + if materialInfo then + itemCost[#itemCost + 1] = materialInfo.label .. ': ' .. amount .. 'x' + end + end + local itemCostString = table.concat(itemCost, ', ') + items[i] = { + name = itemInfo.name, + amount = tonumber(craftingItem.amount), + info = { costs = itemCostString }, + label = itemInfo.label, + description = itemInfo.description or '', + weight = itemInfo.weight, + type = itemInfo.type, + unique = itemInfo.unique, + useable = itemInfo.useable, + image = itemInfo.image, + slot = i, + costs = craftingItem.costs, + threshold = craftingItem.threshold, + points = craftingItem.points, + } + end + end + Config.CraftingItems = items end ----Setup item info for items from Config.AttachmentCrafting["items"] local function SetupAttachmentItemsInfo() - local itemInfos = { - [1] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 140x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 250x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 60x"}, - [2] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 165x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 285x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 75x"}, - [3] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 190x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 305x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 85x, " .. QBCore.Shared.Items["smg_extendedclip"]["label"] .. ": 1x"}, - [4] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 205x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 340x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 110x, " .. QBCore.Shared.Items["smg_extendedclip"]["label"] .. ": 2x"}, - [5] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 230x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 365x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 130x"}, - [6] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 255x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 390x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 145x"}, - [7] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 270x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 435x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 155x"}, - [8] = {costs = QBCore.Shared.Items["metalscrap"]["label"] .. ": 300x, " .. QBCore.Shared.Items["steel"]["label"] .. ": 469x, " .. QBCore.Shared.Items["rubber"]["label"] .. ": 170x"}, - } - - local items = {} - for _, item in pairs(Config.AttachmentCrafting["items"]) do - local itemInfo = QBCore.Shared.Items[item.name:lower()] - items[item.slot] = { - name = itemInfo["name"], - amount = tonumber(item.amount), - info = itemInfos[item.slot], - label = itemInfo["label"], - description = itemInfo["description"] or "", - weight = itemInfo["weight"], - unique = itemInfo["unique"], - useable = itemInfo["useable"], - image = itemInfo["image"], - slot = item.slot, - costs = item.costs, - threshold = item.threshold, - points = item.points, - } - end - Config.AttachmentCrafting["items"] = items + local items = {} + for i = 1, #Config.AttachmentCrafting do + local attachmentItem = Config.AttachmentCrafting[i] + local itemInfo = QBCore.Shared.Items[attachmentItem.name:lower()] + if itemInfo then + local itemCost = {} + for material, amount in pairs(attachmentItem.costs) do + local materialInfo = QBCore.Shared.Items[material:lower()] + if materialInfo then + itemCost[#itemCost + 1] = materialInfo.label .. ': ' .. amount .. 'x' + end + end + local itemCostString = table.concat(itemCost, ', ') + items[i] = { + name = itemInfo.name, + amount = tonumber(attachmentItem.amount), + info = { costs = itemCostString }, + label = itemInfo.label, + description = itemInfo.description or '', + weight = itemInfo.weight, + type = itemInfo.type, + unique = itemInfo.unique, + useable = itemInfo.useable, + image = itemInfo.image, + slot = i, + costs = attachmentItem.costs, + threshold = attachmentItem.threshold, + points = attachmentItem.points, + } + end + end + Config.AttachmentCrafting = items end ---Runs ItemsToItemInfo() and checks if the client has enough reputation to support the threshold, otherwise the items is not available to craft for the client ---@return table items local function GetThresholdItems() - ItemsToItemInfo() - local items = {} - for k in pairs(Config.CraftingItems) do - if PlayerData.metadata["craftingrep"] >= Config.CraftingItems[k].threshold then - items[k] = Config.CraftingItems[k] - end - end - return items + ItemsToItemInfo() + local items = {} + for i = 1, #Config.CraftingItems do + if PlayerData.metadata['craftingrep'] >= Config.CraftingItems[i].threshold then + items[i] = Config.CraftingItems[i] + end + end + return items end ---Runs SetupAttachmentItemsInfo() and checks if the client has enough reputation to support the threshold, otherwise the items is not available to craft for the client ---@return table items local function GetAttachmentThresholdItems() - SetupAttachmentItemsInfo() - local items = {} - for k in pairs(Config.AttachmentCrafting["items"]) do - if PlayerData.metadata["attachmentcraftingrep"] >= Config.AttachmentCrafting["items"][k].threshold then - items[k] = Config.AttachmentCrafting["items"][k] - end - end - return items + SetupAttachmentItemsInfo() + local items = {} + for i = 1, #Config.AttachmentCrafting do + if PlayerData.metadata['attachmentcraftingrep'] >= Config.AttachmentCrafting[i].threshold then + items[i] = Config.AttachmentCrafting[i] + end + end + return items end ---Removes drops in the area of the client @@ -340,20 +335,20 @@ local function CreateItemDrop(index) DropsNear[index].isDropShowing = true PlaceObjectOnGroundProperly(dropItem) FreezeEntityPosition(dropItem, true) - if Config.UseTarget then - exports['qb-target']:AddTargetEntity(dropItem, { - options = { - { - icon = 'fas fa-backpack', - label = Lang:t("menu.o_bag"), - action = function() - TriggerServerEvent("inventory:server:OpenInventory", "drop", index) - end, - } - }, - distance = 2.5, - }) - end + if Config.UseTarget then + exports['qb-target']:AddTargetEntity(dropItem, { + options = { + { + icon = 'fas fa-backpack', + label = Lang:t('menu.o_bag'), + action = function() + TriggerServerEvent('inventory:server:OpenInventory', 'drop', index) + end, + } + }, + distance = 2.5, + }) + end end --#endregion Functions @@ -361,15 +356,15 @@ end --#region Events RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() - LocalPlayer.state:set("inv_busy", false, true) + LocalPlayer.state:set('inv_busy', false, true) PlayerData = QBCore.Functions.GetPlayerData() - QBCore.Functions.TriggerCallback("inventory:server:GetCurrentDrops", function(theDrops) - Drops = theDrops + QBCore.Functions.TriggerCallback('inventory:server:GetCurrentDrops', function(theDrops) + Drops = theDrops end) end) RegisterNetEvent('QBCore:Client:OnPlayerUnload', function() - LocalPlayer.state:set("inv_busy", true, true) + LocalPlayer.state:set('inv_busy', true, true) PlayerData = {} RemoveAllNearbyDrops() end) @@ -387,25 +382,25 @@ AddEventHandler('onResourceStop', function(name) if Config.UseItemDrop then RemoveAllNearbyDrops() end end) -RegisterNetEvent("qb-inventory:client:closeinv", function() +RegisterNetEvent('qb-inventory:client:closeinv', function() closeInventory() end) RegisterNetEvent('inventory:client:CheckOpenState', function(type, id, label) - local name = QBCore.Shared.SplitStr(label, "-")[2] - if type == "stash" then + local name = QBCore.Shared.SplitStr(label, '-')[2] + if type == 'stash' then if name ~= CurrentStash or CurrentStash == nil then TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id) end - elseif type == "trunk" then + elseif type == 'trunk' then if name ~= CurrentVehicle or CurrentVehicle == nil then TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id) end - elseif type == "glovebox" then + elseif type == 'glovebox' then if name ~= CurrentGlovebox or CurrentGlovebox == nil then TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id) end - elseif type == "drop" then + elseif type == 'drop' then if name ~= CurrentDrop or CurrentDrop == nil then TriggerServerEvent('inventory:server:SetIsOpenState', false, type, id) end @@ -414,7 +409,7 @@ end) RegisterNetEvent('inventory:client:ItemBox', function(itemData, type) SendNUIMessage({ - action = "itemBox", + action = 'itemBox', item = itemData, type = type }) @@ -424,16 +419,16 @@ RegisterNetEvent('inventory:client:requiredItems', function(items, bool) local itemTable = {} if bool then for k in pairs(items) do - itemTable[#itemTable+1] = { + itemTable[#itemTable + 1] = { item = items[k].name, - label = QBCore.Shared.Items[items[k].name]["label"], + label = QBCore.Shared.Items[items[k].name]['label'], image = items[k].image, } end end SendNUIMessage({ - action = "requiredItem", + action = 'requiredItem', items = itemTable, toggle = bool }) @@ -441,7 +436,7 @@ end) RegisterNetEvent('inventory:server:RobPlayer', function(TargetId) SendNUIMessage({ - action = "RobMoney", + action = 'RobMoney', TargetId = TargetId, }) end) @@ -454,7 +449,7 @@ RegisterNetEvent('inventory:client:OpenInventory', function(PlayerAmmo, inventor currentOtherInventory = other.name end SendNUIMessage({ - action = "open", + action = 'open', inventory = inventory, slots = Config.MaxInventorySlots, other = other, @@ -468,7 +463,7 @@ end) RegisterNetEvent('inventory:client:UpdatePlayerInventory', function(isError) SendNUIMessage({ - action = "update", + action = 'update', inventory = PlayerData.items, maxweight = Config.MaxInventoryWeight, slots = Config.MaxInventorySlots, @@ -479,73 +474,73 @@ end) RegisterNetEvent('inventory:client:CraftItems', function(itemName, itemCosts, amount, toSlot, points) local ped = PlayerPedId() SendNUIMessage({ - action = "close", + action = 'close', }) isCrafting = true - QBCore.Functions.Progressbar("repair_vehicle", Lang:t("progress.crafting"), (math.random(2000, 5000) * amount), false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, { - animDict = "mini@repair", - anim = "fixing_a_player", - flags = 16, - }, {}, {}, function() -- Done - StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0) - TriggerServerEvent("inventory:server:CraftItems", itemName, itemCosts, amount, toSlot, points) - TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add') - isCrafting = false - end, function() -- Cancel - StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0) - QBCore.Functions.Notify(Lang:t("notify.failed"), "error") - isCrafting = false - end) + QBCore.Functions.Progressbar('repair_vehicle', Lang:t('progress.crafting'), (math.random(2000, 5000) * amount), false, true, { + disableMovement = true, + disableCarMovement = true, + disableMouse = false, + disableCombat = true, + }, { + animDict = 'mini@repair', + anim = 'fixing_a_player', + flags = 16, + }, {}, {}, function() -- Done + StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0) + TriggerServerEvent('inventory:server:CraftItems', itemName, itemCosts, amount, toSlot, points) + TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add') + isCrafting = false + end, function() -- Cancel + StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0) + QBCore.Functions.Notify(Lang:t('notify.failed'), 'error') + isCrafting = false + end) end) RegisterNetEvent('inventory:client:CraftAttachment', function(itemName, itemCosts, amount, toSlot, points) local ped = PlayerPedId() SendNUIMessage({ - action = "close", + action = 'close', }) isCrafting = true - QBCore.Functions.Progressbar("repair_vehicle", Lang:t("progress.crafting"), (math.random(2000, 5000) * amount), false, true, { - disableMovement = true, - disableCarMovement = true, - disableMouse = false, - disableCombat = true, - }, { - animDict = "mini@repair", - anim = "fixing_a_player", - flags = 16, - }, {}, {}, function() -- Done - StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0) - TriggerServerEvent("inventory:server:CraftAttachment", itemName, itemCosts, amount, toSlot, points) - TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add') - isCrafting = false - end, function() -- Cancel - StopAnimTask(ped, "mini@repair", "fixing_a_player", 1.0) - QBCore.Functions.Notify(Lang:t("notify.failed"), "error") - isCrafting = false - end) + QBCore.Functions.Progressbar('repair_vehicle', Lang:t('progress.crafting'), (math.random(2000, 5000) * amount), false, true, { + disableMovement = true, + disableCarMovement = true, + disableMouse = false, + disableCombat = true, + }, { + animDict = 'mini@repair', + anim = 'fixing_a_player', + flags = 16, + }, {}, {}, function() -- Done + StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0) + TriggerServerEvent('inventory:server:CraftAttachment', itemName, itemCosts, amount, toSlot, points) + TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'add') + isCrafting = false + end, function() -- Cancel + StopAnimTask(ped, 'mini@repair', 'fixing_a_player', 1.0) + QBCore.Functions.Notify(Lang:t('notify.failed'), 'error') + isCrafting = false + end) end) RegisterNetEvent('inventory:client:PickupSnowballs', function() local ped = PlayerPedId() LoadAnimDict('anim@mp_snowball') TaskPlayAnim(ped, 'anim@mp_snowball', 'pickup_snowball', 3.0, 3.0, -1, 0, 1, 0, 0, 0) - QBCore.Functions.Progressbar("pickupsnowball", Lang:t("progress.snowballs"), 1500, false, true, { + QBCore.Functions.Progressbar('pickupsnowball', Lang:t('progress.snowballs'), 1500, false, true, { disableMovement = true, disableCarMovement = true, disableMouse = false, disableCombat = true, }, {}, {}, {}, function() -- Done ClearPedTasks(ped) - TriggerServerEvent('inventory:server:snowball', 'add') - TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items["snowball"], "add") + TriggerServerEvent('inventory:server:snowball', 'add') + TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items['snowball'], 'add') end, function() -- Cancel ClearPedTasks(ped) - QBCore.Functions.Notify(Lang:t("notify.canceled"), "error") + QBCore.Functions.Notify(Lang:t('notify.canceled'), 'error') end) end) @@ -559,14 +554,14 @@ RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool) RemoveAllPedWeapons(ped, true) TriggerEvent('weapons:client:SetCurrentWeapon', nil, shootbool) currentWeapon = nil - elseif weaponName == "weapon_stickybomb" or weaponName == "weapon_pipebomb" or weaponName == "weapon_smokegrenade" or weaponName == "weapon_flare" or weaponName == "weapon_proxmine" or weaponName == "weapon_ball" or weaponName == "weapon_molotov" or weaponName == "weapon_grenade" or weaponName == "weapon_bzgas" then + elseif weaponName == 'weapon_stickybomb' or weaponName == 'weapon_pipebomb' or weaponName == 'weapon_smokegrenade' or weaponName == 'weapon_flare' or weaponName == 'weapon_proxmine' or weaponName == 'weapon_ball' or weaponName == 'weapon_molotov' or weaponName == 'weapon_grenade' or weaponName == 'weapon_bzgas' then TriggerEvent('weapons:client:DrawWeapon', weaponName) GiveWeaponToPed(ped, weaponHash, 1, false, false) SetPedAmmo(ped, weaponHash, 1) SetCurrentPedWeapon(ped, weaponHash, true) TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool) currentWeapon = weaponName - elseif weaponName == "weapon_snowball" then + elseif weaponName == 'weapon_snowball' then TriggerEvent('weapons:client:DrawWeapon', weaponName) GiveWeaponToPed(ped, weaponHash, 10, false, false) SetPedAmmo(ped, weaponHash, 10) @@ -579,7 +574,7 @@ RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool) TriggerEvent('weapons:client:SetCurrentWeapon', weaponData, shootbool) local ammo = tonumber(weaponData.info.ammo) or 0 - if weaponName == "weapon_petrolcan" or weaponName == "weapon_fireextinguisher" then + if weaponName == 'weapon_petrolcan' or weaponName == 'weapon_fireextinguisher' then ammo = 4000 end @@ -632,10 +627,10 @@ end) RegisterNetEvent('inventory:client:DropItemAnim', function() local ped = PlayerPedId() SendNUIMessage({ - action = "close", + action = 'close', }) - LoadAnimDict("pickup_object") - TaskPlayAnim(ped, "pickup_object" ,"pickup_low" ,8.0, -8.0, -1, 1, 0, false, false, false ) + LoadAnimDict('pickup_object') + TaskPlayAnim(ped, 'pickup_object', 'pickup_low', 8.0, -8.0, -1, 1, 0, false, false, false) Wait(2000) ClearPedTasks(ped) end) @@ -646,18 +641,18 @@ end) RegisterNetEvent('qb-inventory:client:giveAnim', function() if IsPedInAnyVehicle(PlayerPedId(), false) then - return + return else - LoadAnimDict('mp_common') - TaskPlayAnim(PlayerPedId(), 'mp_common', 'givetake1_b', 8.0, 1.0, -1, 16, 0, 0, 0, 0) + LoadAnimDict('mp_common') + TaskPlayAnim(PlayerPedId(), 'mp_common', 'givetake1_b', 8.0, 1.0, -1, 16, 0, 0, 0, 0) end end) -RegisterNetEvent('inventory:client:craftTarget',function() +RegisterNetEvent('inventory:client:craftTarget', function() local crafting = {} - crafting.label = Lang:t("label.craft") + crafting.label = Lang:t('label.craft') crafting.items = GetThresholdItems() - TriggerServerEvent("inventory:server:OpenInventory", "crafting", math.random(1, 99), crafting) + TriggerServerEvent('inventory:server:OpenInventory', 'crafting', math.random(1, 99), crafting) end) --#endregion Events @@ -671,7 +666,7 @@ end, false) RegisterCommand('inventory', function() if IsNuiFocused() then return end if not isCrafting and not inInventory then - if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] and not IsPauseMenuActive() then + if not PlayerData.metadata['isdead'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['ishandcuffed'] and not IsPauseMenuActive() then local ped = PlayerPedId() local curVeh = nil local VendingMachine = nil @@ -687,7 +682,7 @@ RegisterCommand('inventory', function() if vehicle ~= 0 and vehicle ~= nil then local pos = GetEntityCoords(ped) local dimensionMin, dimensionMax = GetModelDimensions(GetEntityModel(vehicle)) - local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMin.y), 0.0) + local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMin.y), 0.0) if (IsBackEngine(GetEntityModel(vehicle))) then trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMax.y), 0.0) end @@ -697,7 +692,7 @@ RegisterCommand('inventory', function() curVeh = vehicle CurrentGlovebox = nil else - QBCore.Functions.Notify(Lang:t("notify.vlocked"), "error") + QBCore.Functions.Notify(Lang:t('notify.vlocked'), 'error') return end else @@ -710,59 +705,59 @@ RegisterCommand('inventory', function() if CurrentVehicle then -- Trunk local vehicleClass = GetVehicleClass(curVeh) - local trunkConfig = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace["default"] - if not trunkConfig then return print("Cannot get the vehicle trunk config") end + local trunkConfig = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace['default'] + if not trunkConfig then return print('Cannot get the vehicle trunk config') end local slots = trunkConfig.slots local maxweight = trunkConfig.maxWeight - if not slots or not maxweight then return print("Cannot get the vehicle slots and maxweight") end + if not slots or not maxweight then return print('Cannot get the vehicle slots and maxweight') end local other = { maxweight = maxweight, slots = slots, } - TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other) + TriggerServerEvent('inventory:server:OpenInventory', 'trunk', CurrentVehicle, other) OpenTrunk() elseif CurrentGlovebox then - TriggerServerEvent("inventory:server:OpenInventory", "glovebox", CurrentGlovebox) + TriggerServerEvent('inventory:server:OpenInventory', 'glovebox', CurrentGlovebox) elseif CurrentDrop ~= 0 then - TriggerServerEvent("inventory:server:OpenInventory", "drop", CurrentDrop) + TriggerServerEvent('inventory:server:OpenInventory', 'drop', CurrentDrop) elseif VendingMachine then local ShopItems = {} - ShopItems.label = "Vending Machine" + ShopItems.label = 'Vending Machine' ShopItems.items = Config.VendingItem ShopItems.slots = #Config.VendingItem - TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems) + TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems) else openAnim() - TriggerServerEvent("inventory:server:OpenInventory") + TriggerServerEvent('inventory:server:OpenInventory') end end end end, false) -RegisterKeyMapping('inventory', Lang:t("inf_mapping.opn_inv"), 'keyboard', Config.KeyBinds.Inventory) +RegisterKeyMapping('inventory', Lang:t('inf_mapping.opn_inv'), 'keyboard', Config.KeyBinds.Inventory) RegisterCommand('hotbar', function() isHotbar = not isHotbar - if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] and not IsPauseMenuActive() then + if not PlayerData.metadata['isdead'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['ishandcuffed'] and not IsPauseMenuActive() then ToggleHotbar(isHotbar) end end, false) -RegisterKeyMapping('hotbar', Lang:t("inf_mapping.tog_slots"), 'keyboard', Config.KeyBinds.HotBar) +RegisterKeyMapping('hotbar', Lang:t('inf_mapping.tog_slots'), 'keyboard', Config.KeyBinds.HotBar) for i = 1, 6 do - RegisterCommand('slot' .. i,function() - if not PlayerData.metadata["isdead"] and not PlayerData.metadata["inlaststand"] and not PlayerData.metadata["ishandcuffed"] and not IsPauseMenuActive() and not LocalPlayer.state.inv_busy then + RegisterCommand('slot' .. i, function() + if not PlayerData.metadata['isdead'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['ishandcuffed'] and not IsPauseMenuActive() and not LocalPlayer.state.inv_busy then if i == 6 then i = Config.MaxInventorySlots end - TriggerServerEvent("inventory:server:UseItemSlot", i) - closeInventory() + TriggerServerEvent('inventory:server:UseItemSlot', i) + closeInventory() end end, false) - RegisterKeyMapping('slot' .. i, Lang:t("inf_mapping.use_item") .. i, 'keyboard', i) + RegisterKeyMapping('slot' .. i, Lang:t('inf_mapping.use_item') .. i, 'keyboard', i) end --#endregion Commands @@ -770,7 +765,7 @@ end --#region NUI RegisterNUICallback('RobMoney', function(data, cb) - TriggerServerEvent("police:server:RobPlayer", data.TargetId) + TriggerServerEvent('police:server:RobPlayer', data.TargetId) cb('ok') end) @@ -799,7 +794,7 @@ RegisterNUICallback('RemoveAttachment', function(data, cb) for _, pew in pairs(exports['qb-weapons']:getConfigWeaponAttachments(WeaponData.name:upper())) do if v.component == pew.component then local item = pew.item - Attachies[#Attachies+1] = { + Attachies[#Attachies + 1] = { attachment = pew.item, label = QBCore.Shared.Items[item].label, } @@ -822,8 +817,8 @@ RegisterNUICallback('getCombineItem', function(data, cb) cb(QBCore.Shared.Items[data.item]) end) -RegisterNUICallback("CloseInventory", function(_, cb) - if currentOtherInventory == "none-inv" then +RegisterNUICallback('CloseInventory', function(_, cb) + if currentOtherInventory == 'none-inv' then CurrentDrop = nil CurrentVehicle = nil CurrentGlovebox = nil @@ -835,16 +830,16 @@ RegisterNUICallback("CloseInventory", function(_, cb) end if CurrentVehicle ~= nil then CloseTrunk() - TriggerServerEvent("inventory:server:SaveInventory", "trunk", CurrentVehicle) + TriggerServerEvent('inventory:server:SaveInventory', 'trunk', CurrentVehicle) CurrentVehicle = nil elseif CurrentGlovebox ~= nil then - TriggerServerEvent("inventory:server:SaveInventory", "glovebox", CurrentGlovebox) + TriggerServerEvent('inventory:server:SaveInventory', 'glovebox', CurrentGlovebox) CurrentGlovebox = nil elseif CurrentStash ~= nil then - TriggerServerEvent("inventory:server:SaveInventory", "stash", CurrentStash) + TriggerServerEvent('inventory:server:SaveInventory', 'stash', CurrentStash) CurrentStash = nil else - TriggerServerEvent("inventory:server:SaveInventory", "drop", CurrentDrop) + TriggerServerEvent('inventory:server:SaveInventory', 'drop', CurrentDrop) CurrentDrop = nil end SetNuiFocus(false, false) @@ -852,12 +847,12 @@ RegisterNUICallback("CloseInventory", function(_, cb) cb('ok') end) -RegisterNUICallback("UseItem", function(data, cb) - TriggerServerEvent("inventory:server:UseItem", data.inventory, data.item) +RegisterNUICallback('UseItem', function(data, cb) + TriggerServerEvent('inventory:server:UseItem', data.inventory, data.item) cb('ok') end) -RegisterNUICallback("combineItem", function(data, cb) +RegisterNUICallback('combineItem', function(data, cb) Wait(150) TriggerServerEvent('inventory:server:combineItem', data.reward, data.fromItem, data.toItem) cb('ok') @@ -870,7 +865,7 @@ RegisterNUICallback('combineWithAnim', function(data, cb) local aLib = combineData.anim.lib local animText = combineData.anim.text local animTimeout = combineData.anim.timeOut - QBCore.Functions.Progressbar("combine_anim", animText, animTimeout, false, true, { + QBCore.Functions.Progressbar('combine_anim', animText, animTimeout, false, true, { disableMovement = false, disableCarMovement = true, disableMouse = false, @@ -884,38 +879,38 @@ RegisterNUICallback('combineWithAnim', function(data, cb) TriggerServerEvent('inventory:server:combineItem', combineData.reward, data.requiredItem, data.usedItem) end, function() -- Cancel StopAnimTask(ped, aDict, aLib, 1.0) - QBCore.Functions.Notify(Lang:t("notify.failed"), "error") + QBCore.Functions.Notify(Lang:t('notify.failed'), 'error') end) cb('ok') end) -RegisterNUICallback("SetInventoryData", function(data, cb) - TriggerServerEvent("inventory:server:SetInventoryData", data.fromInventory, data.toInventory, data.fromSlot, data.toSlot, data.fromAmount, data.toAmount) +RegisterNUICallback('SetInventoryData', function(data, cb) + TriggerServerEvent('inventory:server:SetInventoryData', data.fromInventory, data.toInventory, data.fromSlot, data.toSlot, data.fromAmount, data.toAmount) cb('ok') end) -RegisterNUICallback("PlayDropSound", function(_, cb) - PlaySound(-1, "CLICK_BACK", "WEB_NAVIGATION_SOUNDS_PHONE", 0, 0, 1) +RegisterNUICallback('PlayDropSound', function(_, cb) + PlaySound(-1, 'CLICK_BACK', 'WEB_NAVIGATION_SOUNDS_PHONE', 0, 0, 1) cb('ok') end) -RegisterNUICallback("PlayDropFail", function(_, cb) - PlaySound(-1, "Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds", 0, 0, 1) +RegisterNUICallback('PlayDropFail', function(_, cb) + PlaySound(-1, 'Place_Prop_Fail', 'DLC_Dmod_Prop_Editor_Sounds', 0, 0, 1) cb('ok') end) -RegisterNUICallback("GiveItem", function(data, cb) +RegisterNUICallback('GiveItem', function(data, cb) local player, distance = QBCore.Functions.GetClosestPlayer(GetEntityCoords(PlayerPedId())) if player ~= -1 and distance < 3 then if data.inventory == 'player' then local playerId = GetPlayerServerId(player) - SetCurrentPedWeapon(PlayerPedId(),'WEAPON_UNARMED',true) - TriggerServerEvent("inventory:server:GiveItem", playerId, data.item.name, data.amount, data.item.slot) + SetCurrentPedWeapon(PlayerPedId(), 'WEAPON_UNARMED', true) + TriggerServerEvent('inventory:server:GiveItem', playerId, data.item.name, data.amount, data.item.slot) else - QBCore.Functions.Notify(Lang:t("notify.notowned"), "error") + QBCore.Functions.Notify(Lang:t('notify.notowned'), 'error') end else - QBCore.Functions.Notify(Lang:t("notify.nonb"), "error") + QBCore.Functions.Notify(Lang:t('notify.nonb'), 'error') end cb('ok') end) @@ -928,11 +923,10 @@ CreateThread(function() while true do local sleep = 100 if DropsNear ~= nil then - local ped = PlayerPedId() - local closestDrop = nil - local closestDistance = nil + local ped = PlayerPedId() + local closestDrop = nil + local closestDistance = nil for k, v in pairs(DropsNear) do - if DropsNear[k] ~= nil then if Config.UseItemDrop then if not v.isDropShowing then @@ -943,21 +937,21 @@ CreateThread(function() DrawMarker(20, v.coords.x, v.coords.y, v.coords.z, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.15, 120, 10, 20, 155, false, false, false, 1, false, false, false) end - local coords = (v.object ~= nil and GetEntityCoords(v.object)) or vector3(v.coords.x, v.coords.y, v.coords.z) - local distance = #(GetEntityCoords(ped) - coords) - if distance < 2 and (not closestDistance or distance < closestDistance) then - closestDrop = k - closestDistance = distance - end + local coords = (v.object ~= nil and GetEntityCoords(v.object)) or vector3(v.coords.x, v.coords.y, v.coords.z) + local distance = #(GetEntityCoords(ped) - coords) + if distance < 2 and (not closestDistance or distance < closestDistance) then + closestDrop = k + closestDistance = distance + end end end - if not closestDrop then - CurrentDrop = 0 - else - CurrentDrop = closestDrop - end + if not closestDrop then + CurrentDrop = 0 + else + CurrentDrop = closestDrop + end end Wait(sleep) end @@ -993,8 +987,8 @@ CreateThread(function() exports['qb-target']:AddTargetModel(Config.VendingObjects, { options = { { - icon = "fa-solid fa-cash-register", - label = Lang:t("menu.vending"), + icon = 'fa-solid fa-cash-register', + label = Lang:t('menu.vending'), action = function() OpenVending() end @@ -1010,9 +1004,9 @@ CreateThread(function() exports['qb-target']:AddTargetModel(Config.CraftingObject, { options = { { - event = "inventory:client:craftTarget", - icon = "fas fa-tools", - label = Lang:t("menu.craft"), + event = 'inventory:client:craftTarget', + icon = 'fas fa-tools', + label = Lang:t('menu.craft'), }, }, distance = 2.5, @@ -1027,12 +1021,12 @@ CreateThread(function() local objectPos = GetEntityCoords(craftObject) if #(pos - objectPos) < 1.5 then sleep = 0 - DrawText3Ds(objectPos.x, objectPos.y, objectPos.z + 1.0, Lang:t("interaction.craft")) + DrawText3Ds(objectPos.x, objectPos.y, objectPos.z + 1.0, Lang:t('interaction.craft')) if IsControlJustReleased(0, 38) then local crafting = {} - crafting.label = Lang:t("label.craft") + crafting.label = Lang:t('label.craft') crafting.items = GetThresholdItems() - TriggerServerEvent("inventory:server:OpenInventory", "crafting", math.random(1, 99), crafting) + TriggerServerEvent('inventory:server:OpenInventory', 'crafting', math.random(1, 99), crafting) sleep = 100 end end @@ -1052,12 +1046,12 @@ CreateThread(function() if distance < 10 then if distance < 1.5 then sleep = 0 - DrawText3Ds(Config.AttachmentCraftingLocation.x, Config.AttachmentCraftingLocation.y, Config.AttachmentCraftingLocation.z, Lang:t("interaction.craft")) + DrawText3Ds(Config.AttachmentCraftingLocation.x, Config.AttachmentCraftingLocation.y, Config.AttachmentCraftingLocation.z, Lang:t('interaction.craft')) if IsControlJustPressed(0, 38) then local crafting = {} - crafting.label = Lang:t("label.a_craft") + crafting.label = Lang:t('label.a_craft') crafting.items = GetAttachmentThresholdItems() - TriggerServerEvent("inventory:server:OpenInventory", "attachment_crafting", math.random(1, 99), crafting) + TriggerServerEvent('inventory:server:OpenInventory', 'attachment_crafting', math.random(1, 99), crafting) sleep = 100 end end diff --git a/config.lua b/config.lua index 85d564430..d5990dc8a 100644 --- a/config.lua +++ b/config.lua @@ -2,46 +2,46 @@ Config = {} Config.UseTarget = GetConvar('UseTarget', 'false') == 'true' -- Use qb-target interactions (don't change this, go to your server.cfg and add `setr UseTarget true` to use this and just that from true to false or the other way around) -Config.MaxInventoryWeight = 120000 -- Max weight a player can carry (default 120kg, written in grams) -Config.MaxInventorySlots = 41 -- Max inventory slots for a player +Config.MaxInventoryWeight = 120000 -- Max weight a player can carry (default 120kg, written in grams) +Config.MaxInventorySlots = 41 -- Max inventory slots for a player Config.KeyBinds = { Inventory = 'TAB', HotBar = 'z' } -Config.CleanupDropTime = 15 * 60 -- How many seconds it takes for drops to be untouched before being deleted -Config.MaxDropViewDistance = 12.5 -- The distance in GTA Units that a drop can be seen -Config.UseItemDrop = false -- This will enable item object to spawn on drops instead of markers +Config.CleanupDropTime = 15 * 60 -- How many seconds it takes for drops to be untouched before being deleted +Config.MaxDropViewDistance = 12.5 -- The distance in GTA Units that a drop can be seen +Config.UseItemDrop = false -- This will enable item object to spawn on drops instead of markers Config.ItemDropObject = `prop_nigel_bag_pickup` -- if Config.UseItemDrop is true, this will be the prop that spawns for the item Config.VendingObjects = { - "prop_vend_soda_01", - "prop_vend_soda_02", - "prop_vend_water_01" + 'prop_vend_soda_01', + 'prop_vend_soda_02', + 'prop_vend_water_01' } Config.BinObjects = { - "prop_bin_05a", + 'prop_bin_05a', } Config.CraftingObject = `prop_toolchest_05` Config.VendingItem = { - [1] = { - name = "kurkakola", + { + name = 'kurkakola', price = 4, amount = 50, info = {}, - type = "item", + type = 'item', slot = 1, }, - [2] = { - name = "water_bottle", + { + name = 'water_bottle', price = 4, amount = 50, info = {}, - type = "item", + type = 'item', slot = 2, }, } @@ -50,7 +50,7 @@ Config.VendingItem = { -- The template: -- [vehicleClass] = {slots = [number], maxWeight = [number]} Config.TrunkSpace = { - ["default"] = { -- All the vehicle class that not listed here will use this as default + ['default'] = { -- All the vehicle class that not listed here will use this as default slots = 35, maxWeight = 60000 }, @@ -117,295 +117,233 @@ Config.TrunkSpace = { } Config.CraftingItems = { - [1] = { - name = "lockpick", + { + name = 'lockpick', amount = 50, - info = {}, - costs = { - ["metalscrap"] = 22, - ["plastic"] = 32, - }, - type = "item", - slot = 1, threshold = 0, points = 1, - }, - [2] = { - name = "screwdriverset", - amount = 50, - info = {}, costs = { - ["metalscrap"] = 30, - ["plastic"] = 42, + ['metalscrap'] = 22, + ['plastic'] = 32, }, - type = "item", - slot = 2, - threshold = 0, - points = 2, }, - [3] = { - name = "electronickit", + { + name = 'screwdriverset', amount = 50, - info = {}, + threshold = 0, + points = 2, costs = { - ["metalscrap"] = 30, - ["plastic"] = 45, - ["aluminum"] = 28, + ['metalscrap'] = 30, + ['plastic'] = 42, }, - type = "item", - slot = 3, - threshold = 0, - points = 3, }, - [4] = { - name = "radioscanner", + { + name = 'electronickit', amount = 50, - info = {}, + threshold = 0, + points = 3, costs = { - ["electronickit"] = 2, - ["plastic"] = 52, - ["steel"] = 40, + ['metalscrap'] = 30, + ['plastic'] = 45, + ['aluminum'] = 28, }, - type = "item", - slot = 4, - threshold = 0, - points = 4, }, - [5] = { - name = "gatecrack", + { + name = 'radioscanner', amount = 50, - info = {}, + threshold = 0, + points = 4, costs = { - ["metalscrap"] = 10, - ["plastic"] = 50, - ["aluminum"] = 30, - ["iron"] = 17, - ["electronickit"] = 2, + ['electronickit'] = 2, + ['plastic'] = 52, + ['steel'] = 40, }, - type = "item", - slot = 5, - threshold = 110, - points = 5, }, - [6] = { - name = "handcuffs", + { + name = 'gatecrack', amount = 50, - info = {}, + threshold = 110, + points = 5, costs = { - ["metalscrap"] = 36, - ["steel"] = 24, - ["aluminum"] = 28, + ['metalscrap'] = 10, + ['plastic'] = 50, + ['aluminum'] = 30, + ['iron'] = 17, + ['electronickit'] = 2, }, - type = "item", - slot = 6, - threshold = 160, - points = 6, }, - [7] = { - name = "repairkit", + { + name = 'handcuffs', amount = 50, - info = {}, + threshold = 160, + points = 6, costs = { - ["metalscrap"] = 32, - ["steel"] = 43, - ["plastic"] = 61, + ['metalscrap'] = 36, + ['steel'] = 24, + ['aluminum'] = 28, }, - type = "item", - slot = 7, - threshold = 200, - points = 7, }, - [8] = { - name = "pistol_ammo", + { + name = 'repairkit', amount = 50, - info = {}, + threshold = 200, + points = 7, costs = { - ["metalscrap"] = 50, - ["steel"] = 37, - ["copper"] = 26, + ['metalscrap'] = 32, + ['steel'] = 43, + ['plastic'] = 61, }, - type = "item", - slot = 8, - threshold = 250, - points = 8, }, - [9] = { - name = "ironoxide", + { + name = 'pistol_ammo', amount = 50, - info = {}, + threshold = 250, + points = 8, costs = { - ["iron"] = 60, - ["glass"] = 30, + ['metalscrap'] = 50, + ['steel'] = 37, + ['copper'] = 26, }, - type = "item", - slot = 9, - threshold = 300, - points = 9, }, - [10] = { - name = "aluminumoxide", + { + name = 'ironoxide', amount = 50, - info = {}, + threshold = 300, + points = 9, costs = { - ["aluminum"] = 60, - ["glass"] = 30, + ['iron'] = 60, + ['glass'] = 30, }, - type = "item", - slot = 10, - threshold = 300, - points = 10, }, - [11] = { - name = "armor", + { + name = 'aluminumoxide', amount = 50, - info = {}, + threshold = 300, + points = 10, costs = { - ["iron"] = 33, - ["steel"] = 44, - ["plastic"] = 55, - ["aluminum"] = 22, + ['aluminum'] = 60, + ['glass'] = 30, }, - type = "item", - slot = 11, - threshold = 350, - points = 11, }, - [12] = { - name = "drill", + { + name = 'armor', amount = 50, - info = {}, + threshold = 350, + points = 11, costs = { - ["iron"] = 50, - ["steel"] = 50, - ["screwdriverset"] = 3, - ["advancedlockpick"] = 2, + ['iron'] = 33, + ['steel'] = 44, + ['plastic'] = 55, + ['aluminum'] = 22, }, - type = "item", - slot = 12, + }, + { + name = 'drill', + amount = 50, threshold = 1750, points = 12, + costs = { + ['iron'] = 50, + ['steel'] = 50, + ['screwdriverset'] = 3, + ['advancedlockpick'] = 2, + }, }, } Config.AttachmentCraftingLocation = vector3(88.91, 3743.88, 40.77) Config.AttachmentCrafting = { - ["items"] = { - [1] = { - name = "pistol_extendedclip", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 140, - ["steel"] = 250, - ["rubber"] = 60, - }, - type = "item", - slot = 1, - threshold = 0, - points = 1, + { + name = 'pistol_extendedclip', + amount = 50, + threshold = 0, + points = 1, + costs = { + ['metalscrap'] = 140, + ['steel'] = 250, + ['rubber'] = 60, }, - [2] = { - name = "pistol_suppressor", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 165, - ["steel"] = 285, - ["rubber"] = 75, - }, - type = "item", - slot = 2, - threshold = 10, - points = 2, + }, + { + name = 'pistol_suppressor', + amount = 50, + threshold = 10, + points = 2, + costs = { + ['metalscrap'] = 165, + ['steel'] = 285, + ['rubber'] = 75, }, - [3] = { - name = "smg_extendedclip", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 190, - ["steel"] = 305, - ["rubber"] = 85, - }, - type = "item", - slot = 3, - threshold = 25, - points = 3, + }, + { + name = 'smg_extendedclip', + amount = 50, + threshold = 25, + points = 3, + costs = { + ['metalscrap'] = 190, + ['steel'] = 305, + ['rubber'] = 85, }, - [4] = { - name = "microsmg_extendedclip", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 205, - ["steel"] = 340, - ["rubber"] = 110, - }, - type = "item", - slot = 4, - threshold = 50, - points = 4, + }, + { + name = 'microsmg_extendedclip', + amount = 50, + threshold = 50, + points = 4, + costs = { + ['metalscrap'] = 205, + ['steel'] = 340, + ['rubber'] = 110, }, - [5] = { - name = "smg_drum", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 230, - ["steel"] = 365, - ["rubber"] = 130, - }, - type = "item", - slot = 5, - threshold = 75, - points = 5, + }, + { + name = 'smg_drum', + amount = 50, + threshold = 75, + points = 5, + costs = { + ['metalscrap'] = 230, + ['steel'] = 365, + ['rubber'] = 130, }, - [6] = { - name = "smg_scope", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 255, - ["steel"] = 390, - ["rubber"] = 145, - }, - type = "item", - slot = 6, - threshold = 100, - points = 6, + }, + { + name = 'smg_scope', + amount = 50, + threshold = 100, + points = 6, + costs = { + ['metalscrap'] = 255, + ['steel'] = 390, + ['rubber'] = 145, }, - [7] = { - name = "assaultrifle_extendedclip", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 270, - ["steel"] = 435, - ["rubber"] = 155, - ["smg_extendedclip"] = 1, - }, - type = "item", - slot = 7, - threshold = 150, - points = 7, + }, + { + name = 'assaultrifle_extendedclip', + amount = 50, + threshold = 150, + points = 7, + costs = { + ['metalscrap'] = 270, + ['steel'] = 435, + ['rubber'] = 155, + ['smg_extendedclip'] = 1, }, - [8] = { - name = "assaultrifle_drum", - amount = 50, - info = {}, - costs = { - ["metalscrap"] = 300, - ["steel"] = 469, - ["rubber"] = 170, - ["smg_extendedclip"] = 2, - }, - type = "item", - slot = 8, - threshold = 200, - points = 8, + }, + { + name = 'assaultrifle_drum', + amount = 50, + threshold = 200, + points = 8, + costs = { + ['metalscrap'] = 300, + ['steel'] = 469, + ['rubber'] = 170, + ['smg_extendedclip'] = 2, }, - } + }, } BackEngineVehicles = { @@ -450,8 +388,8 @@ BackEngineVehicles = { } Config.MaximumAmmoValues = { - ["pistol"] = 250, - ["smg"] = 250, - ["shotgun"] = 200, - ["rifle"] = 250, -} \ No newline at end of file + ['pistol'] = 250, + ['smg'] = 250, + ['shotgun'] = 200, + ['rifle'] = 250, +}