I'll give you a little introduction to hooks.
Hooks are what Garry's Mod lets scripters use to "hook into" game events. It allows us to perform certain actions when an event happens in the game. The
GM:PlayerSay hook lets us do something when someone sends a message in the chat. There are three parameters to PlayerSay: The Player that sent the message, the String that holds the text inside the message, and a Boolean (true/false) variable that says whether or not the message was sent to only the person's team or not. Since we don't care if it's team chat or not, we can ignore it in our parameter list ( everything inside of the parentheses ).
So when I said "this can be named anything" I mean the function name ( in this case, "openGoogle" ) can be named anything. If you wanted
function thisIsStupid( ply, text )
that would work just as well, but you'd have to edit it in the hook.Add statement at the bottom. The parameters, again, are anything inside of the parentheses. We want something that is distinguishable as a Player, so we use ply ( again, though, this can be anything, but we use 'ply' or 'calling_ply' as a standard in gLua to make code easier to read ). The next thing PlayerSay wants us to provide is a variable for the message. On the wiki page (
GM:PlayerSay) the parameter is "text", so we generally use "text" as our variable.
The "!google" on line 3 is the text that our script is checking. If the message that the person sent starts with "!google", our script will be performed ( if not, nothing will happen, at least in our script ) and the webpage "google" will be opened in their browser.
If you wanted to use this example, all you have to change is the string ( anything inside quotes [ "" ] ) next to where it says "local URL = "
For example, if you wanted to link to your donation website, you would need to change where it says "
http://www.google.com" to whatever your donation link is. You will also need to change the command you want to open this. Line 2 says
if ( string.sub( text, 1, 7 ) == "!google" ) then
What this is checking is if the substring ( a part of a string ) if the message sent is equal to "!google", then whatever is inside this if statement ( anything before the next "end" ) will be executed.
I see you're fairly new to Lua, so here are some links that might help:
How to use hooks:
http://wiki.garrysmod.com/page/Hook_Library_UsageLua String library:
https://www.lua.org/pil/20.htmlWhat are functions?:
https://www.lua.org/pil/5.htmlLet me know if anything in here was confusing; I tried to break it down for you.