Files
2026-03-31 10:27:04 +03:00

65 lines
2.3 KiB
Lua

local PLUGIN = PLUGIN
PLUGIN.name = "Arsenal"
PLUGIN.author = "Refosel"
PLUGIN.description = "Arsenal plugin (skeleton) — выдача оружия, патронов и управление очками снабжения."
ix.util.Include("sh_config.lua")
ix.util.Include("cl_plugin.lua")
ix.util.Include("sv_plugin.lua")
ix.command.Add("test_arsenal", {
description = "Test arsenal weapon availability.",
OnRun = function(self, client)
local plugin = ix.plugin.list and ix.plugin.list["arsenal"]
if not plugin then return "Plugin not found" end
local char = client:GetCharacter()
if not char then return "No character" end
client:ChatPrint("--- Arsenal Test for " .. client:Nick() .. " ---")
local avail = plugin:GetAvailableWeapons(char)
client:ChatPrint("Available weapons total: " .. table.Count(avail))
for class, data in pairs(avail) do
client:ChatPrint(string.format(" [%s] %s (Donate: %s)", class, data.name or "N/A", tostring(data.isDonateVersion or false)))
end
client:ChatPrint("--- End Test ---")
end
})
ix.command.Add("arsenal_supply_set", {
description = "Set faction supply. Usage: arsenal_supply_set <amount> [faction id]",
adminOnly = true,
arguments = {
ix.type.number,
ix.type.number
},
OnRun = function(self, client, amount, faction)
if CLIENT then return end
local plugin = ix.plugin.list and ix.plugin.list["arsenal"]
if not plugin then return client:Notify("Arsenal plugin not loaded") end
local fid = faction or client:GetCharacter():GetFaction()
plugin:SetFactionSupply(fid, math.max(tonumber(amount) or 0, 0))
client:Notify("Set supply for faction " .. tostring(fid) .. " to " .. tostring(plugin:GetFactionSupply(fid)))
end
})
ix.command.Add("arsenal_supply_add", {
description = "Add (or subtract) supply for a faction. Usage: arsenal_supply_add <delta> [faction id]",
adminOnly = true,
arguments = {
ix.type.number,
ix.type.number
},
OnRun = function(self, client, delta, faction)
if CLIENT then return end
local plugin = ix.plugin.list and ix.plugin.list["arsenal"]
if not plugin then return client:Notify("Arsenal plugin not loaded") end
local fid = faction or client:GetCharacter():GetFaction()
plugin:AddFactionSupply(fid, tonumber(delta) or 0)
client:Notify("Faction " .. tostring(fid) .. " supply now: " .. tostring(plugin:GetFactionSupply(fid)))
end
})