So I am currently trying to create a small script for when a player, in GMOD, enters "!content" for example, they would be presented by a window that would lead them to the Steam Content for that server. For the previous example it worked so I then tried to copy over the template and just change the function name etc. I was not met with the same result as the example shown, yet nothing seem to happen and im not sure why as I have only changed the function name and string. If you can please help me that would be great. Thanks in advance.
Steam Group Chat Script (Works)
function steamgroupCommand( ply, text)
if string.sub( text, 1, 6 ) == "!steam" then
ply:PrintMessage( 3, "It Worked!" )
ply:SendLua([[gui.OpenURL("http://steamcommunity.com/groups/PhantomNetworksCommunity")]])
for k, v in pairs(player.GetAll()) do v:ChatPrint( "Player " .. ply:Nick() .. " has used !steam to view our community Steam Group!" )
end
end
end
hook.Add( "PlayerSay", "Chat", steamgroupCommand )
Discord Chat Script (Does Not Work)
function discordCommand( ply, text)
if string.sub( text, 1, 8 ) == "!discord" then
ply:PrintMessage( 3, "It Worked!" )
ply:SendLua([[gui.OpenURL("https://discord.gg/35rQxcE")]])
for k, v in pairs(player.GetAll()) do v:ChatPrint( "Player " .. ply:Nick() .. " has used !discord to view our official Discord server!" )
end
end
end
hook.Add( "PlayerSay", "Chat", discordCommand )
If you have a look at the documentation of
hook.Add
, you will see details about the needed arguments.The second argument is important for you
So according to this you need to change your second argument of
hook.Add
(which in your case is"chat"
for both of your hooks) to be unique for each hook to not override your other hooks.