[Help] Unlock All DarkRP Doors

Is there anyway to unlock all the doors in a DarkRP server? I know that specific doors can be unlocked with commands, but what about all of them at once?

You can make a .lua script to either have a command do unlock all doors, or unlock all doors on ‘InitPostEntity’



UnlockAllDoors = function()
	for _, Door in pairs( ents.GetAll() ) do
		if Door:GetClass() == "func_door" || Door:GetClass() == "prop_door_rotating" || Door:GetClass() == "func_door_rotating" then
			Door:Fire("unlock", "", .5)
		end
	end
end

hook.Add("InitPostEntity", "[DarkRP] Unlock All Doors", function()
	UnlockAllDoors();
end)

concommand.Add("darkrp_unlock_all_doors", function( Player, Command, Args )
	if !Player:IsAdmin() then return false; end	-- You can add "--" in front of this line, or remove it all if you don't want to run an admin check.
	UnlockAllDoors();
end)


Save this as a ‘.lua’ file, and put this in either in the ‘lua/autorun/server/’ folder, or under ‘gamemodes/DarkRP/gamemode/modules/’ (I think DarkRP auto-loads everything under the modules folder).

Thank you very much! This is exactly what I was looking for!