Help with disabling VGUI DModelPanel when menu is open
2 replies, posted
I have created this VGUI :
[CODE] draw.RoundedBox(6, 10, ScrH()-150, 140, 140, Color(0,255,0,200))
PlayerModel = vgui.Create("DModelPanel")
function PlayerModel:LayoutEntity( Entity ) return end
PlayerModel:SetModel( LocalPlayer():GetModel() )
PlayerModel:SetPos(0, ScrH() - 190)
PlayerModel:SetSize(150,175)
PlayerModel:SetCamPos(Vector( 20, 0, 65 ))
PlayerModel:SetLookAt(Vector( 5, 0, 63 ))
timer.Create( "UpdatePlayerModel", 0.5, 0, function()
if LocalPlayer():GetModel() != PlayerModel.Entity:GetModel() then
PlayerModel:Remove()
PlayerModel = vgui.Create("DModelPanel")
function PlayerModel:LayoutEntity( Entity ) return end
PlayerModel:SetModel( LocalPlayer():GetModel())
PlayerModel:SetPos(5, ScrH() - 190)
PlayerModel:SetSize(152,170)
PlayerModel:SetCamPos(Vector( 20, 0, 65 ))
PlayerModel:SetLookAt(Vector( 0, 0, 63 ))
end
end)[/CODE]
and im experiencing this problem:
[IMG]http://i.imgur.com/T784cie.png[/IMG]
How can I "disable" the vgui when the ESC menu is open?
1. To disable your stuff while menu is open, use gui.IsGameUIVisible()
2. Create your vgui elements out of the hudpaint hook, or you'll destroy memory
3. In your updateplayermodel timer, there's no need to recreate the element. just do PlayerModel:SetModel( LocalPlayer():GetModel() )
[QUOTE=rejax;43896097]1. To disable your stuff while menu is open, use gui.IsGameUIVisible()
2. Create your vgui elements out of the hudpaint hook, or you'll destroy memory
3. In your updateplayermodel timer, there's no need to recreate the element. just do PlayerModel:SetModel( LocalPlayer():GetModel() )[/QUOTE]
I'm really new to lua, i've tried to do this:
[CODE] if gui.IsGameUIVisible() then
PlayerModel:SetVisible(false)
Avatar:SetVisible(false)
else
PlayerModel:SetVisible(true)
Avatar:SetVisible(true)
end[/CODE]
It still dosent work :\
did I do it wrong?
Sorry, you need to Log In to post a reply to this thread.