3D2D text on RP doors.

I know this is possible because I’ve seen it before. I’ve been using 3D2D for things like weapon shipments, dropped money and the like, but how could I apply this effect to doors?

The best thing I can think up right now is an invisible entity that attaches itself to every door in a map. When you get close to it, it gives you the 3D2D text info. I’m terrible with entities and vectors and all that jazz, would someone be kind enough to help me out? :smiley:

Thanks guys!

You wouldn’t be able to use constraint.Weld unless you could specify which door_rotating it is, I suggest making a new door sent all together any placing it in the maps with hammer.

Are you certain there’s no other way? Augh, if only 3D2D worked in GM:HudPaint.

What if I use a function to find all entities with the “func_door_rotating” class and create SENTs with the exact world position as each of the doors.

I’m kinda grasping at straws, but I really want to know how Conna did it in kuroScript2.

I coded one of these for Darkland RP, you just draw them in RenderScreenspaceEffects (I think that was the hook) and set the cam position something of 0.01 above the door, then set the angles to the doors angles. It’s pretty easy.

Awesome! So what would the script inside of that hook be? Basically, find all ownable doors and put a cam.3D2D on each of em?

I did this before, it’s not that simple. GetAngles doesn’t return the doors rotation, moreso it returns the amount that it has been rotated. I wrote a function that would manually calculate the exact position, angles, and scale for the 3d2d text though.

Well simple or not, all I need is a push in the right direction. It’s good to know that people besides the elusive Conna have done this before, so any help with this would be totally rad.

Also I’m using DarkRP as a base, so anyone familiar with its spaghetti-like layout gets… double points?

I can also whip out the ol’ PayPal account and offer up cash goodies for a full, working script that’s compatible with DRP.

Thanks!

Conna got the code from me.

Well then. :stuck_out_tongue:

Would you be willing to help?

I’ll take you’re money. I do have a dollar sign in my name after all.

Anywho, shouldn’t be too difficult. Even if rotating doors don’t actually rotate, per se, you should be able to find that stuff based on which way it last opened. In fact, another way to ensure all ownable doors do this is to make a client-side entity that displays the 3D2D text and parent it to the door entity. That would be ideal for those brush-based doors.

Any help would be greatly appreciated, buddy-bud, so tell me how much your time is worth. :slight_smile:

Here’s the code that gets the positioning/draws it. Straight from CakeScript G3.
[lua]
function CalculatePositioning(door, reverse)

local obbCenter = door:OBBCenter();
local obbMaxs = door:OBBMaxs();
local obbMins = door:OBBMins();
local data = {};

data.endpos = door:LocalToWorld(obbCenter);
data.filter = ents.FindInSphere(data.endpos, 20);

for k, v in pairs(data.filter) do
		if (v == door) then
				data.filter[k] = Entity(0);
		end;
end;

local width = 0;
local length = 0;

local size = obbMins - obbMaxs;
size.x = math.abs(size.x);
size.y = math.abs(size.y);
size.z = math.abs(size.z);
if (size.z < size.x and size.z < size.y) then
		-- updown
		width = size.y;
		length = size.z;
		
		if reverse then
		
			data.start = data.endpos - door:GetUp() * length;
			
		else
		
			data.start = data.endpos + door:GetUp() * length;

		end
		
elseif (size.x < size.y) then

		width = size.y;
		length = size.x;
		
		if reverse then
		
			data.start = data.endpos - door:GetForward() * length;
		
		else
		
			data.start = data.endpos + door:GetForward() * length;
			
		end
		
elseif (size.y < size.x) then

		width = size.x;
		length = size.y;
		
		if reverse then
		
			data.start = data.endpos - door:GetRight() * length;
		
		else
		
			data.start = data.endpos + door:GetRight() * length;
			
		end

end;

width = math.abs(width);

local trace = util.TraceLine(data);

if trace.HitWorld and !reverse then

	return CalculatePositioning(door, true);
	
end

local ang = trace.HitNormal:Angle();

ang:RotateAroundAxis(ang:Forward(), 90);
ang:RotateAroundAxis(ang:Right(), 90);

local pos = trace.HitPos - ((data.endpos - trace.HitPos):Length() * 2) * trace.HitNormal;

