Инструмент
Этот коммит содержится в:
родитель
05d84ab4b7
коммит
ada6371905
1 изменённых файлов: 80 добавлений и 0 удалений
80
lua/weapons/gmod_tool/stools/permanent.lua
Обычный файл
80
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
|
||||
Загрузка…
Создание таблицы
Добавить ссылку
Сослаться в новой задаче