Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local entitiesToRemove = {
- ["prop_physics"] = true,
- ["money_printer"] = true,
- }
- local cachedEntites = {};
- hook.Add("OnEntityCreated", "cache_entities", function(ent)
- table.insert(cachedEntites, {e = ent});
- end);
- hook.Add("EntityRemoved", "remove_cached_entities", function(ent)
- for k, v in ipairs(cachedEntites) do
- if (IsValid(v.e) and v.e:GetClass() == ent:GetClass()) then
- table.remove(cachedEntites, k);
- end
- end
- end);
- hook.Add("PlayerDisconnected", "remove_ents_on_disconnect", function(ply)
- for k, v in ipairs(cachedEntites) do
- if (IsValid(v.e) and entitiesToRemove[v.e:GetClass()]) then
- if (v.e.CPPIGetOwner and IsValid(v.e:CPPIGetOwner()) and v.e:CPPIGetOwner() == ply) then
- v.e:Remove();
- continue;
- end
- if (v.e.Getowning_ent and IsValid(v.e:Getowning_ent()) and v.e:Getowning_ent() == ply) then
- v.e:Remove();
- end
- end
- end
- end);
- hook.Add("OnPlayerChangedTeam", "removenets_on_jobchange", function(ply, old, new)
- for k, v in ipairs(cachedEntites) do
- if (IsValid(v.e) and entitiesToRemove[v.e:GetClass()]) then
- if (v.e.CPPIGetOwner and IsValid(v.e:CPPIGetOwner()) and v.e:CPPIGetOwner() == ply) then
- v.e:Remove();
- continue;
- end
- if (v.e.Getowning_ent and IsValid(v.e:Getowning_ent()) and v.e:Getowning_ent() == ply) then
- v.e:Remove();
- end
- end
- end
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement