Jailbreak Cell Door

I’ve been trying to work out how to make a command that allows the user to open cell doors. The problem I am having is that everything I have tried so far, it opens every door in the map!

Can anyone help please?

Post what you’ve tried.

for k,v in ipairs(ents.FindByClass("func_door")) do

You’ve got to filter them in some sort of way, because obviously that will open them all.
Also, please wrap the code next time in


How would I filter the cell doors?

You’d check if the player using the command has met certain criteria.

Normally, this kinds of maps have got different names for their doors and such, as for example, normally the doors would be something like: cell_door1, cell_door2, etc etc.
But, thats map specific normally, so you should take a look by either decompiling the map and taking a look to them by hammer or either in-game with custom commands that’d print the doors name on the console.
Either that, or using entity map creation ids.

You can try to open the door entities which in a radius, starting from prisoner’s spawn entity.

If the map has a dedicated button to open cells, you can just Fire(“Use”) on GetMapCreatedEntity(int). Thats what I did when I did JB.

You can always try creating a concommand that tells you the class of the entity (just another option, and a easier way of finding the entity class)
And thats how you run the button on what


concommand.Add( "entityclass", function( ply, cmd, args )
     print( tostring(ply:GetEyeTrace().Entity:GetClass()) )
     -- for running on all entites of the entity your looking at with the same class
     for k,v in pairs(ents.FindByClass(tostring(ply:GetEyeTrace().Entity:GetClass())) ) do
         -- etc
end )