Custom Chat Commands

I cant figure out how to make the command !addons open up the webpage.
Here is what I have.

local function OpenAddonPage( ply, text, team )
if string.sub(text, 1, 8 ) == “!addons” then

	ply.SendLua( [[ gui.OpenURL( "" ) ]] )


hook.ADD( “PlayerSay”, “OpenAddonPage”, OpenAddonPage )

But it just gives errors. Any help would be good.

  1. Use a plain comparison for text or else !addonsblahblah will work. (text:lower() == “!addons”)
  2. Call SendLua as a function of ply, so use a colon instead of dot. (ply:SendLua(…))
  3. ADD should be Add.

This code is originally from custom ulx commands (which is released to the public now) you can play around with it to make it work. Make a lua file in /garrysmod/addons/ulx/lua/ulx/modules/sh (Assuming you’re running ULX else this is useless.)
Here is what I have.

function ulx.url( calling_ply, target_plys, openedurl, should_silent )
	if( string.find( openedurl, "porn" ) ) then
		ULib.tsayError( calling_ply, "Nice try...", true ) -- get rekt

	for k,v in pairs( target_plys ) do

		v:SendLua([[gui.OpenURL( "]] .. openedurl .. [[" )]])

	if should_silent then
		ulx.fancyLogAdmin( calling_ply, true, "#A opened url #s on #T", openedurl, target_plys )
		ulx.fancyLogAdmin( calling_ply, "#A opened url #s on #T", openedurl, target_plys )

local url = ulx.command( "Rcon", "ulx url", ulx.url, "!url" )
url:addParam{ type=ULib.cmds.PlayersArg }
url:addParam{ type=ULib.cmds.StringArg, hint="url", ULib.cmds.takeRestOfLine }
url:addParam{ type=ULib.cmds.BoolArg, invisible=true }
url:defaultAccess( ULib.ACCESS_SUPERADMIN )
url:help( "Open a URL on target(s)." )
url:setOpposite( "ulx surl", { _, _, _, true }, "!surl" )