I am working on some admin only doors and I am trying to make them unlock then open when I use them and then close then lock when I use them a second time which would close them. The problem is that I am using keypressed so it is actually opening the door twice which causes problems during locking. Is there a way to be able to use keypress ( which I am using e of course ) and return false to the normal door use?
[lua]
local function UnlockDoors( ply, key )
local trace = ply:GetEyeTrace()
if key == IN_USE then
if 1==1 and trace.Entity:GetNWInt( "Type" ) == 3 and trace.Entity:GetNWInt( "Locked" ) == 1 then
trace.Entity:Fire( "unlock", "", 0 )
trace.Entity:Fire( "open", "", 0 )
trace.Entity:SetNWInt( "Locked", 0 )
elseif trace.Entity:GetNWInt( "Type" ) == 3 and trace.Entity:GetNWInt( "Locked" ) == 0 then
trace.Entity:Fire( "close", "", 0 )
trace.Entity:Fire( "lock", "", 2 )
trace.Entity:SetNWInt( "Locked", 1 )
end
end
end
hook.Add( “KeyPress”, “UnlockDoors”, UnlockDoors )
[/lua]