Files
VnUtest/garrysmod/gamemodes/militaryrp/schema/items/consumables/sh_c4_bundle.lua
2026-03-31 10:27:04 +03:00

45 lines
1.2 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.
ITEM.name = "Комплект C4"
ITEM.desc = "Набор, содержащий детонатор и 3 заряда C4. Распакуйте для получения содержимого."
ITEM.category = "Снаряжение"
ITEM.model = "models/items/box_stack.mdl"
ITEM.width = 1
ITEM.height = 1
ITEM.functions.Unpack = {
name = "Распаковать",
onRun = function(item)
local client = item.player
local inventory = client:GetCharacter():GetInventory()
if not inventory or isnumber(inventory) then
client:Notify("Инвентарь еще не загрузился, подождите...")
return false
end
local successDet = inventory:Add("c4_detonator")
if not successDet then
client:Notify("Нет места в инвентаре для детонатора!")
return false
end
local count = 0
for i = 1, 3 do
if inventory:Add("c4_ammo") then
count = count + 1
else
break
end
end
if count < 3 then
client:Notify("Заряды добавлены частично (" .. count .. "/3), не хватило места!")
else
client:Notify("Вы распаковали комплект C4.")
end
return true
end,
onCanRun = function(item)
return !IsValid(item.entity)
end
}