3d Text on DarkRP doors.

Hello!

Im having some problems how to make 3d text on doors that shows who owns it.
I tried to figure it out myself but i couldnt.

So if you know how to make it please help me :slight_smile:

Are you a coder? Cause it’s bloody hard to do this. Not something you could work out by trying to change lines of code…

I dont know if that was a joke or not.
But no im not a really good coder. I just started coding from some days ago.

Could you paste the code you have so far and any lua errors you see in-game (if any)? That should help us come up with a solution.

What are you trying to achieve by doing this? In order for someone to own it you’d have to make a system to have who owns what and to be able to reset when they leave or save. Unless you know mySQL. If you want to learn how to do this id advise you start with something smaller and work your way up.

You would have to use **[Cam.Start3D2D

http://wiki.garrysmod.com/favicon.ico](http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedb0.html?title=Cam.Start3D2D)**. Take a look at the cl_init.lua of the money_printer entity in DarkRP. Once you get the hang of things, you can use it to draw on all the doors in the map. Be sure to render only ones within a certain distance, otherwise you’d end up with massive FPS drops from all the unnecessary rendering. If you still need help, try looking at other publicly available RP gamemodes with it and see how they do it. Sure we could code you up something and have you change a few lines (and someone very well might do that), but you really should try it yourself first.

I took a look at the Cam.Start function on the printers.

But I have no idea how to make it so the text disappears with distance.

Also it says HUDElement5, what do the other elements look like?

You could take a look at ThreeD Text Tool. This appears 3D text and the closer you get the bigger it gets.

Not quite sure you understand what is happening currently. I could steal code form that but no.

Don’t steal code, learn from it. In the description it says it has distance fading. Study the code a bit (shouldn’t take too long) and find out how they do it. As for HUDElement5, I think that is a font, right? If so, check this out. Good luck!

So just setting the alpha to 0 at a distance would reduce lag?

This is what i meant with the ThreeD Text Tool. Just search through the code and learn from it.

Bump This is the code that draws words on doors edited.
[lua]/---------------------------------------------------------
Serverside part
---------------------------------------------------------
/
if CLIENT then
function meta:DrawOwnableInfo()

	local pos = 0

	local ownerstr = ""

	if ValidEntity(self:GetDoorOwner()) and self:GetDoorOwner().Nick then
		ownerstr = self:GetDoorOwner():Nick() .. "

"
end

	for k,v in pairs(player.GetAll()) do
		if self:OwnedBy(v) and v ~= self:GetDoorOwner() then
			ownerstr = ownerstr .. v:Nick() .. "

"
end
end

	if type(self.DoorData.AllowedToOwn) == "string" and self.DoorData.AllowedToOwn ~= "" and self.DoorData.AllowedToOwn ~= ";" then
		local names = {}
		for a,b in pairs(string.Explode(";", self.DoorData.AllowedToOwn)) do
			if ValidEntity(Player(b)) then
				table.insert(names, Player(b):Nick())
			end
		end
		ownerstr = ownerstr .. string.format(LANGUAGE.keys_other_allowed).. table.concat(names, "

“)…”
"
elseif type(self.DoorData.AllowedToOwn) == “number” and ValidEntity(Player(self.DoorData.AllowedToOwn)) then
ownerstr = ownerstr … string.format(LANGUAGE.keys_other_allowed)…Player(self.DoorData.AllowedToOwn):Nick()…"
"
end

	if not LocalPlayer():InVehicle() then
		local blocked = self.DoorData.NonOwnable
		local st = nil
		local whiteText = false -- false for red, true for white text

		self.DoorData.title = self.DoorData.title or ""

		if self:IsOwned() then
			whiteText = true
			if superAdmin then
				if blocked then
					st = self.DoorData.title .. "

"…LANGUAGE.keys_allow_ownership
else
if ownerstr == “” then
st = self.DoorData.title … "
"…LANGUAGE.keys_disallow_ownership … "
"
else
if self:OwnedBy(LocalPlayer()) and not self.DoorData.GroupOwn and not self.DoorData.TeamOwn then
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr
elseif not self.DoorData.GroupOwn and not self.DoorData.TeamOwn then
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr … LANGUAGE.keys_disallow_ownership … "
"
elseif not self:IsVehicle() then
local grouptext = “”
if self.DoorData.TeamOwn then
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
else
grouptext = self.DoorData.GroupOwn … "
"
end
st = self.DoorData.title … "
" … grouptext … LANGUAGE.keys_disallow_ownership … "
"
end
end
if self.DoorData.GroupOwn or self.DoorData.TeamOwn and not self:IsVehicle() then
st = st … LANGUAGE.keys_everyone
elseif not self:IsVehicle() and self.DoorData.GroupOwn or self.DoorData.TeamOwn then
local grouptext = “”
if self.DoorData.TeamOwn then
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
else
grouptext = self.DoorData.GroupOwn … "
"
end
st = st … grouptext
end
end
else
if blocked then
st = self.DoorData.title
else
if ownerstr == “” then
st = self.DoorData.title
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … grouptext
else
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr
end
end
end
end
else
if superAdmin then
if blocked then
whiteText = true
st = self.DoorData.title … "
"… LANGUAGE.keys_allow_ownership
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
if not self:IsVehicle() then
st = st … "
"… LANGUAGE.keys_everyone
end
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
"… LANGUAGE.keys_owned_by … "
" … grouptext
if not self:IsVehicle() then
st = st … "
“… LANGUAGE.keys_everyone
end
else
st = LANGUAGE.keys_unowned…”
"… LANGUAGE.keys_disallow_ownership
if not self:IsVehicle() then
st = st … "
"…LANGUAGE.keys_cops
end
end
end
else
if blocked then
whiteText = true
st = self.DoorData.title
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … grouptext
else
st = LANGUAGE.keys_unowned
end
end
end
end

		if whiteText then
		cam.Start3D2D( Vector(0, 0, 0), Angle(0, 0, 0), 1 )
			draw.AntiAliased = true
			draw.Weight = 600
			draw.FadeDistance = 512
			draw.DrawText(st, "TargetID", "UiBold", 0, 0, Color(0, 0, 0, 200), TEXT_ALIGN_CENTER )
			draw.DrawText(st, "TargetID", "UiBold", 0, 0, Color(173, 173, 173, 200), TEXT_ALIGN_CENTER )
		else
			draw.DrawText(st, "TargetID", "UiBold", 0, 0, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER )
			draw.DrawText(st, "TargetID", "UiBold", 0, 0, Color(27, 115, 170, 200), TEXT_ALIGN_CENTER )
		cam.End3D2D()
		end
	end
end

return

end[/lua]

This is the error: ERROR: GAMEMODE:‘HUDPaint’ Failed: [@lua\includes\modules\draw.lua:93] bad argument #1 to ‘ceil’ (number expected, got string)

http://facepunch.com/threads/1099509

you could try that.

Read the post please. That is not what we are aiming for here.

I know but the text on the doors from the link i posted are from perp it looks sorta 3d.

That doesnt help at all.

EDIT! Updated code and a new error:
[lua]
/---------------------------------------------------------
Serverside part
---------------------------------------------------------
/
if CLIENT then
function meta:DrawOwnableInfo()

	local surface.SetFont("Coolvetica")
	local pos = 0

	local ownerstr = ""

	if ValidEntity(self:GetDoorOwner()) and self:GetDoorOwner().Nick then
		ownerstr = self:GetDoorOwner():Nick() .. "

"
end

	for k,v in pairs(player.GetAll()) do
		if self:OwnedBy(v) and v ~= self:GetDoorOwner() then
			ownerstr = ownerstr .. v:Nick() .. "

"
end
end

	if type(self.DoorData.AllowedToOwn) == "string" and self.DoorData.AllowedToOwn ~= "" and self.DoorData.AllowedToOwn ~= ";" then
		local names = {}
		for a,b in pairs(string.Explode(";", self.DoorData.AllowedToOwn)) do
			if ValidEntity(Player(b)) then
				table.insert(names, Player(b):Nick())
			end
		end
		ownerstr = ownerstr .. string.format(LANGUAGE.keys_other_allowed).. table.concat(names, "

“)…”
"
elseif type(self.DoorData.AllowedToOwn) == “number” and ValidEntity(Player(self.DoorData.AllowedToOwn)) then
ownerstr = ownerstr … string.format(LANGUAGE.keys_other_allowed)…Player(self.DoorData.AllowedToOwn):Nick()…"
"
end

	if not LocalPlayer():InVehicle() then
		local blocked = self.DoorData.NonOwnable
		local st = nil
		local whiteText = false -- false for red, true for white text

		self.DoorData.title = self.DoorData.title or ""

		if self:IsOwned() then
			whiteText = true
			if superAdmin then
				if blocked then
					st = self.DoorData.title .. "

"…LANGUAGE.keys_allow_ownership
else
if ownerstr == “” then
st = self.DoorData.title … "
"…LANGUAGE.keys_disallow_ownership … "
"
else
if self:OwnedBy(LocalPlayer()) and not self.DoorData.GroupOwn and not self.DoorData.TeamOwn then
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr
elseif not self.DoorData.GroupOwn and not self.DoorData.TeamOwn then
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr … LANGUAGE.keys_disallow_ownership … "
"
elseif not self:IsVehicle() then
local grouptext = “”
if self.DoorData.TeamOwn then
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
else
grouptext = self.DoorData.GroupOwn … "
"
end
st = self.DoorData.title … "
" … grouptext … LANGUAGE.keys_disallow_ownership … "
"
end
end
if self.DoorData.GroupOwn or self.DoorData.TeamOwn and not self:IsVehicle() then
st = st … LANGUAGE.keys_everyone
elseif not self:IsVehicle() and self.DoorData.GroupOwn or self.DoorData.TeamOwn then
local grouptext = “”
if self.DoorData.TeamOwn then
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
else
grouptext = self.DoorData.GroupOwn … "
"
end
st = st … grouptext
end
end
else
if blocked then
st = self.DoorData.title
else
if ownerstr == “” then
st = self.DoorData.title
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … grouptext
else
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … ownerstr
end
end
end
end
else
if superAdmin then
if blocked then
whiteText = true
st = self.DoorData.title … "
"… LANGUAGE.keys_allow_ownership
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
if not self:IsVehicle() then
st = st … "
"… LANGUAGE.keys_everyone
end
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
"… LANGUAGE.keys_owned_by … "
" … grouptext
if not self:IsVehicle() then
st = st … "
“… LANGUAGE.keys_everyone
end
else
st = LANGUAGE.keys_unowned…”
"… LANGUAGE.keys_disallow_ownership
if not self:IsVehicle() then
st = st … "
"…LANGUAGE.keys_cops
end
end
end
else
if blocked then
whiteText = true
st = self.DoorData.title
else
if self.DoorData.GroupOwn then
whiteText = true
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … self.DoorData.GroupOwn
elseif self.DoorData.TeamOwn then
whiteText = true
local grouptext = “”
for k, v in pairs( self.DoorData.TeamOwn ) do
if v then
grouptext = grouptext … RPExtraTeams[k].name … "
"
end
end
st = self.DoorData.title … "
“… LANGUAGE.keys_owned_by …”
" … grouptext
else
st = LANGUAGE.keys_unowned
end
end
end
end
cam.Start3D2D( Vector(0, 0, 0), Angle(0, 0, 0), 1 )
draw.AntiAliased = true
draw.Weight = 600
draw.FadeDistance = 512
if whiteText then
draw.DrawText(st, “Coolvetica”, 0, 0, Color(0, 0, 0, 200), TEXT_ALIGN_CENTER )
draw.DrawText(st, “Coolvetica”, 0, 0, Color(173, 173, 173, 200), TEXT_ALIGN_CENTER )
else
draw.DrawText(st, “Coolvetica”, 0, 0, Color(0, 0, 0, 255), TEXT_ALIGN_CENTER )
draw.DrawText(st, “Coolvetica”, 0, 0, Color(27, 115, 170, 200), TEXT_ALIGN_CENTER )

		end
		cam.End3D2D()
	end
end

return

end[/lua]

The new error is: ERROR: GAMEMODE:‘HUDPaint’ Failed: [darkrp\gamemode\cl_hud.lua:382] attempt to call method ‘IsOwnable’ (a nil value)

The Lua on cl_hud’s line 382 is: [lua]
if tr.Entity:IsOwnable() and tr.Entity:GetPos():Distance(LocalPlayer():GetPos()) < 200 then
tr.Entity:DrawOwnableInfo()
end
end
[/lua]

Bump… Any idea?

Well, I started working on this a few weeks ago… I’ve been way too busy to complete it.
But I must warn you, the doors’ shapes, positions and angles differ a lot.
For example, you must rotate the door’s angles 90 degrees in the roll axis to get the angle for 2d3d. Also, negate the Y coordinates for the text that’s supposed to appear on the outside.
Moreover, you don’t draw in 3d in the HUD… You’ll end up with errors or a wallhack.

Bump Is there any updates on this as i would love it :slight_smile: