Creating a shield that only allows certain entities passage.

Hey guys.

I was wondering if it was possible to create a solid shield (a barrier of some sort, doesn’t have to be a shield specifically) that only certain entities could go through, and would stop anything not on the whitelist (or some other form of allowed entities list) from going through it. Sort of like the shield included in the stargate pack, but protecting against ~everything~.

You could try doing what the ‘one way door’ does, setting the velocity of any disallowed entity, forcing them in the opposite direction.


hook.Add(“InitPostEntity”, “BlockProp”, function()
local prop = ents.Create(“prop_physics”)
prop:SetModel(–[[Model Here]]–)
prop:SetNWBool(“Blocked”, true)

hook.Add(“ShouldCollide”, “BlockedProps”, function( ent1, ent2)
local AllowedEnts = {“player”,“prop_physics”,“ent_ball”}
local AllowedIDs = {“STEAM_0:0:0000”}

if ent1:GetNWBool(“Blocked”) or ent2:GetNWBool(“Blocked”) the
if (ent1:IsPlayer() or ent2:IsPlayer()) and table.HasValue(AllowedEnts, “player”) then
return table.HasValue(AllowedIDs, ent1:SteamID())

[lua]hook.Add( “ShouldCollide”, “ShallwecollidexD”, function( ent1, ent2 )
if ent1:GetClass() == “prop_physics” or ent2:GetClass() == “prop_physics” then
if ent1:IsPlayer() or ent2:IsPlayer() then return not ent1:IsAdmin() or ent2:IsAdmin() end
end // We don’t return true because other hooks may also call this and it will break custom addons
end )[/lua]

Simple code that lets all admins go through all props :slight_smile:

Im pretty sure that will let everyone but admins go through…

I have an addon that I wrote for someone awhile ago that allows people to noclip everywhere but through props and the world if you want it.

Thinking about it I could probally quickly mock up a feature to allow just admins to be able to go through props.