79 строки
Без EOL
1,5 КиБ
Lua
79 строки
Без EOL
1,5 КиБ
Lua
|
|
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("Permanent.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("Permanent.ID")
|
|
|
|
permanent.Remove(id)
|
|
tr.Entity:Remove()
|
|
return true
|
|
|
|
end
|
|
|
|
function TOOL:Reload()
|
|
|
|
if SERVER then return end
|
|
|
|
permanent.OpenMenu()
|
|
|
|
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("Permanent.ID"), "GModNotify", x, y + 16, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black)
|
|
|
|
end |