Team Specific Doors

I wanted to make the doors in Team Fortress 2 levels team based. Though the way they are activated in TF2 is through a filter_activator_tfteam, which doesn’t exist in garrys mod. Is there any way to create a working lua version of this entity (I have made it, it just doesn’t do anything). I have tried so many things but nothing seems to work.

Couldn’t you simply make a func_door entity, or the likes, and then check the activator’s team?

EDIT: Nevermind, re-read what you wanted. Ignore me. Sorry.

You will need to adapt the code for it to work for you.

SERVER
[lua]
– The doors table.
Doors = { }

– Load doors from the txt.
function LoadDoors()
if ( file.Exists( “CGRP/Doors/” … game.GetMap() … “.txt” ) ) then
local worked, err = pcall( glon.decode, file.Read( “CGRP/Doors/” … game.GetMap() … “.txt” ) )
if ( worked ) then
Doors = err
else
return
end
else
return
end
end

– Save door info.
function SaveDoors()
local worked, err = pcall( glon.encode, Doors )
if ( worked ) then
file.Write( “CGRP/Doors/” … game.GetMap() … “.txt”, err )
else
return
end
end

– Configure a doors info.
function ConfigureDoor( ply, cmd, args )
if ( !ply:IsAdmin() ) then
return
end

local tr = ply:EyeTrace( 80 )

if ( tr.Entity:IsDoor() and tr.Entity:IsValid() ) then
	local NewDoor = { }
	NewDoor.Name = NilFix( args[ 1 ], "" )
	NewDoor.Owners = NilFix( args[ 2 ], "" )
	NewDoor.Pos = tr.Entity:GetPos()
	
	table.insert( Doors, NewDoor )
	SaveDoors()
end

end
concommand.Add( “rp_newdoor”, ConfigureDoor )

function GM:Initialize()
LoadDoors()
end

local EMeta = FindMetaTable( “Entity” )

local DoorTable = { “func_door”, “func_door_rotating”, “prop_door_rotating” }

function EMeta:IsDoor()
local Class = self:GetClass()

for k, v in pairs( DoorTable ) do
	if ( Class == v ) then
		return true
	end
end

return false

end

function GM:KeyPress( ply, code )
if ( code == IN_USE ) then
local tr = ply:EyeTrace( 80 )
if ( tr.Entity:IsDoor() ) then
if ( tr.Entity.Owners == “Combine” ) then
if ( ply:IsCombine() ) then
tr.Entity:Fire( “toggle”, “”, 0.1 )
else
return
end
end
end
end
end
[/lua]

Thanks but I’m trying to get the trigger_multiple that is already there to open the door, not a use key based door. At the moment they open for anyone, I want them to open for a specific team.

Or can this code be used like that?

Its not in the code but yet again could be used you could have an entity invisible. Be placed on either side of the door. Whent he player is near the entity it opens all valid doors. Assuming thats what your asking.

But then would there be a way to stop the trigger_multiple from working?

You need to forget about triggers for the time being. Your asking for help in the lua section. To do this it ise quite possible. In fact I don’t see how it’s not possible.

In order for someone to make something like this they need the team names. Such as TEAM_BLU or TEAM_RED which are defined by your gamemode. ( Next they need the door names. ) Last sentence doesn’t count if the person coding this is smart enough You can trigger entity from an entity by using FindInSphere. Then after all this is done the person who wants the code needs to get location of each door. They need to get as close to the center of the door and type “getpos”.

After all this the coder can code the entity that will be placed near the door. When the right team walks near the door. The entity query all available doors within FindInSphere. The sphere will most likely be low distance since its near the door. The entity will then executes code from the query causing the door to stay open and then close after sometime.

Basically if this all sounds right then forget triggers within the maps because we can create entity in lua that can do the same thing.

…You could just create the necessary entity in Lua by that logic. As said, a working version of filter_activator_fteam would work.

[editline]18th February 2011[/editline]

Also that’s a tautology hurp

Which is what I have been trying to do, but I don’t understand how to see if the filter has activated or not. ENT:AcceptInput() doesn’t return anything on it. (If that is what I should be using)