URL

Hi FacePunch.
How to players to open the link google.com in game?
What command to use?



function Go_Google( ply, text )

	if (text == "!google") then
         --   open.url google.com
		return ""
	end
end
hook.Add( "PlayerSay", "Kill_Me", Go_Google)


gui.OpenURL()



function url_vip( ply, text )

	if (text == "!vip") then
      local button = vgui.Create( "DButton" )
      button:SetSize( 125, 90 )
      button:Center() 
      button:SetText( "Support Our Servers!" )
      button.DoClick = function()
	     gui.OpenURL( "http://examplepage.com/buy/" )
      end
	end
end
hook.Add( "PlayerSay", "url_vip", url_vip)

Doesn’t work

PlayerSay it’s server side, you must use net messages to open the frame

Because PlayerSay is Serverside, and gui.OpenURL is clientside.



--somewhere clientside
net.Receive("donate_menu_receive", function()


    gui.OpenURL("http://examplepage.com/buy/")


end)




--Somwhere serverside
util.AddNetworkString("donate_menu_receive")

local function url_vip( ply, text )

    if (text == "!vip") then
        net.Start("donate_menu_receive")
        net.Send(ply)
    end
end

hook.Add( "PlayerSay", "url_vip", url_vip)


How to me then to make this script?
What you will advise?

Use OnPlayerChat

Whether will be it works?



function url_vip( ply, text )

	if (text == "!vip") then
      local button = vgui.Create( "DButton" )
      button:SetSize( 125, 90 )
      button:Center() 
      button:SetText( "Support Our Servers!" )
      button.DoClick = function()
		 ply:SendLua( "gui.OpenURL( "http://examplepage.com/buy/" )" )
      end
	end
end
hook.Add( "PlayerSay", "url_vip", url_vip)


[editline]5th April 2015[/editline]


function url_vip( ply, text )

	if (text == "!vip") then
      local button = vgui.Create( "DButton" )
      button:SetSize( 125, 90 )
      button:Center() 
      button:SetText( "Support Our Servers!" )
      button.DoClick = function()
		gui.OpenURL( "http://examplepage.com/buy/" )
      end
	end
end
hook.Add( "OnPlayerChat", "url_vip", url_vip)

Doesn’t work

you don’t have the knowledge (or desire to learn) to make your server successful
it is doomed to be horrible and filled with poorly executed vip garbage, forever

Don’t use OnPlayerChat, that’s called whenever anyone talks. Just stick with what I gave you. Stop trying to overcomplicate it with a Derma button (that’s not even parented to anything). You could even incorporate what you did.



local function url_vip( ply, text )

    if (text == "!vip") then
        ply:SendLua[[gui.OpenURL("http://examplepage.com/buy/")]]
    end
end

hook.Add( "PlayerSay", "url_vip", url_vip)


The vgui stuff (the button) is client side too.

I don’t know why, but it doesn’t wish to work.

OnPlayerChat is just the clientside equivolent of PlayerSay; they’re synonymous.

Synonymous hooks :v:
Interesting way to put it

Same hooks, different realms. Using it clientside prevents having to use SendLua

In case you want to use a vgui (which would be fully ingame, and would probably work without steam), I commented a LOT of lua to use on this thread.