Forcefield on doors?

Hey, how would i create forcefield that is size of the door and doesnt pass anyone expect Admins?

I know ply:IsAdmin(), but how would i create the forcefield and be the size of the door, i don’t.

Bump

:snip: complicated way

Just use ShouldCollide

GM/ShouldCollide

But how would i make it size of the door automatically?

Entity/GetModelBounds

What if the door isnt entity? I want something like someone posted in Waywo, cant find the post.

Door is an entity.

I dont mean like itself the door, something like walkway? When you enter into the big building at gm_construct you will have like big frame, like door without the door just the edges. Sry for my English.

If within the bounds of the building just forcefully teleport them out if not admin. Don’t need that complicated force field stuff and it can’t be bypassed in some way.

make an concommand to set pos 1 & pos 2 so you can make like an box in vector, and then check if the box exists, and if an player enters & is no admin, teleport him back some units, so it has like an forcefield effect.

[editline]21st August 2015[/editline]

Also the “frames” on gm_construct are mapped.

Couldn’t you just make a prop and set its model, material and etc.?


if (SERVER) then
	local permissions = {
		["admin"] = true,
		["usergroups"] = {
			"owner",
			"moderator",
		},
	}
	local pos = Vector(13919,-10076,62)
	local angles = Angle(0,135,0)
	
	local function MakeAdminDoor(pos,angles)
		local adminDoor = ents.Create("prop_physics")
		adminDoor:SetModel("models/props_building_details/storefront_template001a_bars.mdl")
		adminDoor:SetMaterial("models/props_combine/combine_monitorbay_disp")
		adminDoor:SetCustomCollisionCheck(true)
		adminDoor:SetPos(pos)
		adminDoor:SetAngles(angles)
		adminDoor:Spawn()
		adminDoor:SetMoveType(MOVETYPE_NONE)
		adminDoor:GetPhysicsObject():EnableMotion(false)
		
		hook.Add("ShouldCollide","admindoor_shouldcollide",function(prop2,ply2)
			local prop = nil
			local ply = nil
			if (prop2 == adminDoor) then prop = prop2 end
			if (ply2:IsPlayer()) then ply = ply2 end
			if (prop == nil or ply == nil) then return end
			
			local allow = false
			if (permissions["admin"] == true and (ply:IsSuperAdmin() or ply:IsAdmin())) then
				allow = true
			else
				for _,perm in pairs(permissions["usergroups"]) do
					if (ply:GetNWString("usergroup") == perm) then
						allow = true
					end
				end
			end
			if (allow == true) then
				return false
			end
		end)
	end
	if (tonumber(#player.GetAll()) <= 0) then
		hook.Add("PlayerAuthed","admindoor_init",function() -- There's no physics until the player joins apparently
			MakeAdminDoor(pos,angles)
			hook.Remove("PlayerAuthed","admindoor_init") -- We don't need to call it again
		end)
	else
		MakeAdminDoor(pos,angles)
	end
end