• URL
    15 replies, posted
Hi FacePunch. How to players to open the link google.com in game? What command to use? [CODE] function Go_Google( ply, text ) if (text == "!google") then -- open.url google.com return "" end end hook.Add( "PlayerSay", "Kill_Me", Go_Google) [/CODE]
[URL="http://wiki.garrysmod.com/page/gui/OpenURL"]gui.OpenURL()[/URL]
[QUOTE=Lolcats;47463147][URL="http://wiki.garrysmod.com/page/gui/OpenURL"]gui.OpenURL()[/URL][/QUOTE] [CODE] 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)[/CODE] Doesn't work
PlayerSay it's server side, you must use net messages to open the frame
Because [URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL] is Serverside, and gui.OpenURL is clientside. [code] --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) [/code]
[QUOTE=Lolcats;47463204]Because [URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL] is Serverside, and gui.OpenURL is clientside.[/QUOTE] How to me then to make this script? What you will advise?
Use OnPlayerChat
Whether will be it works? [CODE] 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) [/CODE] [editline]5th April 2015[/editline] [CODE]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)[/CODE] 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. [code] 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) [/code]
The vgui stuff (the button) is client side too.
[QUOTE=Lolcats;47463316]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. [code] 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) [/code][/QUOTE] I don't know why, but it doesn't wish to work.
[QUOTE=Lolcats;47463316]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. [code] 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) [/code][/QUOTE] OnPlayerChat is just the clientside equivolent of PlayerSay; they're synonymous.
Synonymous hooks :v: Interesting way to put it
[QUOTE=r0uge;47463555]Synonymous hooks :v: Interesting way to put it[/QUOTE] 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 [URL="http://facepunch.com/showthread.php?t=1458983"]this thread.[/URL]
Sorry, you need to Log In to post a reply to this thread.