Garry's Mod Wiki

Panel:SetPlayer

  Panel:SetPlayer( Player player, number size = 32 )

Description

Used by AvatarImage to load an avatar for given player.

Arguments

1 Player player
The player to use avatar of.
2 number size = 32
The size of the avatar to use. Acceptable sizes are 32, 64, 184. Non matching sizes will be clamped down to the highest valid number.

Example

Creates an AvatarImage with the LocalPlayer's avatar inside.

concommand.Add( "testavatar", function() local Panel = vgui.Create( "DFrame" ) Panel:SetPos( 200, 200 ) Panel:SetSize( 500, 500 ) Panel:SetTitle( "Avatar Test" ) Panel:MakePopup() local Avatar = vgui.Create( "AvatarImage", Panel ) Avatar:SetSize( 64, 64 ) Avatar:SetPos( 4, 30 ) Avatar:SetPlayer( LocalPlayer(), 64 ) -- After a second reset the avatar to no player timer.Simple( 1, function() Avatar:SetPlayer( NULL, 64 ) end ) end )