DarkRP

Hello, I’m trying to get a door on my DarkRP to be locked by default, so you don’t need to manually lock it to stop people getting in…

Its the Administration door for the Admin Office. I want it to be locked by default after a map change, ect…

Was wondering if you could make it be locked via “TEAM_ADMIN” or something, anyone have any ideas?


(User was banned for this post ("undescriptive thread title, darkrp thread, reaaaally hasn't learnt" - Gran PC))

http://wiki.darkrp.com/index.php/DarkRP:Door_Groups

Can’t remember if that auto-locks it too but it does achieve the “TEAM_ADMIN” owning doors thing you wanted.

Its owned by TEAM_ADMIN, but i want any TEAM_ADMIN doors to be locked by default (After a map change they will still be locked)

Do you have the doors owned by the TEAM_ADMIN or do you have it owned by a group (AddDoorGroup in shared.lua) which includes TEAM_ADMIN?

I owned it by pressing F2 on the door and choosing the job, Administration so only the job Admin can unlock/lock it

[LUA]
function LockAdminDoors()
for _, ent in ipairs(ents.GetAll()) do
if ent:IsDoor() then
local DoorData = table.Copy(ent.DoorData or {})
if DoorData.TeamOwn then
local decoded = {}
for k, v in pairs(string.Explode("
", DoorData.TeamOwn)) do
if v and v != “” then
decoded[tonumber(v)] = true
end
end
DoorData.TeamOwn = decoded
end
if DoorData.TeamOwn and DoorData.TeamOwn[TEAM_ADMIN] then
ent:KeysLock()
end
end
end
end
hook.Add(“InitPostEntity”, “LockAdminDoors”, LockAdminDoors)
[/LUA]

Untested but will probably work.

[editline]22nd June 2013[/editline]

Run this serverside btw.