• PostDrawOpaqueRenderables
    11 replies, posted
this is my code: [code] local function LMMNPCRBounceFunction() for k, v in pairs( ents.FindByClass( "lmm_npcr" ) ) do local p p = v:GetPos() + Vector(0,0,95 + math.sin(CurTime()*3)*5) for _,yaw in pairs({0, 180}) do local a = Angle(0, 0, 0) a:RotateAroundAxis(a:Forward(), 90) a:RotateAroundAxis(a:Right(), yaw) a:RotateAroundAxis(a:Right(), CurTime() * 15) local name = v:GetNWString("LMMNPCRName") or "UnKnown" local cooldown = v:GetNWFloat("LMMNPCRCooldown") or 0 local robbing = v:GetNWFloat("LMMNPCRRobbingInProgress") or 0 local id = v:GetNWString("LMMNPCRID") or 0 local colorr = v:GetNWFloat("LMMNPCRColorR") or 255 local colorg = v:GetNWFloat("LMMNPCRColorG") or 0 local colorb = v:GetNWFloat("LMMNPCRColorB") or 0 local colora = v:GetNWFloat("LMMNPCRColorA") or 255 render.PushFilterMag(TEXFILTER.ANISOTROPIC) render.PushFilterMin(TEXFILTER.ANISOTROPIC) cam.Start3D2D(p, a, 0.1) if robbing == 1 then draw.DrawText(name.."\nRobbing...", "LMMNPCRBounceFont", 0, 0, Color(colorr, colorg, colorb, colora), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) elseif cooldown == 1 then draw.DrawText(name.."\nCooldown: "..string.ToMinutesSeconds(math.Round(LMMNPCRConfig.CooldownTime * 60 - (math.abs(tonumber(v:GetNWFloat("LMMNPCRGetCooldownTime")) - CurTime())))), "LMMNPCRBounceFont", 0, 0, Color(colorr, colorg, colorb, colora), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) else draw.DrawText(name, "LMMNPCRBounceFont", 0, 0, Color(colorr, colorg, colorb, colora), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end cam.End3D2D() render.PopFilterMag() render.PopFilterMin() end end end hook.Add( "PostDrawOpaqueRenderables", "LMMNPCRBounceFunction", LMMNPCRBounceFunction) [/code] problem: Sometimes the text does not render.. sometimes it does there are no errors just sometimes does not happen.. Please help! Thanks
This is a very horrible way of doing this, ( ents.FindByClass is super slow ), since you are using a custom entity, just draw your shit from ENT:Draw()
[QUOTE=Robotboy655;50107177]This is a very horrible way of doing this, ( ents.FindByClass is super slow ), since you are using a custom entity, just draw your shit from ENT:Draw()[/QUOTE] alright i switched to the ENT:Draw function but now its still not working...
Are you setting Render Bounds?
[QUOTE=Robotboy655;50107475]Are you setting Render Bounds?[/QUOTE] Not sure what you mean i have never really used the ENT:Draw() function
[url]http://wiki.garrysmod.com/page/Entity/SetRenderBounds[/url] An entity will only render if its render bounds are on your screen.
[QUOTE=Robotboy655;50107523][url]http://wiki.garrysmod.com/page/Entity/SetRenderBounds[/url] An entity will only render if its render bounds are on your screen.[/QUOTE] sorry to answer so late but what would you recommend for the vectors there?
ENT:Draw won't draw through other world models... At least from my experience with it
[QUOTE=XxLMM13xXx;50150361]sorry to answer so late but what would you recommend for the vectors there?[/QUOTE] Mins and Maxs, relative positions to the Entity:GetPos(). Choose a value that will cover the entire entity. Think of it as a box. Mins is the top left corner and Maxs is the bottom left. Mins usually has all 3 coordinates negative ( Vector(-100, -100, -100) for [b]example[/b] ) You must choose values that will create a box that will cover your entire entity and everything it draws. When any part of that box is on the screen, your entity will be drawn.
[QUOTE=Robotboy655;50107177]This is a very horrible way of doing this, ( ents.FindByClass is super slow ), since you are using a custom entity, just draw your shit from ENT:Draw()[/QUOTE] Just to know, if you are not using a custom entity but just "prop_physics" for example, what do you do ?
[QUOTE=GarrysDorian;50168065]Just to know, if you are not using a custom entity but just "prop_physics" for example, what do you do ?[/QUOTE] here's an example [CODE] for k, v in pairs(ents.FindByClass("prop_physics")) do if v:GetModel() == "yourmodel" then -- do something end end [/CODE]
[QUOTE=Tupac;50168106]here's an example [CODE] for k, v in pairs(ents.FindByClass("prop_physics") do if v:GetModel() == "yourmodel" then -- do something end end [/CODE][/QUOTE] Doing it by model might not be a good idea (actual props having the model, for example), you could set a member on your prop's table when it is created then use that. eg: upon creation: ent.SomeMember = true ... if v.SomeMember then ...
Sorry, you need to Log In to post a reply to this thread.