Фиксы
Этот коммит содержится в:
родитель
ada6371905
коммит
e6bb13bda0
3 изменённых файлов: 27 добавлений и 16 удалений
|
|
@ -42,12 +42,21 @@ end
|
|||
|
||||
function permanent.Remove(id)
|
||||
|
||||
print("permanent.Remove", id)
|
||||
assert(isstring(id), "invalid index")
|
||||
|
||||
print(cache[id])
|
||||
cache[id] = nil
|
||||
print(cache[id])
|
||||
|
||||
end
|
||||
|
||||
hook.Add("ShutDown", "Permanent", function()
|
||||
|
||||
permanent.Push()
|
||||
|
||||
end)
|
||||
|
||||
hook.Add("PostGamemodeLoaded", "Permanent", function()
|
||||
|
||||
currentMap = game.GetMap()
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ local Entity = FindMetaTable("Entity")
|
|||
function Entity:MakePermanent(id, steamid)
|
||||
|
||||
if !IsValid(self) then return end
|
||||
if hook.Add("OnMakePermanent", self, owner) == false then return end
|
||||
if hook.Run("OnMakePermanent", self, owner) == false then return end
|
||||
|
||||
local tbl = {}
|
||||
tbl.class = self:GetClass()
|
||||
tbl.creator = steamid or ""
|
||||
tbl.time = os.time()
|
||||
tbl.pos = self:GetPos()
|
||||
tbl.ang = self:GetAngles()
|
||||
|
||||
|
|
@ -34,12 +36,11 @@ function Entity:MakePermanent(id, steamid)
|
|||
|
||||
end
|
||||
|
||||
id = isstirng(id) and id or tbl.class.."-"..os.time()
|
||||
tbl.creator = steamid or ""
|
||||
id = id or tbl.class.."-"..tbl.time
|
||||
permanent.Add(id, tbl)
|
||||
|
||||
self:Remove()
|
||||
permaents.Spawn(id)
|
||||
permanent.Spawn(id)
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -50,8 +51,10 @@ function permanent.Spawn(id)
|
|||
local tbl = permanent.Get(id)
|
||||
if !istable(tbl) then return end
|
||||
|
||||
local ent = ents.Spawn(tbl.class, tbl.pos, tbl.ang, true)
|
||||
local ent = ents.Create(tbl.class)
|
||||
if !IsValid(ent) then return end
|
||||
ent:SetPos(tbl.pos)
|
||||
ent:SetAngles(tbl.ang)
|
||||
|
||||
for k, v in pairs(tbl) do
|
||||
|
||||
|
|
@ -97,13 +100,13 @@ end
|
|||
|
||||
hook.Add("OnMakePermanent", "EntityBlacklist", function(ent)
|
||||
|
||||
if self:IsPlayer() ||
|
||||
self:IsNPC() ||
|
||||
self:IsNextBot() ||
|
||||
self:IsRagdoll() ||
|
||||
self:IsWeapon() ||
|
||||
self:IsVehicle() ||
|
||||
self:IsWorld()
|
||||
if ent:IsPlayer() ||
|
||||
ent:IsNPC() ||
|
||||
ent:IsNextBot() ||
|
||||
ent:IsRagdoll() ||
|
||||
ent:IsWeapon() ||
|
||||
ent:IsVehicle() ||
|
||||
ent:IsWorld()
|
||||
then return false end
|
||||
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ function TOOL:LeftClick(tr)
|
|||
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)
|
||||
local id = tr.Entity:GetNWString("Permanent.ID", false)
|
||||
|
||||
tr.Entity:MakePermanent(id, ply:SteamID())
|
||||
return true
|
||||
|
|
@ -31,7 +31,7 @@ function TOOL:RightClick(tr)
|
|||
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")
|
||||
local id = tr.Entity:GetNWString("Permanent.ID")
|
||||
|
||||
permanent.Remove(id)
|
||||
tr.Entity:Remove()
|
||||
|
|
@ -74,7 +74,6 @@ function TOOL:DrawHUD()
|
|||
|
||||
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)
|
||||
draw.SimpleTextOutlined(trace.Entity:GetNWString("Permanent.ID"), "GModNotify", x, y + 16, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, color_black)
|
||||
|
||||
end
|
||||
Загрузка…
Создание таблицы
Добавить ссылку
Сослаться в новой задаче