[CODE] local Avatar = vgui.Create( "AvatarImage", Panel )
Avatar:SetSize( 100, 100 )
Avatar:SetPos( 65, 100 )
Avatar:SetPlayer( LocalPlayer(), 100 )[/CODE]
Ok so I have this, everything on the server works no errors. But when I change anything inside of the addon folder I put this in, it lags the player who owns the Avatar image. (Me basically)
Is there a way, to check if something has been changed and remove the avatar and reset it ?
Move that outside the HUDPaint hook - if you create any sort of vgui element in a HUDPaint hook then it'll create one every frame on top of the previous one, which as you can imagine can get very laggy since the previous one never gets removed
[QUOTE=MPan1;50794904]Move that outside the HUDPaint hook - if you create any sort of vgui element in a HUDPaint hook then it'll create one every frame on top of the previous one, which as you can imagine can get very laggy since the previous one never gets removed[/QUOTE]
Oh ok, thanks.
[editline]29th July 2016[/editline]
[QUOTE=jacobcooper18;50794907]Oh ok, thanks.[/QUOTE]
Um, it dosen't really work? I moved it into another Init Hook but it seems to no longer be there xD
[editline]29th July 2016[/editline]
[QUOTE=MPan1;50794904]Move that outside the HUDPaint hook - if you create any sort of vgui element in a HUDPaint hook then it'll create one every frame on top of the previous one, which as you can imagine can get very laggy since the previous one never gets removed[/QUOTE]
So how can I display it? Do I make a panel hook?
[editline]29th July 2016[/editline]
[CODE]function InitSpawn( ply )
local Avatar = vgui.Create( "AvatarImage", Panel )
Avatar:SetSize( 100, 100 )
Avatar:SetPos( 65, 100 )
Avatar:SetPlayer( LocalPlayer(), 100 )
end
hook.Add( "PlayerInitialSpawn", "Setup", InitSpawn )[/CODE]
I tried that..
I tried a different hook, and it seems to work alright for me
[CODE]
local function DoAvatar()
local Avatar = vgui.Create( "AvatarImage" )
Avatar:SetSize( 100, 100 )
Avatar:SetPos( 65, 100 )
Avatar:SetPlayer( LocalPlayer(), 100 )
end
hook.Add( "InitPostEntity", "Setup", DoAvatar )
[/CODE]
[B]EDIT:[/B] Geferon's way is better though since it only needs one hook
[CODE]
local avatar
hook.Add("HUDPaint", "CustomHUD", function()
-- DO HUD PAINT
if not IsValid(avatar) then
-- YOU HAVE TO CREATE THE PANEL WITH Panel VARIABLE HERE AS WELL, IF NOT IT WILL LAG
avatar = vgui.Create("AvatarImage", Panel)
avatar:SetSize(100, 100)
avatar:SetPos(65, 100)
avatar:SetPlayer(LocalPlayer(), 100)
end
end)
[/CODE]
[QUOTE=geferon;50794946][CODE]
local avatar
hook.Add("HUDPaint", "CustomHUD", function()
-- DO HUD PAINT
if not IsValid(avatar) then
-- YOU HAVE TO CREATE THE PANEL WITH Panel VARIABLE HERE AS WELL, IF NOT IT WILL LAG
avatar = vgui.Create("AvatarImage", Panel)
avatar:SetSize(100, 100)
avatar:SetPos(65, 100)
avatar:SetPlayer(LocalPlayer(), 100)
end
end)
[/CODE][/QUOTE]
Yeah but, HUDPaint is what I had it in before and it lagged out..
[editline]29th July 2016[/editline]
Works perfectly thanks!
Sorry, you need to Log In to post a reply to this thread.