ULX

Author Topic: CenKik - Censoring and Kicking  (Read 21964 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: CenKik - Censoring and Kicking
« Reply #15 on: January 15, 2014, 06:57:43 PM »
Take a look at:

http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index53ea.html

it would be like:
Code: [Select]
mytable = string.Explode( " ", message ) --this takes the string message and separates it into a table with space as the separator.
for k, v in pairs(mytable) do
--run your loop to check v against the table of unallowed words
--if the word should be censored then change the table value like this
mytable[v] == "*****"
end
newmessage = string.Implode( " ", mytable ) --this takes the table and places it back into a string with space as the separator.

If someone types: "This forum is great and I love everyone here"
and "great" is an unallowed word it would censor it and output
"This forum is ***** and I love everyone here"

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: CenKik - Censoring and Kicking
« Reply #16 on: January 15, 2014, 06:59:42 PM »
The benefit of doing it this way is that each word is checked as a separate string, allowing you to modify individual words and not having to convert the whole string into lowercase or whatever.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: CenKik - Censoring and Kicking
« Reply #17 on: January 15, 2014, 07:56:46 PM »
UPDATE: All string lowercase fixed. Thanks, MrPresident!

NEW BUG: Letters attached to the censored word will be in lowercase.
Out of the Garry's Mod business.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: CenKik - Censoring and Kicking
« Reply #18 on: January 15, 2014, 08:00:54 PM »
Code: [Select]
mytable = string.Explode( " ", message ) --this takes the string message and separates it into a table with space as the separator.
for k, v in pairs(mytable) do
--run your loop to check v against the table of unallowed words
--if the word should be censored then change the table value like this
mytable[v] == "*****"
end
newmessage = string.Implode( " ", mytable ) --this takes the table and places it back into a string with space as the separator.

Instead of v, I used k because v gives us the value instead of the table's index.
Out of the Garry's Mod business.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: CenKik - Censoring and Kicking
« Reply #19 on: January 15, 2014, 08:44:07 PM »
Yep, sorry. My bad. You would indeed use k.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CenKik - Censoring and Kicking
« Reply #20 on: January 16, 2014, 02:10:41 AM »
Neku, how can I adjust the code so that it returns to admins that the player was censored and what he tried to say? It was in Eccid's code but I am not sure how to adapt it to yours. Not only would it be good to know who is trying to use racist words, but it would be great to use when screening potential moderators.
« Last Edit: January 16, 2014, 02:16:13 AM by Storm »

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: CenKik - Censoring and Kicking
« Reply #21 on: January 16, 2014, 09:05:41 AM »
Here's a hint.

Code: [Select]
ulx.fancyLogAdmin( calling_ply, true, "#A attempted to say: " .. text )
The true in this line of code indicates this will be silent.

Which means that you need to allow moderators to see silent commands.
Out of the Garry's Mod business.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: CenKik - Censoring and Kicking
« Reply #22 on: January 16, 2014, 09:33:42 AM »
Here's a hint.

Code: [Select]
ulx.fancyLogAdmin( calling_ply, true, "#A attempted to say: " .. text )
The true in this line of code indicates this will be silent.

Which means that you need to allow moderators to see silent commands.
Another option is also to do this. You won't have to give the silent command permission.
Code: [Select]
for _, ad in pairs ( player.GetAll() ) do
if ad:IsAdmin() then
ad:ChatPrint( ply:Nick() .. " attempted to say: " .. text )
end
end
If you have groups that don't inherit the default "admin" group, but are still counted as "admins" in your eyes, change this:
Code: [Select]
if ad:IsAdmin() thento this
Code: [Select]
if ad:query( "ulx seeasay" ) thenThe code above will change it so whoever has access to "ulx seeasay" (people that can see messages sent to admins), will get the real chat message sent to their screen.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CenKik - Censoring and Kicking
« Reply #23 on: January 16, 2014, 01:42:37 PM »
I tried putting this code in your addon but, as a complete non-coder, nothing seemed to work. Where should I put what code??

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: CenKik - Censoring and Kicking
« Reply #24 on: January 16, 2014, 11:01:41 PM »
Inside the "string.find":
Code: [Select]
if string.find( string.lower( filter[a] ), v, 1, true ) then
local replace = string.rep( "*", string.len( v ) )
filter[a] = string.gsub( string.lower( filter[a] ), v, replace )
filter = string.Implode( " ", filter )
kikpls = true
for _, ad in pairs ( player.GetAll() ) do
if ad:IsAdmin() then
ad:ChatPrint( ply:Nick() .. " attempted to say: " .. text )
end
end
end
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CenKik - Censoring and Kicking
« Reply #25 on: January 17, 2014, 02:44:06 AM »
I tried this several different ways, including inside the if CenKik.censor. What am I doing wrong?? Sorry but I know nothing about coding!

local function Riplash( ply, text )
   local filter = text
   kikpls = nil
   CenKik.forcetext = nil
   for k,v in pairs( CenKik.words ) do
      if string.find( string.lower( filter ), v, 1, true ) then
         if CenKik.censor then
            filter = string.Explode( " ", filter )
            for a,b in pairs( filter ) do
               print( filter[k] )
               if string.find( string.lower( filter[a] ), v, 1, true ) then
                  local replace = string.rep( "*", string.len( v ) )
                  filter[a] = string.gsub( string.lower( filter[a] ), v, replace )
                  filter = string.Implode( " ", filter )
                  kikpls = true
               end
            end
            
         end   
         
         if string.find( string.lower( filter[a] ), v, 1, true ) then
                    local replace = string.rep( "*", string.len( v ) )
                    filter[a] = string.gsub( string.lower( filter[a] ), v, replace )
                    filter = string.Implode( " ", filter )
                    kikpls = true
                    for _, ad in pairs ( player.GetAll() ) do
                           if ad:IsAdmin() then
                                    ad:ChatPrint( ply:Nick() .. " attempted to say: " .. text )
                            end
                    end
            end         
      end
   end
« Last Edit: January 17, 2014, 02:48:51 AM by Storm »

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: CenKik - Censoring and Kicking
« Reply #26 on: January 17, 2014, 04:20:31 AM »
I think you are over complicating things a little why not just push text to asay? ulx.asay( nil, ply:Nick() .. " attempted to say: " .. text ) or ulx.asay( ply, text )
« Last Edit: January 17, 2014, 04:24:47 AM by LuaTenshi »
I cry every time I see that I am not a respected member of this community.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: CenKik - Censoring and Kicking
« Reply #27 on: January 17, 2014, 05:27:51 AM »
I think you are over complicating things a little why not just push text to asay? ulx.asay( nil, ply:Nick() .. " attempted to say: " .. text ) or ulx.asay( ply, text )
I haven't tried ulx.asay in a while, but last time I did, it didn't properly work for me. So I used the query code instead.

I tried this several different ways, including inside the if CenKik.censor. What am I doing wrong?? Sorry but I know nothing about coding!
Code: [Select]
local function Riplash( ply, text )
local filter = text
kikpls = nil
CenKik.forcetext = nil
for k,v in pairs( CenKik.words ) do
if string.find( string.lower( filter ), v, 1, true ) then
if CenKik.censor then
filter = string.Explode( " ", filter )
for a,b in pairs( filter ) do
print( filter[k] )
if string.find( string.lower( filter[a] ), v, 1, true ) then
local replace = string.rep( "*", string.len( v ) )
filter[a] = string.gsub( string.lower( filter[a] ), v, replace )
filter = string.Implode( " ", filter )
kikpls = true
end
end

end

if string.find( string.lower( filter[a] ), v, 1, true ) then
                 local replace = string.rep( "*", string.len( v ) )
                 filter[a] = string.gsub( string.lower( filter[a] ), v, replace )
                 filter = string.Implode( " ", filter )
                 kikpls = true
                 for _, ad in pairs ( player.GetAll() ) do
                  if ad:IsAdmin() then
                           ad:ChatPrint( ply:Nick() .. " attempted to say: " .. text )
                      end
                 end
            end
end
end
Hmm, I don't know, really. I don't have much time to test whatever code I give out. You could try what LuaTenshi said with ulx.asay, just replace my code with:
Code: [Select]
ulx.asay( "CenKik", ply:Nick() .. " attempted to say: " .. text )That should work the same way, but the message will be sent through the "asay".
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: CenKik - Censoring and Kicking
« Reply #28 on: January 17, 2014, 08:03:23 AM »
Code: [Select]
ulx.asay( nil, ply:Nick() .. " attempted to say: " .. text )
« Last Edit: January 17, 2014, 03:03:41 PM by Neku »
Out of the Garry's Mod business.

Offline Storm

  • Full Member
  • ***
  • Posts: 220
  • Karma: 4
Re: CenKik - Censoring and Kicking
« Reply #29 on: January 17, 2014, 08:27:11 AM »
Thanks Neku! Exactly where do I put that code in your script? I would think any owner would want this in the script, you might consider adding it?