Owning doors like in darkrp

I was lookin on garrysmod.org and i didnt see any addon that makes regular func_door’s ownable and unownable like in darkrp gamemode. So i was thinking about trying and making one myself but what would u call the door? i was thinking just func_door or somthing. Anyone know somthin bout this?


Yes the door is ‘func_door’.

A small little guide on what you want to do:

Note: Does not support vehicles!

  1. Create a new lua file called entity.lua
  2. Put this code into it:

local meta = FindMetaTable("Entity")

function meta:IsDoor()
	local class = self:GetClass()

	if (class == "func_door" or class == "func_door_rotating" or class == "prop_door_rotating") then
			return true
	return false

function meta:IsVeh()
	if (self:IsVehicle() == true) then
			return true
	return false

  1. You can now call these functions when using an entity.



can be called from an entity!

Hope this helps you :slight_smile:

IMPORTANT: This needs to be in server autorun or included by init.lua in a gamemode

Why are you making an entity method called IsVeh and basically returning IsVehicle when you could just use IsVehicle in the first place?

Also, learn2lua:
[lua]local meta = FindMetaTable(“Entity”)

function meta:IsDoor()
local class = self:GetClass()
return class == “func_door” or class == “func_door_rotating” or class == “prop_door_rotating”

Thank you for the explanation, it really helps. Now 1 more hopefully simple question, how would you lock and unlock a door? Is there a function for it? Jw

ENT:Fire(“lock”, “”, 0)
ENT:Fire(“unlock”, “”, 0)


function OwnDoor(ply, cmd, args)
local trace = ply:GetEyeTrace()
if ( trace.Entity:IsValid() and trace.Entity:GetClass() == “prop_door_rotating” ) then
if !ValidEntity( trace.Entity:GetNetworkedEntity( “owner” ) ) then trace.Entity:SetNWString( “owner”, ply:Nick( ) )
if tonumber( ply:GetNWInt( “Money” ) ) >= 75 then
ply:SetNWInt(“Money”, ply:GetNWInt( “Money” ) - 75 )
concommand.Add(“OwnDoor”, OwnDoor )

Wow, you’re a Hypocrite. Read the post that is above my previous post for fucks sake.

Thank you all for your help, very much appreciated!