• surface.DrawTexturedRect Problems
    15 replies, posted
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 [I]materials/custom textures[/I] directory, the code being in a file that was called using [I]lua_openscript_cl[/I]. 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 :/ i get the bit were your useing a random material, But are you opening the .lua file running lua_openscript_cl?
[QUOTE=Tyzer;31233361]Dont understand the last bit sorry :/ i get the bit were your useing a random material, But are you opening the .lua file running lua_openscript_cl?[/QUOTE] Yeah, you can run Lua scripts on demand using [I]lua_run[/I] for serverside stuff and [I]lua_run_cl[/I] for clientside stuff, saves putting them in autorun and having to reload the game each time you change something. Have you made sure that [I]cl_hud.lua[/I] is running clientside?
For some reason this is all im getting [url]http://prntscr.com/2dcco[/url] [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 :/
Make sure the [B]vmt[/B] points to "roleplay/hud/aim".
Ohhhh yes, i will check that thanks freeman, ill update you when i checked :D [editline]20th July 2011[/editline] [url]http://prntscr.com/2dclg[/url] [url]http://prntscr.com/2dclm[/url] Hmmm, Still not showing :/
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 :) 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 :) 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 :) Thanks anyway, remember i owe you ;)
Doesn't it have to be UnlitGeneric?
Sorry, you need to Log In to post a reply to this thread.