Simple command to open webpage in game?

I was wondering if anyone could make me a simple command that I could type in game that would take them to my server leaderboards or tell me how to do it.

I want a command !stats that takes you to http://dynamicrp.org/stats/ while in game. How would i do this thank you!



hook.Add( "PlayerSay", "stats", function( ply, text, public )
  text = string.lower( text )
   if ( string.sub( text, 1, 6 ) == "!stats" ) then
    ply:SendLua( [[
      Stats = vgui.Create("HTML")
      Stats:SetPos(100,100)
      Stats:SetSize(ScrW() - 200,ScrH() - 200)
      Stats:OpenURL("http://dynamicrp.org/stats/")
      Stats:SetTooltip("")
    ]] )
    ply:SendLua( [[
      local but = vgui.Create("DColorButton", Stats)
      but:SetPos(0,0)
      but:SetSize(30, 30)
      but:SetText("")
      but:SetColor( Color(150, 255, 150) )
      but.DoClick = function()
        Stats:Remove()
      end
    ]] )
    ply:SendLua( [[
      local label = vgui.Create("DLabel", Stats)
      label:SetPos(7,7)
      label:SetText("X")
      label:SetColor( Color(255, 255, 255) )
      label:SetFont("DermaLarge")
      label.DoClick = function()
        Stats:Remove()
      end
    ]] )    
    return ""
end )


This should work.

Thank you @escept I will try this.

[editline]17th September 2017[/editline]

Where do i put this I put it in autorun/server and I got a lua error

well it might be useful if you provided the error itself

Do not put it in autorun. put it in garrysmod/lua and add “lua_openscript (NAME).lua” to your autorun.cfg.

Putting a lua file in autorun caused errors for me too.