• Print

Author Topic: DrawTexturedRect Help  (Read 4406 times)

0 Members and 1 Guest are viewing this topic.

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
DrawTexturedRect Help
« on: October 26, 2014, 03:03:54 pm »
So I'm trying to make a HUD for a Jailbreak gamemode, and I can't get the texture to render. The server console does not give me any lua errors so I don't know what's going on. The text works just fine, but the texture won't come up. If you could tell me errors in the code it'll be nice. :) This is in the cl_init.lua of the gamemode.
Fixed, put working code in. :D
Code: Lua
  1.         function GM:HUDPaint()
  2.                 self.BaseClass:HUDPaint()
  3.                 local ply = LocalPlayer()
  4.                 local HP = LocalPlayer():Health()
  5.                
  6.                 surface.SetDrawColor(255,255,255,255)
  7.                 surface.SetMaterial( Material( "materials/pdhud/hp.png", "noclamp" ) )
  8.                 surface.DrawTexturedRect( 0, ScrH() / 30, 42, 42 ) -- Draws HP Icon
  9.                 surface.SetTextColor( 255, 0, 0, 255 )
  10.                 surface.SetTextPos( 50, ScrH() / 50 )
  11.                 surface.SetFont( "pd_basefont" )
  12.                 surface.DrawText( HP ) -- Puts HP Next to HP Icon
  13.         end
  14.  
« Last Edit: October 27, 2014, 05:32:26 pm by Dog »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: DrawTexturedRect Help
« Reply #1 on: October 26, 2014, 07:05:17 pm »
The server console does not give me any lua errors
FYI - It shouldn't. If errors were occuring, they should appear CLIENT console. :)
I'm not experienced in GUI. Little help other than that tip, and asking, are your texture pngs on your client in materials/pdhud/hp.png?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Dog

  • Newbie
  • *
  • Posts: 17
  • Karma: 1
Re: DrawTexturedRect Help
« Reply #2 on: October 26, 2014, 07:45:03 pm »
The png file is in materials/pdhud/hp.png. I would like to say before this I had an error with my text, the texture was blinking(very odd). I was using SetText instead of DrawText at the time. I also have vmt and vtf files of the pngs.
Here's the files for the materials:

Just figured out what you said. :P Yeah, they're in my client's download/materials/pdhud/hp.png
P.S. Thanks I'll check the client console and look for stuff there.
Found something in client console:
Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material)
I don't know how to use a vmt(or vtf) material so that's why I did a png.
« Last Edit: October 26, 2014, 08:31:30 pm by Dog »

  • Print