surface.DrawTexturedRect Problems

I am trying to imported my aim.vtf file into the center of my screen,

Ive done it in the past and had it working i just can seem to get it working now, can anyone please help me…

it is a file called ‘cl_hud.lua’

Here is the code…


[lua]
local AimTexture = surface.GetTextureID( “roleplay/hud/aim” );

function PaintBoxToScreen()
local BoxSize = 18;
local Offset = BoxSize / 2;

surface.SetDrawColor( 255, 255, 255, 255 );
surface.SetTexture( AimTexture );
surface.DrawTexturedRect( ScrW() * 0.5, ScrH() * 0.5, 18, 18 );

end
hook.Add( “HUDPaint”, “PaintBoxToScreen”, PaintBoxToScreen );
[/lua]

Just tried that code with another texture, works fine for me. What happens when you try it? Do you get an error?

In console i dont get ANY error just it doesnt print the VTF Onto my screen, what is the directory of the file your loading?

I’m trying it with something random in the materials/custom textures directory, the code being in a file that was called using lua_openscript_cl. Are you sure the hook is running? Try putting a print in it and see if it spams your console.

Dont understand the last bit sorry :confused: i get the bit were your useing a random material,

But are you opening the .lua file running lua_openscript_cl?

Yeah, you can run Lua scripts on demand using lua_run for serverside stuff and lua_run_cl for clientside stuff, saves putting them in autorun and having to reload the game each time you change something. Have you made sure that cl_hud.lua is running clientside?

For some reason this is all im getting
http://prntscr.com/2dcco

[editline]20th July 2011[/editline]

A little offline ino but i wanna get it to show them ill get it in place

The pink/black means the game can’t find the texture, and it’s small because you’ve set the width/height to 18x18.

Its small because its meant to be my aim, custom aim, so the size is good, but the .vtf file directory is

materials\roleplay\hud\aim.vtf
And
materials\roleplay\hud\aim.vmt

So i dont understand why it aint loading :confused:

Make sure the vmt points to “roleplay/hud/aim”.

Ohhhh yes, i will check that thanks freeman, ill update you when i checked :smiley:

[editline]20th July 2011[/editline]

Hmmm, Still not showing :confused:

And the gamemode is definitely loading? You could try putting them in garrysmod\materials instead, as a test.

Just a quick note i have it centered :slight_smile:

And yea, it is in
“garrysmod\garrysmod\materials\roleplay\hud”
and
“garrysmod\garrysmod\gamemodes\RolePlay\content\materials\roleplay\hud”

You could try removing it from one of the directories, not sure that it will do anything. As a last resort you could PM a link to the files and i’ll test them.

Cheers freeman, if we get this working i owe you, ill delete one of them and give it a go :slight_smile: Update you soon

[editline]20th July 2011[/editline]

Right, i deleted the one in the gamemode materials and it didnt work, ill send you a PM with the vtf and vmt

[editline]20th July 2011[/editline]

Doesnt matter dude, i got :slight_smile:

Thanks anyway, remember i owe you :wink:

Doesn’t it have to be UnlitGeneric?