Fix cl error and use global IsValid instead (#1257)

* Fix cl error and use global IsValid instead

* Newline

* Revert usage of global IsValid
This commit is contained in:
Redox 2022-11-09 17:49:22 +01:00 committed by GitHub
parent 0330c223bf
commit b7658d3d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
pac.OwnerNames =
{
pac.OwnerNames = {
"self",
"viewmodel",
"hands",
@ -117,6 +116,16 @@ function pac.HandleOwnerName(owner, name, ent, part, check_func)
if name == "viewmodel" and owner.GetViewModel then
return owner:GetViewModel()
end
if IsValid(ent) and (not check_func or check_func(ent)) and check_owner(ent, owner) and find_ent(ent, name) then
return ent
end
for _, val in pairs(ents.GetAll()) do
if val:IsValid() and (not check_func or check_func(val)) and check_owner(val, owner) and find_ent(val, name) then
return val
end
end
end
if name:find("persist ", nil, true) then
@ -128,15 +137,5 @@ function pac.HandleOwnerName(owner, name, ent, part, check_func)
end
end
if IsValid(ent) and (not check_func or check_func(ent)) and check_owner(ent, owner) and find_ent(ent, name) then
return ent
end
for _, val in pairs(ents.GetAll()) do
if val:IsValid() and (not check_func or check_func(val)) and check_owner(val, owner) and find_ent(val, name) then
return val
end
end
return NULL
end
end