3
0
Ответвление 0
permanent/lua/weapons/gmod_tool/stools/permanent.lua

79 строки
1,5 КиБ
Lua
Исходный Обычный вид История

2025-03-30 14:25:23 +05:00
TOOL.Name = "Permanent"
TOOL.Category = "Construction"
function TOOL:LeftClick(tr)
if CLIENT then return true end
local ply = self:GetOwner()
if !CAMI.PlayerHasAccess(ply, "Permanent") then return false end
if !IsValid(tr.Entity) then return end
if tr.Entity:IsWorld() || tr.Entity:CreatedByMap() then return end
2025-03-30 15:13:32 +05:00
local id = tr.Entity:GetNWString("Permanent.ID", false)
2025-03-30 14:25:23 +05:00
tr.Entity:MakePermanent(id, ply:SteamID())
return true
end
function TOOL:RightClick(tr)
if CLIENT then return true end
local ply = self:GetOwner()
if !CAMI.PlayerHasAccess(ply, "Permanent") then return false end
if !IsValid(tr.Entity) then return end
if tr.Entity:IsWorld() || tr.Entity:CreatedByMap() then return end
if !tr.Entity:GetNWBool("IsPermanent") then return end
2025-03-30 15:13:32 +05:00
local id = tr.Entity:GetNWString("Permanent.ID")
2025-03-30 14:25:23 +05:00
permanent.Remove(id)
tr.Entity:Remove()
return true
end
function TOOL:Reload()
if SERVER then return end
//
end
if SERVER then return end
TOOL.Information = {
{name = "left"},
{name = "right"},
{name = "reload"},
}
function TOOL:DrawHUD()
local tr = util.GetPlayerTrace(LocalPlayer())
local trace = util.TraceLine(tr)
if !(trace.Hit && trace.HitNonWorld) then return end
if !trace.Entity:GetNWBool("IsPermanent") then return end
local x, y = gui.MousePos()
if x == 0 && y == 0 then
x = ScrW()/2
y = ScrH()/2
end
2025-03-30 15:13:32 +05:00
draw.SimpleTextOutlined(trace.Entity:GetNWString("Permanent.ID"), "GModNotify", x, y + 16, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black)
2025-03-30 14:25:23 +05:00
end