local QBCore = exports['qb-core']:GetCoreObject()

Config = Config or {}

Config.Debug = false
-- If true, the resource will automatically spawn a Gun Van on a random location. 
-- When stopping/restarting the resource, it will clean up the previous script-data.

-- If false, the resource will not spawn a Gun Van on resource-start.
-- You'll have to wait until the server triggers a Gun Van spawn.

Config.minutesBetweenVans = 180 -- This is the time between each Gun Van spawn. This is in minutes.
Config.duration = 10 -- This is in minutes. This is the duration of the Gun Van event. After this time, the Gun Van will despawn.

-- Make sure that minutesBetweenVans is higher than duration.
-- Otherwise multiple vans will spawn at the same time, before the previous one despawns.


-- Should the player be dropped, if they're more than 10 units away from the Gun Van?
-- Recommended to keep true, to avoid players from cheating and buying items from a distance.
Config.DropPlayer = false

-- Permission for using the Gun Van commands.
Config.Permission = "admin"

-- Function to trigger the emergency event. 
-- This is triggered, if "triggerCops" is set to true for the specific item.
Config.EmergencyTrigger = function()
    print("Trigger the emergency event.")
    -- exports['ps-dispatch']:SuspiciousActivity() -- Change this to your dispatch system.
end

-- Function to log the player's activity.
Config.LogHandler = function(msg)
    print(msg)
end

Config.NotifyEmpty = function(src, item)
    TriggerClientEvent('HudNotification', src, 'error', 'Gun Van', item.."? Jeg er sgu løbet tør makker....")
end

Config.NotifyNoMoney = function(src, item)
    TriggerClientEvent('HudNotification', src, 'error', 'Gun Van', "Du har ikke råd til at købe en "..item..".")
end

Config.Notify = function(src, item)
    TriggerClientEvent('HudNotification', src, 'success', 'Gun Van', 'Du købte en '..item)
end

Config.InventoryExport = function(src, item, amount) -- Change this to your inventory system.
    exports['ps-inventory']:AddItem(src, item, amount, false, { serie = "722"..tostring(QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(1) .. "GV" .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))})
end

Config.Lang = {
    OutsideRange = "prøvede at købe våben fra Gun Van udenfor rækkevidde.",
    OutsideRangeKick = "blev kicked fra serveren. Overskred maks-rækkevidde for anti-cheat.",
    OutsideRangeKickPlayer = "Du blev smidt ud. Du forsøgte at trigger Gun Van køb udenfor rækkevidde.",

    OutsideBuyHours = "prøvede at købe våben fra Gun Van udenfor spawn-tidspunktet.",
    TimeUntilNext = "Tid til næste gunvan:",
    Seconds = "sekunder",

    Buy = "Køb",
    Currency = ",-",
    ItemBought = "Du købte:",

    ForcedSpawn = "Der blev tvangs-spawnet en Gun Van her:",
    SpawnedBy = "Den blev spawned af",
    ForcedRemoved = "Der blev tvangs-destroyet en Gun Van her:",
    RemovedBy = "Den blev fjernet af",
}

-- If true, the resource will use the items from the Gun Van config, otherwise we use VanItems.
Config.perVanItems = true

Config.VanItems = {
    {
        label = "Pistol",
        item = "weapon_pistol",
        weaponType = "pistol",
        iAmount = 1,
        aAmount = math.random(1,4),
        price = 35000,
        triggerCops = true
    },
    {
        label = "Foldekniv",
        item = "weapon_switchblade",
        iAmount = 1,
        price = 5000,
        triggerCops = false
    }
}

--[[
   This is where you configure your gunvans.

   Here's a small schematic, of how the gunvans are configured, and what each value does
   * Means that the value is required.
   -- Means that the value is optional, and will either be false, 0 or replaced by a default value.

   ped: "ig_gunvanseller" - The ped that will be spawned at the gunvan. (Required) - If not set, it will default to "ig_gunvanseller"

   vehicles = { -- array
        {
            coords = vector3(-1400.00, -2720.0, 13.94), -- Vector3. The coords of the gunvan.
            heading = 0.00, -- The heading of the gunvan.
            items = { -- Items array
                {
                    label = "Pistol XM3", * The label of the item. - This is what the player will see in the menu.
                    item = "weapon_pistolxm3", * The name of the item from QBCore/Shared/Items.lua.
                    weaponType = "pistol", * Just to make sure, that if you use ammo, the correct ammo is given. If gun, specify the type of gun.
                    iAmount = 1, * The amount of the item that the gunvan will have in stock. Should never be 0.
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase. Remove if you don't want to give ammo
                    price = 35000, * The price of the item.
                    triggerCops = true -- If the item should trigger the emergency event. - If not set, it won't trigger.
                },
                { 
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    type = "blunt",
                    triggerCops = false
                }
            }
        },
   }
--]]

Config.Gunvans = {
    ped =  "ig_gunvanseller",
    vehicles = {
        {
            coords = vector3(-915.84, -2600.69, 31.6),
            heading = 328.98,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-1269.17, -2661.21, 13.94),
            heading = 329.6,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-1018.11, -2193.89, 8.98),
            heading = 352.8,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-559.84, -1799.59, 22.61),
            heading = 153.56,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-559.6, -1681.66, 19.31),
            heading = 350.13,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-1083.81, -1671.52, 4.7),
            heading = 126.03,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-1155.1, -1564.93, 4.43),
            heading = 168.59,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-659.96, -735.03, 31.27),
            heading = 327.81,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        { 
            coords = vector3(-1265.44, -820.3, 17.1),
            heading = 252.0,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-2021.38, -362.03, 44.11),
            heading = 208.51,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-1601.67, 3093.5, 32.57),
            heading = 323.71,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-2166.33, 4284.34, 48.96),
            heading = 332.96,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-598.55, 5349.68, 70.47),
            heading = 7.98,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-678.79, 5797.2, 17.33),
            heading = 64.67,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(-176.42, 6405.17, 31.86),
            heading = 225.81,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(1539.5, 6335.8, 23.81),
            heading = 241.77,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(2195.82, 5609.29, 53.33),
            heading = 166.43,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(1969.08, 5178.88, 47.6),
            heading = 334.39,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
        {
            coords = vector3(1296.1, 4331.41, 38.24),
            heading = 84.15,
            items = {
                {
                    label = "Pistol", -- Label of the item
                    item = "weapon_pistol", -- Name of the item from QBCore/Shared/Items.lua
                    weaponType = "pistol", -- Only used for ammo. Specify the type of gun.
                    iAmount = 1, -- The amount of the item that the gunvan will have in stock. Should never be 0, for obvious reasons?
                    aAmount = math.random(1,4), -- The amount of ammo that the gunvan will give to the player on purchase, if you don't want to give ammo, remove this line.
                    price = 35000, -- The price of the item. Don't remove this, just set it to 0 if you want it to be free.
                    triggerCops = true -- If cops should be alerted about a suspicious activity. If not set, it won't trigger Config.EmergencyTrigger
                },
                {
                    label = "Foldekniv",
                    item = "weapon_switchblade",
                    iAmount = 1,
                    price = 5000,
                    triggerCops = false
                }
            }
        },
    }
}