Hey, I was wondering how to code a VGUI that pops up when you join the server. Also, how would I add a button that when you click it it opens a url in the steam browser?
[lua]
-- server
function CrapTasket(ply)
umsg.Start("MotdMessage", ply)
umsg.End()
end
hook.Add( "PlayerInitialSpawn", "ShowStartingMenu", CrapTasket )
-- client
function OpenMOTD()
local MOTDframe = vgui.Create("DFrame")
MOTDframe:SetSize(640, 480)
MOTDframe:SetTitle("Welcome to the server")
MOTDframe:MakePopup()
local SteamBrowserButton = vgui.Create("DImageButton", MOTDframe)
SteamBrowserButton:SetSize(320, 240)
SteamBrowserButton:SetImage("yourimagedir/image.vtf")
SteamBrowserButton.DoClick = function() gui.OpenURL("http://www.yourservernameorwhatever.com/") end
end
usermessage.Hook("MotdMessage", OpenMOTD)
[/lua]
This is what I would do. Pretty sure this runs but it probably won't look very good. Key thing here is you have to create the derma clientside so you could take advantage of the PlayerInitialSpawn serverside hook and send a usermessage to the player who's spawning and make them open it that way. gui.OpenURL() will open the URL in the steam browser but it has to have the http:// or https:// prefix.
Where do I add this? What file?
Sorry, you need to Log In to post a reply to this thread.