[B]Hi,[/B]
How can I add an image to a HUD ? (Not like an icon for wanted/gun license for DarkRP an actual image).
Where can I store this image and I don't know what code to use. ( If you can link me to the post on the gmod wiki )
[QUOTE=AustinH;49860878]
[code]
net.Receive("image", function()
local image = vgui.Create( "DImage") -- Make the actual thing
image:SetPos( 10, 10 ) -- Where on the screen it draws
image:SetSize( 380, 380 ) -- How big in pixels
image:SetImage( "" ) -- Materials/
image:MakePopup() -- Make it show
end) -- End it
[/code]
[code]
util.AddNetworkString( "menu" ) -- Cache the netmessage
function GM:PlayerSpawn( ply ) -- When the player spawns, run this function
net.Start("menu") -- Start the message
net.Send(ply) -- Send it to all players
end
[/code][/QUOTE]
:what:
[QUOTE=Tupac;49859515]Heres an example:
[CODE]
local image = Material( "imagepath" )
surface.SetMaterial( image )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 0, 0, 100, 100 )
[/CODE][/QUOTE]
Thank you, so I just store the image in materials/ folder and put in imagepath - material/imageexample.png right?
Assuming that's to be put in a HUDPaint hook, that's not the most efficient way to do it.
First cache the material, then draw it, otherwise it'll be creating a material each frame.
[code]
local Image = Material( "image/path" )
hook.Add( "HUDPaint", "ImagePaint", function()
surface.SetMaterial( Image )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 0, 0, 100, 100 )
end )
[/code]
[QUOTE=McDunkable;49862080]Assuming that's to be put in a HUDPaint hook, that's not the most efficient way to do it.
First cache the material, then draw it, otherwise it'll be creating a material each frame.
[code]
local Image = Material( "image/path" )
hook.Add( "HUDPaint", "ImagePaint", function()
surface.SetMaterial( Image )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 0, 0, 100, 100 )
end )
[/code][/QUOTE]
In [code] surface.SetMaterial( Image )[/code] in the ( Image ) do I put something there or just leave like that ?
[QUOTE=Athods;49862160]In [code] surface.SetMaterial( Image )[/code] in the ( Image ) do I put something there or just leave like that ?[/QUOTE]
Leave it. You are setting "Image" to the material defined in the local Image line.
Just set the path to the material you want.
Sorry, you need to Log In to post a reply to this thread.