local angBack = trace.HitNormal:Angle();

angBack:RotateAroundAxis(angBack:Forward(), 90);
angBack:RotateAroundAxis(angBack:Right(), -90);

local posBack = trace.HitPos;

return pos, ang, posBack, angBack, width, trace.HitWorld;

end

function MODULE.RenderScreenspaceEffects()

if !LocalPlayer():Alive() then return end

local find = ents.FindInSphere(LocalPlayer():EyePos(), 300);
	
local eyePos = EyePos();
local eyeAngles = EyeAngles();

for _, ent in pairs(find) do

	if IsValid(ent) then
	
		if cake.util.IsDoor(ent) then
		
			local pos, ang, posBack, angBack, width, hitWorld = CalculatePositioning(ent);
			
			if !hitWorld then
				
				local dist = LocalPlayer():EyePos():Distance(ent:GetPos());
				local alpha = math.Clamp(255 - (255 * (dist / 300)), 0, 255);
				local name = ent:GetNWString("DoorName");
				local propertyName = ent:GetNWString("PropertyName");
				
				local eyePos = EyePos();
				local eyeAngles = EyeAngles();
				
				if name != "" and propertyName != "" then
					
					surface.SetFont("DoorID1");
					local nameWidth = surface.GetTextSize(name);
					surface.SetFont("DoorID2");
					local propertyWidth = surface.GetTextSize(propertyName);
					
					local longWidth = nameWidth;
					
					if propertyWidth > nameWidth then
					
						longWidth = propertyWidth;
						
					end
					
					local scale = math.abs((width * 0.65) / longWidth);
						
					cam.Start3D(eyePos, eyeAngles)
					
						cam.Start3D2D(pos, ang, scale);
						
							draw.SimpleText(ent:GetNWString("DoorName"), "DoorID1", 6, -20, Color(10, 10, 10, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
							draw.SimpleText(ent:GetNWString("DoorName"), "DoorID1", 0, -26, Color(240, 240, 240, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
						
							draw.SimpleText(ent:GetNWString("PropertyName"), "DoorID2", 6, 32, Color(10, 10, 10, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
							draw.SimpleText(ent:GetNWString("PropertyName"), "DoorID2", 0, 26, Color(230, 230, 230, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
						
						cam.End3D2D();
						
						cam.Start3D2D(posBack, angBack, scale);
						
							draw.SimpleText(ent:GetNWString("DoorName"), "DoorID1", 6, -20, Color(10, 10, 10, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
							draw.SimpleText(ent:GetNWString("DoorName"), "DoorID1", 0, -26, Color(240, 240, 240, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
						
							draw.SimpleText(ent:GetNWString("PropertyName"), "DoorID2", 6, 32, Color(10, 10, 10, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
							draw.SimpleText(ent:GetNWString("PropertyName"), "DoorID2", 0, 26, Color(230, 230, 230, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
						
						cam.End3D2D();
					
					cam.End3D();
				
				end
			
			end
			
		end
		
	end
	
end

end
[/lua]

The code in MODULE.RenderScreenspaceEffects can just go into your RenderScreenspaceEffects hook, and you have to change bits of the code to get the door name/property and whether or not it is a door to work with whatever gamemode you’re using. Obviously you’ll also need to change the fonts and the 0.65 multiplier to scale better to your font.

Thanks for stealing my thunder bro.

Jesus tapdancing Christ.

I know you’ve already just pumped out 99.99% of the work with this puppy but… script goze where? cl_init.lua savvy?

laff. Well, I still have to fuck around with it and get it all DarkRP compatible. (so, bend the code into an unrecognizable shape and shove it into the can of worms that is the DarkRP source, not unlike sticking a bent wire hanger into a toaster)

You probably won’t be able to get this code into your gamemode without the help of another scripter.

Well shit on my titties. Grea$e, looks like you’re still the guy. You can add me on Steam, my name is superkyol.

I mean, unless you know lua. It’s not that difficult, you just have to throw that into a clientside file and change the code to get the right networked vars and use the DarkRP is this a door function.

Holy funkin’ taters, it worked! :slight_smile:

Thanks a lot bud, very cool!