Author Topic: Kick when X is said in chat  (Read 4921 times)

0 Members and 1 Guest are viewing this topic.

Offline frustratedgamers

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
Kick when X is said in chat
« on: January 08, 2014, 04:30:00 PM »
Was wondering if there is a way to make an addon that would autokick a player if a certain word or predefined phrase was said?

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Kick when X is said in chat
« Reply #1 on: January 08, 2014, 05:06:59 PM »
There is a way, and it's quite simple.

I'll make one for you in a bit.
Out of the Garry's Mod business.

Offline frustratedgamers

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
Re: Kick when X is said in chat
« Reply #2 on: January 08, 2014, 06:23:57 PM »
There is a way, and it's quite simple.

I'll make one for you in a bit.

awesome! thank you :D

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Kick when X is said in chat
« Reply #3 on: January 08, 2014, 06:37:43 PM »
Also, what game mode is this for?
Out of the Garry's Mod business.

Offline frustratedgamers

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
Re: Kick when X is said in chat
« Reply #4 on: January 08, 2014, 10:24:58 PM »
Also, what game mode is this for?
Would be for prop hunt

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Kick when X is said in chat
« Reply #5 on: January 09, 2014, 12:18:51 AM »
I'm awake, so here's what I made for you. If you only want kicking to happen, either leave the Banwords table empty, or delete between where it says ban begin and ban end.
Put this in lua\autorun\server\

Code: [Select]
KickWords = KickWords or {}
BanWords = BanWords or {}

KickWords = { --Add what words to be kickable.
"poohead",    --Any added word should be in this format,
"muggle"      --last word does NOT have a comma after it.
}
BanWords = {  --Same rules as above, only for banning
"poopypants",
"nerfherder"
}


hook.Add( "PlayerSay", "Kick For Words", function(ply, text)
--Kick Begin--
for a,b in pairs(KickWords) do
if string.find(string.lower(text), b, 1, true) then --Is a word being used?
RunConsoleCommand("ulx", "kick", ply:Nick(), "Using a banned word.") --If yes, kick them
ulx.fancyLogAdmin( ply, true, "#A was kicked for saying the following: #s", text) --Tell admins they were kicked and what they said.
return "" --Return nothing so everyone can't read what was said.
end
end
--Kick End--

--Ban Begin--
for a,b in pairs(BanWords) do --Same as above, except for banning.
if string.find(string.lower(text), b, 1, true) then
RunConsoleCommand("ulx", "ban",  ply:Nick(), "0", "Using a banned word.") --Ban time is set to 0 for perm, feel free to edit.
ulx.fancyLogAdmin( ply, true, "#A was banned for saying the following: #s", text)
return ""
end
end
--Ban End--
end )

Make sure your admins know what words are in the list and adhere to the rules. It looks bad if your admins are getting kicked for things like this.
« Last Edit: January 10, 2014, 12:11:46 PM by Eccid »

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Kick when X is said in chat
« Reply #6 on: January 09, 2014, 12:26:38 AM »
I'm awake, so here's what I made for you. If you only want kicking to happen, either leave the Banwords table empty, or delete between where it says ban begin and ban end.
Put this in lua\autorun\server\

Code: [Select]
KickWords = KickWords or {}
BanWords = BanWords or {}

KickWords = { --Add what words to be kickable.
"poohead",    --Any added word should be in this format,
"muggle"      --last word does NOT have a comma after it.
}
BanWords = {  --Same rules as above, only for banning
"poopypants",
"nerfherder"
}


hook.Add( "PlayerSay", "Kick For Words", function(ply, text)
--Kick Begin--
for a,b in pairs(KickWords) do
if string.find(text, b, 1, true) then --Is a word being used?
RunConsoleCommand("ulx", "kick", ply:Nick(), "Using a banned word.") --If yes, kick them
ulx.fancyLogAdmin( ply, true, "#A was kicked for saying the following: #s", text) --Tell admins they were kicked and what they said.
return "" --Return nothing so everyone can't read what was said.
end
end
--Kick End--

--Ban Begin--
for a,b in pairs(BanWords) do --Same as above, except for banning.
if string.find(text, b, 1, true) then
RunConsoleCommand("ulx", "ban",  ply:Nick(), "0", "Using a banned word.") --Ban time is set to 0 for perm, feel free to edit.
ulx.fancyLogAdmin( ply, true, "#A was banned for saying the following: #s", text)
return ""
end
end
--Ban End--
end )

Make sure your admins know what words are in the list and adhere to the rules. It looks bad if your admins are getting kicked for things like this.

Meh. I was gonna do it, but I ran into issues. (See my Lua n00b thread.)

Thanks for taking my place.
Out of the Garry's Mod business.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Kick when X is said in chat
« Reply #7 on: January 09, 2014, 12:36:00 AM »
Meh. I was gonna do it, but I ran into issues. (See my Lua n00b thread.)

Thanks for taking my place.

:P No problem. I was already awake and had something similar mostly written. Just took a few minutes to polish it.

Offline frustratedgamers

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
Re: Kick when X is said in chat
« Reply #8 on: January 09, 2014, 02:10:26 AM »
sweet! thank you very much :D

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: Kick when X is said in chat
« Reply #9 on: January 09, 2014, 03:34:43 AM »
Can you tell me if this would work in ttt?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Kick when X is said in chat
« Reply #10 on: January 09, 2014, 03:38:31 AM »
Can you tell me if this would work in ttt?
It should work as normal, in my eyes.

Isn't it better to use ULib.kick & ULib.ban? Instead of running it through the console, I mean.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Kick when X is said in chat
« Reply #11 on: January 09, 2014, 10:30:08 AM »
Can you tell me if this would work in ttt?
It will work regardless of game mode.


It should work as normal, in my eyes.

Isn't it better to use ULib.kick & ULib.ban? Instead of running it through the console, I mean.

Everytime I use Ulib commands, they fail to work for me, so it's just easier to use RunConsoleCommand.
« Last Edit: January 09, 2014, 10:33:07 AM by Eccid »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Kick when X is said in chat
« Reply #12 on: January 09, 2014, 07:29:21 PM »
Everytime I use Ulib commands, they fail to work for me, so it's just easier to use RunConsoleCommand.

We'd love to help you on specific issues... :)
Experiencing God's grace one day at a time.

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Kick when X is said in chat
« Reply #13 on: January 09, 2014, 08:34:29 PM »
We'd love to help you on specific issues... :)

Next time I write something that kicks or bans I'll us ulib commands, and if it messes up post here. It' just easier for me to run console commands :P