Team Spartan Cookies & Milk Forums
[BUG/Needs optimization]VGUI - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: [BUG/Needs optimization]VGUI (/thread-1058.html)

Pages: 1 2


[BUG/Needs optimization]VGUI - SuperPlayer - 30-06-2015

Hello!
Today i looked into the world of VGUI's. It very cool but after a few times connecting myself to the hud my Gmod is crashing. I dont know if it is a bug or i am just too stupid to find the error in my code, i dont know. Also the DoClick function doesnt work. Maybe thats the problem? Thats the code i am using:

--@name MAINFRAME_HUD
--@author SuperPlayer
--@requirecl lib/string.txt
--@updater STEAM_0:0:74694146
--@shared

if SERVER then

else
local BackTex = render.getTextureID("Boba_Fett/textures/atlantiswall_blue")
--A player has linked to us.
hook( "hudlink", "bleh", function( Ply )

local BackTex = render.getTextureID("Boba_Fett/textures/atlantiswall_blue")

local Frame = vgui.create( "DFrame" )
Frame:SetSize( 1000, 600 )
Frame:Center()
Frame:MakePopup()
Frame:SetText("Mainframe HUD")
Frame:ShowCloseButton(true)
Frame:replaceMethod( "Paint", function( self, W, H )
render.setTexture(BackTex)
render.setColor( 255, 255, 255 )
render.drawTexturedRect( 0, 0, W, H )
end )
local CloseButton = vgui.create( "DButton" ,Frame)
CloseButton:SetPos( 0,0 )
CloseButton:SetSize( 90, 45 )
CloseButton:SetText( "Close" )
CloseButton:SetTextColor( Color( 255, 255, 255 ) )
CloseButton:replaceMethod( "Paint", function( self, W, H )
render.setTexture(BackTex)
render.setColor( 255, 255, 255 )
render.drawTexturedRect( 0, 0, W, H )
end)
CloseButtonBig GrinoClick( function()
Frame:remove()
end)




end )
hook( "hudunlink", "bleh", function( Ply )

end )
end




RE: [BUG/Needs optimization]VGUI - Person8880 - 30-06-2015

You're trying to draw a material designed for a 3D lit model on a 2D surface. That's why it's crashing.

As for DoClick, you're calling DoClick with a function argument, i.e. you're doing nothing.

You already have the replacement for Paint, DoClick is the same thing:
CloseButton:replaceMethod( "DoClick", function( self )
Frame:Remove()
end )



RE: [BUG/Needs optimization]VGUI - SuperPlayer - 30-06-2015

Hmm. What can i use instead? Is there another material i can use or just no material? And how das DoClick() works?


RE: [BUG/Needs optimization]VGUI - Person8880 - 30-06-2015

Why do you need a material? If you want to draw with no material, then use render.drawRect().

DoClick is called whenever you click the button. The argument passed is the button object.


RE: [BUG/Needs optimization]VGUI - SuperPlayer - 30-06-2015

I like how material look. Ok so i just wont use it. Thx for the fast help!


RE: [BUG/Needs optimization]VGUI - Person8880 - 30-06-2015

Hmm, just double checked the SF VGUI code and there is one typo which might also cause problems. I'm restarting #2 with the fix, but #1 can't load it until it restarts.


RE: [BUG/Needs optimization]VGUI - SuperPlayer - 30-06-2015

Ok i will try it. Because on Server #1 if i press use when the VGUI is on my screen i crash every second time.

Ok it doesnt crash anymore but if I am linked to the hud once and i get unlinked or linked, whenever i press use wherever i aim.


RE: [BUG/Needs optimization]VGUI - Person8880 - 30-06-2015

Not sure what you mean by that last part. It only links/unlinks when you press use on it or sit in/get out of a linked chair.


RE: [BUG/Needs optimization]VGUI - SuperPlayer - 01-07-2015

I mean if I spawn an HUD and i am close to it it doesnt matter where i look/aim i get linked/unliked by the hud when i press USE. Also if i spawn a SF-Screen next to it The VGUI opens for some reasons.


RE: [BUG/Needs optimization]VGUI - Person8880 - 01-07-2015

You're using the standard model? The use events are controlled by the Source engine code so there's little I can do about them being overly sensitive.