How can i make it so when a swep is equiped it opens a website in steam over lay.
Does it have to be in a steam overlay? A vgui would work. It’d also be entirely ingame, which may be more useful.
If you want to open one in the steam overlay, all you have to use is:
gui.OpenURL("Your url here") Ex: gui.OpenURL("www.google.com")
That would be even more incredible, but how?
SetHTML w/ DHTML; in-game web browsers run into the issue of an outdated version of Awesomium, though, which messes with a lot of flash/JS elements.
What MPan1 said should help: http://wiki.garrysmod.com/page/Category:DHTML
Here’s something I made earlier (but stopped using), you can test it by putting the script in your autorun/client folder (name it whatever you want):
concommand.Add( "WebsiteTest", function() --It doesn't need to be a concommand local websiteselect = nil --Needs to be defined at the top so functions before it can still use it local HTMLselectbox = vgui.Create( "DFrame" ) --The base frame HTMLselectbox:SetSize( 1000, 600 ) --Size doesn't matter HTMLselectbox:SetTitle( "Choose a site!" ) --The title of it HTMLselectbox:Center() --Center it HTMLselectbox:ShowCloseButton( true ) --Make it closable HTMLselectbox:MakePopup() --This enables keyboard and mouse input local Loadingscreen = vgui.Create( "DPanel", HTMLselectbox ) --A screen that says 'loading', just so it doesn't go blank while the site is loading Loadingscreen:Dock(FILL) --Make it fit with the HTML select box function Loadingscreen:Paint( w, h ) --Make it look pretty with a roundedbox draw.RoundedBox( 8, 0, 0, w, h, Color( 60, 60, 60 ) ) draw.DrawText("Loading...", "Trebuchet24", 500, 270, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER) end --Below is the text entry for a URL. This isn't needed. local URLenter = vgui.Create( "DTextEntry", Loadingscreen ) --The text entry for the URL URLenter:Dock(BOTTOM) --Put it at the bottom (relative to the loading screen) URLenter:SetText( "https://www.google.com" ) --This doesn't really matter as long as it's a site URLenter.OnEnter = function() websiteselect:OpenURL( URLenter:GetText() ) --Open the URL when you press 'enter'. end websiteselect = vgui.Create( "DHTML", Loadingscreen ) --The actual HTML panel (needed). websiteselect:Dock(FILL) --Make it fit with the loading panel websiteselect:OpenURL( URLenter:GetText() ) --Open the website from the URL entering box from earlier, but this can be a website, like you probably want end )
Type ‘WebsiteTest’ in the console, and a window will open, in which you can choose a site. Note that if you change sites via google, the URL shown at the bottom box will not change. You can change the website by typing anything in the URL box at the bottom and pressing ‘Enter’.
There are quite a lot of notes on my example, so you should know what to do.
If you don’t want the window to be movable/closable, then just do something like
local website = vgui.Create( "DHTML" ) website:SetSize( ScrW(), ScrH() ) website:OpenURL("INSERT WEBSITE NAME HERE")
Obviously you can change the size and the URL, or parent it to something like a DFrame. ScrW() and ScrH() are just operations that return the screen width and screen height, meaning that example would cover the WHOLE SCREEN. To make it interactable, adding ‘website:MakePopup()’ will probably work.
Although, based on the fact you wanted a steam overlay, my guess is that you don’t want to build a whole browser from scratch, so probably best to use that if you want. Or, if you just want a closable (and/or moveable) window with any website, you could just do something like
local websitebase = vgui.Create( "DFrame" ) websitebase:SetSize( 1000, 600 ) websitebase:SetTitle( "Choose a site!" ) websitebase:Center() websitebase:ShowCloseButton( true ) websitebase:MakePopup() local website = vgui.Create( "DHTML", websitebase ) --The part after the DHTML just means what it's parented to website:Dock(FILL) website:OpenURL( "https://www.google.com" )