local PLUGIN = PLUGIN

PLUGIN.name = "Weapon Kits"
PLUGIN.author = "Scripty"
PLUGIN.description = "Adds weapon kits for specific user groups with cooldowns."

ix.util.Include("sv_plugin.lua")
ix.util.Include("cl_plugin.lua")

PLUGIN.kits = PLUGIN.kits or {}

ix.command.Add("KitMenu", {
	description = "Open the weapon kit selection menu.",
	OnRun = function(self, client)
		local character = client:GetCharacter()
		if (!character) then return end

		local allowedGroups = {
			["superadmin"] = true,
			["sponsor"] = true,
			["prem"] = true
		}

		if (!allowedGroups[client:GetUserGroup()]) then
			return "У вас нет доступа к этому меню."
		end

		net.Start("ixKitMenu")
		net.Send(client)
	end
})

ix.command.Add("KitAdd", {
	description = "Add a new weapon kit (Admin only).",
	privilege = "Manage Kits",
	adminOnly = true,
	arguments = {
		ix.type.string,
		ix.type.number
	},
	OnRun = function(self, client, weaponClass, cooldown)
		local weaponTable = weapons.GetStored(weaponClass)
		if (!weaponTable) then
			return "Некорректный класс оружия."
		end

		PLUGIN.kits[weaponClass] = {
			name = weaponTable.PrintName or weaponClass,
			cooldown = cooldown -- in seconds
		}

		if (SERVER) then
			PLUGIN:SaveData()
			PLUGIN:SyncKits()
		end

		return "Вы добавили набор: " .. (weaponTable.PrintName or weaponClass) .. " с КД " .. (cooldown / 60) .. " мин."
	end
})

ix.command.Add("KitRemove", {
	description = "Remove a weapon kit (Admin only).",
	privilege = "Manage Kits",
	adminOnly = true,
	arguments = {
		ix.type.string
	},
	OnRun = function(self, client, weaponClass)
		if (!PLUGIN.kits[weaponClass]) then
			return "Такого набора не существует."
		end

		PLUGIN.kits[weaponClass] = nil

		if (SERVER) then
			PLUGIN:SaveData()
			PLUGIN:SyncKits()
		end

		return "Вы удалили набор: " .. weaponClass
	end
})

