From ada6371905e208e1f4e9e2f745de81acfb9a13dc Mon Sep 17 00:00:00 2001 From: Afireal Date: Sun, 30 Mar 2025 14:25:23 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/weapons/gmod_tool/stools/permanent.lua | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lua/weapons/gmod_tool/stools/permanent.lua diff --git a/lua/weapons/gmod_tool/stools/permanent.lua b/lua/weapons/gmod_tool/stools/permanent.lua new file mode 100644 index 0000000..8efcb9e --- /dev/null +++ b/lua/weapons/gmod_tool/stools/permanent.lua @@ -0,0 +1,80 @@ + +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 + + local id = tr.Entity:GetNWString("Permaents.ID", false) + + 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 + + local id = tr.Entity:GetNWString("Permaents.ID") + + 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 + + draw.SimpleTextOutlined(trace.Entity:GetNWString("Permaents.ID"), "GModNotify", x, y, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + draw.SimpleTextOutlined(trace.Entity:GetNWString("Permaents.Creator"), "GModNotify", x, y + 25, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black) + +end \ No newline at end of file