Hello everyone, Im creating a HUD for DarkRP and i would like it to show the persons avatar. My HUD is a DarkRP module and not in the addons folder.
Im attempting to draw the avatar like this:
[CODE]local PlayerAvatar = vgui.Create( "AvatarImage", Panel )
PlayerAvatar:SetSize( 64, 64 )
PlayerAvatar:SetPos( HUDPosX, HUDPosY)
PlayerAvatar:SetPlayer( LocalPlayer(), 64 )[/CODE]
The only problem is when im live positioning it you can still see a avatar in old position and it eventually gets laggy?
Im guessing thats because its redrawing it loads of times or its a Derma and its just constantly being opened. Anyone got any suggestions on how i can fix this or get the users avatar using draw?
Do something like this ( mandatories, first example ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url]
Then, add:
if ( !_p.__HUDAvatar ) then _p.__HUDAvatar = vgui.Create.....
Otherwise you're creating the element every frame, whereby you'll eventually run out of memory and lag / crash.
Sorry, you need to Log In to post a reply to this thread.