1. Post #1
    Dwight's Avatar
    January 2011
    51 Posts
    I'm making a gamemode that already uses the use key.
    So, you can't open doors anymore... :(

    Someone knows how to make: if you stand before the door, it opens automatic ?

    without editing the map.

    Thanks!

  2. Post #2
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,559 Posts
    doorEntity:Fire("open", "");
    doorEntity:Fire("close", "");

  3. Post #3

    July 2007
    864 Posts
    Just an idea:
    Add a timer, holds/executes a function:
    for k, v in pairs(tablewithpositionsfordoors) do
    for n, ply in pairs(ents.getinsphere(20)) do
    if ply:IsPlayer() then
    doorent:Fire("open") --something like that.. aso define doorent
    end
    end
    end

    code is very quickly written and won't work.. It might give ou an idea of how to.

  4. Post #4
    Dwight's Avatar
    January 2011
    51 Posts
    Something like that?
    local DoorTypes =
    {
    
            "func_door",
            "func_door_rotating",
            "prop_door_rotating"
    
    }
    
    
    for k, v in pairs(tablewithpositionsfordoors) do
    for n, ply in pairs(ents.getinsphere(20)) do
    if ply:IsPlayer() then
    doorent = ents.FindByClass( DoorTypes )
    doorent:Fire("open") --something like that.. aso define doorent
    end
    end
    end
    

    Code:
    [@RunString:13] bad argument #1 to 'pairs' (table expected, got nil)

  5. Post #5

    July 2007
    864 Posts
    You'll need to get a table with the doors.

  6. Post #6
    Dwight's Avatar
    January 2011
    51 Posts
    local DoorTypes = { "func_door", "func_door_rotating", "prop_door_rotating" }
     
    for k, v in pairs(tablewithpositionsfordoors) do
    for n, ply in pairs(ents.getinsphere(20)) do
    if ply:IsPlayer() then
    doorent = ents.FindByClass( DoorTypes )
    doorent:Fire("open")
    end
    end
    end
    

    everything i do, always errors..

    Code:
    [RunString:5] unexpected symbol near '='
    Code:
    [RunString:6] attempt to call field 'getinsphere' (a nil value)
    Code:
    [@RunString:5] bad argument #1 to 'pairs' (table expected, got nil)

  7. Post #7
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Disagree Disagree x 1 (list)

  8. Post #8
    Aaron113's Avatar
    April 2010
    158 Posts
    local DoorTypes = { "func_door", "func_door_rotating", "prop_door_rotating" }
    
    hook.Add( "Think", "OpenDoors", function() 
    	for k,v in pairs(DoorTypes) do 
    		for k2,v2 in pairs(ents.FindByClass(v)) do 
    			local EntTable = ents.FindInSphere(v2:GetPos(), 20)
    			local PlayerTable = {}
    			for _,ent in pairs(EntTable) do 
    				if ent:IsPlayer() then 
    					table.insert(PlayerTable, ent)
    				end 
    			end 
    
    			if table.Count(PlayerTable) > 0 then 
    				v2:Fire("open", "")
    			else 
    				v2:Fire("close", "")
    			end 
    		end 
    	end 
    end )
    Didn't test it, but it should be close to what you want.
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Agree Agree x 1Lua Helper Lua Helper x 1 (list)

  9. Post #9

    July 2007
    864 Posts
    local DoorTypes = { "func_door", "func_door_rotating", "prop_door_rotating" }
    
    hook.Add( "Think", "OpenDoors", function() 
    	for k,v in pairs(DoorTypes) do 
    		for k2,v2 in pairs(ents.FindByClass(v)) do 
    			local EntTable = ents.FindInSphere(v2:GetPos(), 20)
    			local PlayerTable = {}
    			for _,ent in pairs(EntTable) do 
    				if ent:IsPlayer() then 
    					table.insert(PlayerTable, ent)
    				end 
    			end 
    
    			if table.Count(PlayerTable) > 0 then 
    				v2:Fire("open", "")
    			else 
    				v2:Fire("close", "")
    			end 
    		end 
    	end 
    end )
    Didn't test it, but it should be close to what you want.
    You did what i was too lazy to do..
    Except, consider using a timer to 1 second, instead of think. It might get heavy running every think.

  10. Post #10
    Dwight's Avatar
    January 2011
    51 Posts
    Ye, it makes a little bit of lag.
    but works as is sould.

    what hook you need to use instead of think?

  11. Post #11

    July 2007
    864 Posts
    A timer.
    Like this:
    local DoorTypes = { "func_door", "func_door_rotating", "prop_door_rotating" }
     
    timer.Create( "DoorCheck", 1, 0, function()
        for k,v in pairs(DoorTypes) do
            for k2,v2 in pairs(ents.FindByClass(v)) do
                local EntTable = ents.FindInSphere(v2:GetPos(), 20)
                local PlayerTable = {}
                for _,ent in pairs(EntTable) do
                    if ent:IsPlayer() then
                        table.insert(PlayerTable, ent)
                    end
                end
     
                if table.Count(PlayerTable) > 0 then
                    v2:Fire("open", "")
                else
                    v2:Fire("close", "")
                end
            end
        end
    end )
    Reply With Quote Edit / Delete Reply Windows 7 Denmark Show Events Friendly Friendly x 1 (list)

  12. Post #12
    Dwight's Avatar
    January 2011
    51 Posts
    Thanks all of you guys!!
    Works fine!
    Reply With Quote Edit / Delete Reply Windows XP Belgium Show Events Friendly Friendly x 1 (list)

  13. Post #13

    July 2007
    864 Posts
    Perfect!

  14. Post #14
    Aaron113's Avatar
    April 2010
    158 Posts
    You're welcome :D