Find the users avatar?

I know how to apply a material to a derma, but what i need to know is how to call a users avatar in lua so i can apply said material, anyone know?

An avatar isn’t a material, but you can get someone’s avatar as such:

[lua]local av = vgui.Create(“Avatar”)
av:SetPos( 10, 10 )
av:SetSize( 100, 100 )
av:SetPlayer( LocalPlayer() )[/lua]

That will show your avatar at the top left of the screen.

Thanks for the repsonse however im getting a error,

hud1.lua:32: attempt to index local ‘av’ (a nil value)

Copy the full code then?

I did

av might already be a variable, try changing it. here is an example:


local PlAvatar = vgui.Create("Avatar")  
PlAvatar:SetPos( 10, 10 )  
PlAvatar:SetSize( 100, 100 )  
PlAvatar:SetPlayer( LocalPlayer() )  

Nope, Same error

Are you running this code on the client?

Tried it with luapad,


 
Warning: vgui.Create failed to create the VGUI component (Avatar)


Avatar isn’t valid even though glua wiki says it is.

[editline]12:47AM[/editline]

and thats client…

luapad? what is that? is it similar to notepad++?

luapad is an In-game scripting environment.

[editline]12:54AM[/editline]

Well, then again some vgui things fail with luapad but still. It gave that error.

No it’s not. It’s a ingame script editor. It has nothing to do with scripting enviorments.

…I just copy pasted what the title of the post said, lol.

also it is considered a scripting environment because it has a script launcher and some other things that make a scripting environment

Yes

Figured it out,

[lua] local Displayavatar = vgui.Create(“AvatarImage”) // It’s AvatarImage Not Avatar
Displayavatar:SetPos( 10, 10 )
Displayavatar:SetSize( 75, 75 )
Displayavatar:SetPlayer( LocalPlayer() ) [/lua]
The bad part about this is…if you try drawing it at 100, 100 it gets all pixelated, or at least mine did…then again I think there is another way to do it that will make it a better image but I don’t know it :[

Thanks, it worked :smiley:

That’s because the native resolution of an avatar in it is 64 by 64 pixels.