Files
wnsrc/gamemodes/darkrp/plugins/ammolimit.lua
lifestorm 6a58f406b1 Upload
2024-08-04 23:54:45 +03:00

43 lines
1.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
PLUGIN.name = "Ammo Limit"
PLUGIN.author = "Gr4Ss"
PLUGIN.description = "Limit how much ammo can be loaded from ammo boxes."
ix.lang.AddTable("english", {
ammoLimitReached = "Mevcut mermi limitine ulaştınız!"
})
ix.config.Add("ammoBoxLimit", 4, "The maximum amount of ammo boxes someone is allowed to equip", nil, {
data = {min = 0, max = 10, decimals = 1},
category = "Other"
})
function PLUGIN:CanPlayerInteractItem(client, action, item, data)
if (isentity(item)) then
if (IsValid(item)) then
item = ix.item.instances[item.ixItemID]
else
return
end
elseif (isnumber(item)) then
item = ix.item.instances[item]
end
if (!item) then return end
if (action == "use" and item.ammo and item.ammoAmount and client:GetAmmoCount(item.ammo) >= item.ammoAmount * ix.config.Get("ammoBoxLimit")) then
client:NotifyLocalized("ammoLimitReached")
return false
end
end