• Find the users avatar?
    16 replies, posted
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.
[QUOTE=Entoros;20769245]An avatar isn't a material, but you can get someone's avatar as such: local av = vgui.Create("Avatar") av:SetPos( 10, 10 ) av:SetSize( 100, 100 ) av:SetPlayer( LocalPlayer() ) That will show your avatar at the top left of the screen.[/QUOTE] Thanks for the repsonse however im getting a error, hud1.lua:32: attempt to index local 'av' (a nil value)
[QUOTE=iRzilla;20769852]Copy the full code then?[/QUOTE] I did
av might already be a variable, try changing it. here is an example: [code]local PlAvatar = vgui.Create("Avatar") PlAvatar:SetPos( 10, 10 ) PlAvatar:SetSize( 100, 100 ) PlAvatar:SetPlayer( LocalPlayer() ) [/code]
Nope, Same error
Are you running this code on the client?
Tried it with luapad, [code] Warning: vgui.Create failed to create the VGUI component (Avatar) [/code] Avatar isn't valid even though glua wiki says it is. [editline]12:47AM[/editline] and thats client..
[QUOTE=DocDoomsday;20770168]Tried it with luapad, [code] Warning: vgui.Create failed to create the VGUI component (Avatar) [/code] Avatar isn't valid even though glua wiki says it is. [editline]12:47AM[/editline] and thats client..[/QUOTE] 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.
[QUOTE=iRzilla;20770322]No it's not. It's a ingame script editor. It has nothing to do with scripting enviorments.[/QUOTE] ...I just copy pasted what the [URL="http://www.facepunch.com/showthread.php?t=776712"]title of the post[/URL] said, lol. also it is considered a scripting environment because it has a script launcher and some other things that make a scripting environment
[QUOTE=Jo The Shmo;20770162]Are you running this code on the client?[/QUOTE] 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 :D
[QUOTE=DocDoomsday;20771216]The bad part about this is...if you try drawing it at 100, 100 it gets all pixelated[/QUOTE] That's because the native resolution of an avatar in it is 64 by 64 pixels.
Sorry, you need to Log In to post a reply to this thread.