Cant run multiple commands . Help

Hi guys , just to let you know im a complete noob when it comes to lua so go easy.

Ive added two almost identical commands to the server. The first one is :

[SUB]function JoinCommand( pl, text, teamonly )
if (text == “!join”) then
pl:SendLua([[gui.OpenURL(“www.steamgroup.com”)]]) –
for k, v in pairs(player.GetAll()) do v:ChatPrint( “Player " … pl:Nick() … " has joined our Steam group via !join.” )

	end
end

end
hook.Add( “PlayerSay”, “Chat”, JoinCommand )[/SUB]

And the other is :

[SUB]function donateCommand( pl, text, teamonly )
if (text == “!donate”) then
pl:SendLua([[gui.OpenURL(“www.donate.com”)]])
for k, v in pairs(player.GetAll()) do v:ChatPrint( “Player " … pl:Nick() … " has donated to the server via !donate” )

	end
end

end
hook.Add( “PlayerSay”, “Chat”, donateCommand )
[/SUB]

Now the problem is that they wont both work together , they are in seperate files but only one command seems to work…
Any help would be great thanks. Also both commands work fine individually , just not when both are in use at the same time

Hook.Add requires that the second parameter be unique, currently your second hook is overriding the first because they share the same unique identifier. Change the second parameter to something else for one of the hooks (or both), for example:



-- first hook
hook.Add("PlayerSay", "Chat1", JoinCommand)

-- second hook
hook.Add("PlayerSay", "Chat2", donateCommand)

You added two hooks which use the same unique name. You can change one of the “Chat”'s to “Chat2” or use one function. Should probably also return “” (overrides the message to be blank) so their message doesn’t appear in chat.

[lua]hook.Add(“PlayerSay”, “Chat”, function(pl, text, teamonly)
if text == “!join” then
pl:SendLua([[gui.OpenURL(“www.steamgroup.com”)]])
PrintMessage(HUD_PRINTTALK, “Player “…pl:Nick()…” has joined our Steam group via !join.”)

	return ""
elseif text == "!donate" then 
	pl:SendLua([[gui.OpenURL("www.donate.com")]])
	PrintMessage(HUD_PRINTTALK, "Player "..pl:Nick().." has donated to the server via !donate")

	return ""
end

end)
[/lua]

Thank you both for the reply helped me a lot