Hook Problem

I need to make a script that has
6 hooks to websites like
when someone writes
addons goes to addons file
facebook goes to facebook page
rules goes to rules page
forum goes to forum page
and 2 more in case I need,
How can I put these all in one script?

Look into a PlayerSay hook, elseif statements and gui.OpenUrl(“url”)

Yea,But how Do I put it a lot in only one script?

You just… do it?
Like Niandra said, elseifs

Didn’t got it,

Alright.
You will need to hook into playersay with a function that checks if the text argument of playersay is equal to your command. After this, you will have an elseif statement for each of the other commands. Each of these statements will contain a gui.OpenURL to your link.

If you still don’t understand these concepts of if/elseif, you may want to read up on programming/lua programming specifically, here:

Alright uh if you don’t want a bunch of elseif statements I wrote something up quickly, this might be a bad way of doing it, some of these boys or girls probably has a better way but it should give you a basic idea of how it looks like in code:

[lua]if ( SERVER ) then

util.AddNetworkString( “send_link_request” )

linkTable = {}

linkTable[“forum”] = “http://www.google.com
linkTable[“rules”] = “http://www.youtube.com
linkTable[“addons”] = “http://www.facepunch.com
linkTable[“facebook”] = “http://www.scriptfodder.com

hook.Add(“PlayerSay”, “open_something”, function( ply, text)
local args = string.Explode( " ", text:lower() )
if( args[1] != “!open” ) then return end

			for keyword, link in pairs( linkTable ) do
				if( args[2] == keyword ) then
					net.Start( "send_link_request" )
					net.WriteString( tostring( link ) )
					net.Send( ply )
			end
	end

end)

else // clientside

net.Receive( "send_link_request", function()
	gui.OpenURL( net.ReadString() )
end)

end

// How to use

// !open forum
// !open rules
// !open addons
// !open facebook
[/lua]

Goes in garrysmod/lua/autorun.

I haven’t done lua in ages and I was never really good at it, just wrote this up quickly without testing it, but should work, didn’t comment anything out though.

Hope it helps.

Edit: You could probably do all this clientside with the OnPlayerChat hook.

Give this wiki page a read first

Official wiki version (might be updated)

Not that it really matters as the guy got spoonfed :rolleyes:

Or you can use this, it’ quite hard though.