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