Ok this should work, as it’s based on the toolgun’s code, but I haven’t tested it.
Texture the ammo counter models/weapons/flak/screen (or something else and change the paths below) and have the background you want it as models/weapons/flak/screen_bg. (again change the name, but you do need a background otherwise it’ll look like a vortex.)
Put a file in youraddon/settings/render_targets/ called FlakCannon.txt and set it’s contents to this
"FlakCannon"
{
"Name" "FlakCannon"
"Width" "256"
"Height" "128"
}
Feel free to change the dimensions to the same as your counter texture, but remember to change them in the Lua too.
Then put this in a clientside portion of your SWep.
[lua]local matScreen = Material( “models/weapons/flaky/screen” )
local txBackground = surface.GetTextureID( “models/weapons/flaky/screen_bg” )
// GetRenderTarget returns the texture if it exists, or THROW LOTS OF DAMN ERRORS IF IT DOESN’T ARGH
local w,h = 256, 128-- Dimensions guessed at, put your own.
local RTTexture = GetRenderTarget( “FlakCannon”, w,h )
function SWEP:ViewModelDrawn()
local NewRT = RTTexture
// Set the material of the screen to our render target
matScreen:SetMaterialTexture( "$basetexture", NewRT )
local OldRT = render.GetRenderTarget();
// Set up our view for drawing to the texture
render.SetRenderTarget( NewRT )
render.SetViewPort( 0, 0, w,h )
cam.Start2D()
// Background
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetTexture( txBackground )
surface.DrawTexturedRect( 0, 0, w,h )
surface.SetFont( "GModToolScreen" )
surface.SetTextColor(255,255,255,255)
local words = self:Clip1() -- I think that's right, I can't remember off the top of my head
local w1,h1 = surface.GetTextSize(words)
surface.SetTextPos((w-w1)/2,(h-h1)/2)
surface.DrawText(words)
cam.End2D()
render.SetRenderTarget( OldRT )
end[/lua]If it doesn’t, drop me a PM and I’ll see what I can do.
I’ve always liked the flak cannon. :3: