Player skins from web?

Hey!

I remember someone in waywo creating materials from web and applying it to players?

How can i create material for my player shirt?

I know that i have to use SetSubMaterial but how do i upload material to my website and get it to my server so i could pass it to the setsubmaterial?

Here’s one of the helpful FP threads related to what you want. There’s one more that I still need to find. I’ll update this post if/when I find it.

http://forum.facepunch.com/showthread.php?t=1453630&p=47286486&viewfull=1#post47286486

Yea i saw this a while ago http://forum.facepunch.com/showthread.php?t=1453630&p=47286486&viewfull=1#post47286486

[editline]9th July 2015[/editline]

Ninja’d :stuck_out_tongue:

stupid firefox show me updated posts

I dont still understand how the png should look and i dont see it getting fetched or anything?

why dont u track down the guy that posted that, social networks steam skype etc thats what i usually do when i need something but i dont have any friends ;(

I recall girrafen or someone posting a nice full c&p code base but I can’t find it.

I could be wrong here as I’ve never done this but I believe you load the wanted png/material in a DHTML then use

Panel:GetHTMLMaterial to load it into a material. Then do as Nak did.

And now i just need to know how the png should look. I think that just image what i want on shirt will not work as everything else will be errors?

I guess there are ways around it, but loading materials from DHTML causes a small 1-2 second freeze on all players, pretty annoying.

Got this done, doesnt work?



CLOTH = {}
CLOTH.Panel = nil
CLOTH.Mat = nil
CLOTH.Url = "http://futuretechs.eu/hl3.png"

function CLOTH.LoadMat()

	if ( CLOTH.Panel ) then

		CLOTH.Panel:Remove()
		CLOTH.Panel = nil

	end

	-- Create a web page panel and fill the entire screen
	CLOTH.Panel = vgui.Create( "DHTML" )
	CLOTH.Panel:Dock( FILL )

	CLOTH.Panel:OpenURL( CLOTH.Url )
	CLOTH.Panel:SetAlpha( 0 )
	CLOTH.Panel:SetMouseInputEnabled( false )
	function CLOTH.Panel:ConsoleMessage( msg ) end
end

function CLOTH.LoadCloth()
	if CLOTH.Panel and CLOTH.Panel:GetHTMLMaterial() then
	
		CLOTH.Mat = CLOTH.Panel:GetHTMLMaterial()
		//local tex = Material( CLOTH.Mat, "nocull smooth" )
		local mattex = CLOTH.Mat:GetString( "$basetexture" )
		local params = {
			["$basetexture"] = mattex
		} 
		local clothmaterial = CreateMaterial("mat_hl3","VertexLitGeneric",params)
	
		LocalPlayer():SetSubMaterial( 2, clothmaterial )
	else
		timer.Simple( 2, function()
			CLOTH.LoadCloth()
		end )
	end
end

CLOTH.LoadMat()
CLOTH.LoadCloth()


Any errors?

No.

you can’t call CLOTH.Panel:GetHTMLMaterial() immediately after loading the page. Here is a similar system (this time used for sprays loaded from a php page, loaded from a mysql. https://gist.github.com/JamesxX/63d9c47e4e47b0d3b6f7

Well, you see, i know that.
I do check
if CLOTH.Panel and CLOTH.Panel:GetHTMLMaterial() then
to see if it is loaded, if it it not, i restart the function 2 seconds later so it loads,
Well, i have been messing with functions and made the material draw to my screen, under right angle it shows the image but flickers?

Current code:



CLOTH = {}
CLOTH.Panel = nil
CLOTH.Mat = nil
CLOTH.Url = "http://futuretechs.eu/hl3.png"
CLOTH.Loaded = false

function CLOTH.LoadMat()

	if ( CLOTH.Panel ) then

		CLOTH.Panel:Remove()
		CLOTH.Panel = nil

	end

	-- Create a web page panel and fill the entire screen
	CLOTH.Panel = vgui.Create( "DHTML" )
	CLOTH.Panel:Dock( FILL )

	CLOTH.Panel:OpenURL( CLOTH.Url )
	CLOTH.Panel:SetAlpha( 0 )
	CLOTH.Panel:SetMouseInputEnabled( false )
	function CLOTH.Panel:ConsoleMessage( msg ) end
end

function CLOTH.LoadCloth()
	if CLOTH.Panel and CLOTH.Panel:GetHTMLMaterial() then
	
		CLOTH.Mat = CLOTH.Panel:GetHTMLMaterial()
		
		local scale_x, scale_y = ScrW()/2048, ScrH()/2048
		
		local params = {
			["$basetexture"] = CLOTH.Mat:GetName(),
			["$basetexturetransform"] = "center 0 0 scale "..scale_x.." "..scale_y.." rotate 0 translate 0 0",
			["$model"] = 1,
		} 
		
		local uid = string.Replace( CLOTH.Mat:GetName(), "__vgui_texture_", "" )
		
		CLOTH.clothmaterial = CreateMaterial("WebMaterial_"..uid,"VertexLitGeneric",params)
		CLOTH.Loaded = true
	else
		timer.Simple( 2, function()
			CLOTH.LoadCloth()
		end )
	end
end

hook.Add( "HUDPaint", "Test", function()
	if CLOTH.Loaded then 
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( CLOTH.clothmaterial )
		surface.DrawTexturedRect( 64, 64, 256, 256 )	
	end
end )

CLOTH.LoadMat()
CLOTH.LoadCloth()


[editline]10th July 2015[/editline]

Okey, no idea why it draw under certain angles

I can make it draw on the screen now normally, but still can’t get it right do draw skins, it just doesnt draw.

Bump, how to use render.MaterialOverrideByIndex?

EDIT:

Trying to achieve this http://forum.facepunch.com/showthread.php?t=1453630&p=47288532&viewfull=1#post47288532

How did you manage to get it drawing correctly? I’ve been working on something along the same lines, but the icon flashes when I move the mouse.

bump