Clientside hook "ENT:Draw()"

I would like to know if im able to hook this this way:

[lua]function Hello()


This is not how it works. You can only use ENT:Draw as a callback function in your entity. You can only use these and these with with hook.Add

To add to this:
ENT:Draw is called every time the engine wants the entity to draw itself.

First of all thanks for that info, sorry for my enlglish… its really poor.

Im trying to do somethink like this:
[lua]local Pos = self:GetPos()
local Ang = self:GetAngles()

local TextWidth = surface.GetTextSize("$"..tostring(self:Getamount()))

cam.Start3D2D(Pos + Ang:Up() * 0.9, Ang, 0.1)
	draw.WordBox(2, -TextWidth*0.5, -10, "$"..tostring(self:Getamount()), "ChatFont", Color(140, 0, 0, 100), Color(255,255,255,255))

Ang:RotateAroundAxis(Ang:Right(), 180)

cam.Start3D2D(Pos, Ang, 0.1)
	draw.WordBox(2, -TextWidth*0.5, -10, "$"..tostring(self:Getamount()), "ChatFont", Color(140, 0, 0, 100), Color(255,255,255,255))

–Took from DarkRP Money entity[/lua]

At an existing entity like a vehicle.

Then you want to use GM:PostDrawRenderables or GM:PreDrawRenderables hooks. Look them up on wiki.

Thanks you very much :slight_smile:

Now i have another problem :frowning:

I don’t know how to explain it here are two pics:

I should be able to see the “draw.WordBox” but the vehicle overlay it

Here is the code:
[lua]-- Draw the NumberPlate on the vehicle
function NumberPlate()

for a,b in pairs(ents.FindByClass("prop_vehicle_jeep*")) do
	if (IsValid(b) and b:IsVehicle() and b:GetNetworkedBool("VU") and b:GetNetworkedString("NumberPlate")) then
		-- This will be taken from the vehicle
		local PlatePos1 = Vector(0,-100.35,20);
		local numplate = b:GetNetworkedString("NumberPlate");
		local angles = b:GetAngles();
		local Pos = b:GetPos() + ( angles:Forward() * PlatePos1.x ) + ( angles:Right() * PlatePos1.y ) + ( angles:Up() * PlatePos1.z );
		local Ang = angles + Angle(0, 0, -90);
		Ang:RotateAroundAxis(Ang:Forward(), 180)
		Ang:RotateAroundAxis(Ang:Right(), 180)
		local TextWidth = surface.GetTextSize(numplate)

		cam.Start3D2D(Pos, Ang , 0.1)
			draw.WordBox(10, -TextWidth*0.5, -10, numplate, "ChatFont", Color(0, 0, 0, 255), Color(255,255,255,255))

hook.Add( “PostDrawOpaqueRenderables”, “NumberPlate”, NumberPlate );[/lua]

Draw the word box after the car.


Actually, it seems like you are drawing it inside of the prop.

You mean change the hook? Which one i should use?

[editline]19th June 2013[/editline]

Ah no, its outside the vehicle im sure

Try drawing it ~32 units in front of the car to verify.

This is annoying only happens with the vehicle :confused:

Seems it’s drawing in front of the plate since the plate is opaque and the hook is PostDrawOpaque.

Try PostDrawTranslucent.

It works like a charm thanks you so much now i know some more things :smiley: