Skip to content

Instantly share code, notes, and snippets.

@ApertureDevelopment
Last active April 23, 2020 21:26
Show Gist options
  • Save ApertureDevelopment/7fcbcd7c0b179b99a1bfd087e22ae4d3 to your computer and use it in GitHub Desktop.
Save ApertureDevelopment/7fcbcd7c0b179b99a1bfd087e22ae4d3 to your computer and use it in GitHub Desktop.
hook.Add("PlayerSay", "Dereinzigartige", function( ply, text )
if text == "Hallo" then
print("Hello")
end
end)
--[[
The hook add function adds a custom function to the said hook. That way our function runs everytime the hook is called.
The hook add function has 3 parameters:
1: The hook name ( for example PlayerSay )
2: Your custom event name, which allows you to remove your hook later if needed
3: the function to run when the hook gets executed
]]
hook.Add("PlayerSay", "MyAwesomeHook", function( ply, text )
-- As you can see here the PlayerSay hook passes two parameters to your function:
-- ply is the player object ( the player that said the text )
-- text is the said text
if text == "MyCommand" then
-- do stuff
end
-- With the return you decide what gets written into the chat, if you set it to "" the command won't be printed into everyones chat
return ""
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment