!join Command with LUA

Hello, right now I’m trying to create a command that will open my steam group’s profile for a user when they type !join in chat, this is the code I have so far:


function myCommand ( ply, text, public )
	if( string.sub( text, 1, 6) == "!join" ) then
		gui.OpenURL("http://steamcommunity.com/groups/basedgamings")
	end
end
hook.Add( "PlayerSay" , "myCommand" , myCommand )

It wasn’t working before, there was no response to the !join command.

The questions I have are, will this code work, and where does the .lua file with the code need to be? I’m running a TTT server.

I didn’t know that “!join” are 6 chars :v:

Oh thank you, now, where would i put this lua to have the command work?

Noticed that a second later, you are using the wrong hook too, atleast for complexity reasons it should look like this:

[lua]
hook.Add(“OnPlayerChat”, “blarg”, function(ply, txt)
if(ply == LocalPlayer() and txt:sub(1, 5) == “!join”) then
gui.OpenURL(“http://steamcommunity.com/groups/basedgamings”)
end
end)
[/lua]

NOTE: Admin systems like Evolve will most likely fuck this over.

Oh, I have ULX currently, do I just need to give people permission and stuff? And where should I put this LUA code?

-snip

Afaik this will not really conflict with ULX, but I am not sure.

File file would need to be placed in /autorun/

Also correction:

[lua]
AddCSLuaFile()
if(CLIENT) then
hook.Add(“OnPlayerChat”, “blarg”, function(ply, txt)
if(ply == LocalPlayer() and txt:sub(1, 5) == “!join”) then
gui.OpenURL(“http://steamcommunity.com/groups/basedgamings”)
end
end)
end
[/lua]

Thanks a ton man!