Files
VnUtest/garrysmod/gamemodes/militaryrp/plugins/carrying/sh_plugin.lua
2026-03-31 10:27:04 +03:00

54 lines
1.9 KiB
Lua

local PLUGIN = PLUGIN
PLUGIN.name = "Carrying Entities"
PLUGIN.author = "Scripty"
PLUGIN.description = "Позволяет игрокам поднимать любые энтити на клавишу E через стандартную механику."
-- Список классов, которые ЗАПРЕЩЕНО поднимать
local BLACKLIST = {
["player"] = true,
["worldspawn"] = true,
["func_door"] = true,
["func_door_rotating"] = true,
["prop_door_rotating"] = true,
["func_movelinear"] = true,
["prop_dynamic"] = true,
["ix_vendor"] = true,
["gmod_hands"] = true,
["viewmodel"] = true
}
if SERVER then
-- Этот хук вызывается ядром Helix во время GM:AllowPlayerPickup
function PLUGIN:CanPlayerPickupEntity(client, entity)
if (!IsValid(entity) or entity:IsPlayer() or entity:IsWorld()) then
return false
end
local class = entity:GetClass()
if (BLACKLIST[class]) then
return false
end
-- Проверка защиты Helix (Prop Protection)
local char = client:GetCharacter()
local owner = entity:GetNetVar("owner", 0)
-- Разрешаем владельцу, админу или если объект ничей
if (owner == 0 or (char and owner == char:GetID()) or client:IsAdmin()) then
local phys = entity:GetPhysicsObject()
-- Разрешаем подбирать только то, что имеет физику
if (IsValid(phys) and phys:IsMoveable()) then
return true
end
-- Прямое разрешение для пакетов крови (если физика считается не-moveable)
if (class == "bloodbag_medicmod") then
return true
end
end
return false
end
end