Raised This Month: $51 Target: $400
 12% 

No Censure 1.0


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-10-2016 , 17:02   No Censure 1.0
Reply With Quote #1

No Censure (+ Words Exploit API)

This plugin blocks chat message which contains bad words loaded from a file bad_words.ini. Nobody will see that message except the sender. So bassicaly if you talk bad words you will think that someone read them but indeed they didn't see them.
I named it "No Censure", because it doesn't censure message or gag player, just won't show it to other ones.

Defines And Constants:
PHP Code:
BAD_WORDS_DIR "addons/amxmodx/configs" //Set your custom directory of file bad_words.ini by editing this define. 
PHP Code:
new const g_warn_msg[] = "[AMXX] Warning! Bad Word Detected in the Messsage." //If cvar below is set to "2" then this warning will be shown to the player before blocking message. 
Bad Words File Overview:
If file bad_words.ini will be found/not found then you will recieve a message in server console and
also amxx log file (I think it's location is in amxmodx/logs/L[year][month][date].txt)
Every line from file must have only one word. If you want to deactivate that word, no need to remove it,
just add ; symbol in front of it.
For example:
word
;word1
word2

"word1" won't be checked because it has ; symbol in front.

Aslo I used ; symbol to separate words from different languages like ;[EN] or ;[RO]
Also don't be afraid to hit space and add 1 empty line to separate new language words list.


Cvars:
  • nc_hide_msg 0 | 1 | 2
  • 0 - as default it will show message with bad words only to player who sent it.
    I recommend to let it be default ( 0 ), because if player saw that message has been blocked then he would try to trick the plugin as well as he could. By default player will think the his message has been seen by all players, which is not true.
  • 1 - Will block the message to all players, even sender.
  • 2 - Same as 1, but also prints a warning message to user (see instruction above how to change warning message).

Words Exploit API:
This is a stock placed in a include (.inc) file named "words_exploit.inc".
It bassicaly clears a string from non-letters symbols and repeated symbols.

This is usefull to detect if a string contains a specified word ( like in my plugin's case).

Structure:
PHP Code:
stock remove_words_exploit str )
//Returns modified string length 
How To Use It :
1. Download "words_exploit.inc" (down below you will see it) and place to "cstrike/addons/amxmodx/scripting/include" folder.
2. At the top of your plugin add :
PHP Code:
#include <words_exploit> 
Now how to properly use it:
For example you want to block the message when player say's "votemap".
You get the message for example to myString
then do :
PHP Code:
 remove_words_exploit(myString
Then check and do your action:
PHP Code:
if(equal(myString"votemap")) return PLUGIN_HANDLED
And as i said above , if your word contains double letters then write it with one letter.
For example if you want to check "letter" instead, then use "leter" :

PHP Code:
if(equal(myString"leter")) return PLUGIN_HANDLED
After update to version 1.1 , this stock returns modified strings length.
Example of using:

PHP Code:
new iLen strlen(myString)
if( 
remove_words_exploit(myString) == iLen)
return 
PLUGIN_CONTINUE;
//If length is the same as before calling the stock then return. 

Change Log:
  • 1.1 - Second Release (12/06/2016)
  • Changed file_read with fopen
  • Added auto remove multiple consecutive letters before saving to array. Now you can add words with double letters in bad_words.ini.
  • . Improved performance while checking string and replacing characters, now is used only one arrray in message hook.
  • Added cvar "nc_hide_msg", "2" . It's used to warn user before blocking his message.
  • Now "remove_words_exploit" returns modified string length.

    1.0 - Initial Release (10/06/2016)

Credits:
  • KliPPy - Special thanks for helping with blocking message and also with checking alphabet letters stock.
  • HamletEagle - Helped me and explained some errors in my stock.
  • kaboomkazoom - Used his stock which detects some symbols as letters.
Attached Files
File Type: ini bad_words.ini (339 Bytes, 202 views)
File Type: sma Get Plugin or Get Source (no_censure.sma - 747 views - 6.7 KB)
File Type: inc words_exploit.inc (2.9 KB, 212 views)

Last edited by siriusmd99; 06-12-2016 at 15:06.
siriusmd99 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-10-2016 , 17:10   Re: No Censure 1.0
Reply With Quote #2

Add a warning message for the player.

PHP Code:
  if ( containiszCheckedszTmp) != -
   return 
PLUGIN_HANDLED;                   //Bad Word detected, Blocking it. 
->

PHP Code:
  if ( containiszCheckedszTmp) != -
  {
      
client_print(id,print_chat,"MESSAGE")
      return 
PLUGIN_HANDLED;                   //Bad Word detected, Blocking it.
  


And can you make for me,
If i said F*CK, or SH*T, can you make a code for me learn that? I really liked.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 06-10-2016 at 17:12.
EFFx is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-10-2016 , 17:38   Re: No Censure 1.0
Reply With Quote #3

Quote:
Originally Posted by EFFx View Post
Add a warning message for the player.

PHP Code:
  if ( containiszCheckedszTmp) != -
   return 
PLUGIN_HANDLED;                   //Bad Word detected, Blocking it. 
->

PHP Code:
  if ( containiszCheckedszTmp) != -
  {
      
client_print(id,print_chat,"MESSAGE")
      return 
PLUGIN_HANDLED;                   //Bad Word detected, Blocking it.
  


And can you make for me,
If i said F*CK, or SH*T, can you make a code for me learn that? I really liked.
Added warning message, only when cvar is set to "2".

And about f*ck.My stock will remove * as it is not letter , so you can add just fck or fuk, or fuc in bad_words.ini and it will block it.. I know that it's good to make it smart but more smarter I do this stock , more problems occur.
For example if there is a word FCK which means a football club name or something and you add it in and word list to detect f*uck then it will block his message...

I think I will also add IP,DNS,sites spam...Lol. I forgot....

Last edited by siriusmd99; 06-10-2016 at 17:43.
siriusmd99 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-10-2016 , 18:05   Re: No Censure 1.0
Reply With Quote #4

And what about:

PHP Code:
new Warned[33
PHP Code:
      if(iCvar == 2)
       
client_print(idprint_chat"%s"g_warn_msg); //If cvar is set to 2 then show message, else only block message. 
->

PHP Code:

 
if(iCvar == 2)
 {
  
Warned[id]++
  
  if(
Warned[id] != get_pcvar_num(YOUR_MAX_PCVAR))
  {
   
client_print(idprint_chat"%s"g_warn_msg); //If cvar is set to 2 then show message, else only block message.
  
}
  else
  {
   switch(
get_pcvar_num(YOUR_PCVAR_TYPE))
   {
    case 
0:
    {
     
server_cmd("kick #%d",get_user_userid(id))
     
client_print(idprint_chat"%s"g_kick_msg);
    }
    case 
1:
    {
     
server_cmd("amx_ban ^"%s^" ^"%d^" ^"%s^"",username,time,reason)
     
client_print(idprint_chat"%s"g_ban_msg);
    }
   }
   
Warned[id] = 0
  
}
 } 
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 06-10-2016 at 18:16.
EFFx is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-10-2016 , 18:56   Re: No Censure 1.0
Reply With Quote #5

Plugin looks like it has been made 10 years ago. Since you don't have much knowledge, you should have posted first in scripting or suggestions section to get feedbacks and learning from that. Your code is kind of horrible.

Just a few of them:
- Don't hardcode configs path, AMXX has some config for that (core.ini)
- Don't hardcode buffer length, use charsmax() (maintainability, less prone to error)
- Don't hardcode the "additional characters".
- Don't use read_file to read a file with several entries, use the new file API (fopen, etc.) (read_file open/closes/allocates each time)
- Use log_amx instead of server_print + log_message
- Trying to get max word length for use with ArrayCreate is really pointless. Just use the t_word buffer length directly.
- Most of the string natives return the number of cells written, no need to call each time strlen.
- Use a swtich instead of multiple single if.
- g_size value is potentially wrong, it should be the value of ArraySize, not i, which counts the line.
- Looks like nc_hide_msg 1 does nothing
- About your "rules", 1) just lowercase when reading the config file 2) You should deal it in your code
- ...

Poorly coded, kind of redundant. Unapproved for now.

Really, take your time to learn, you are supposed to know how to code when releasing a plugin. No need to rush.
Just because it's unapproved doesn't you can't improve your plugin (if you think you plugin has been fixed totally, you can always ask to be reviewed again).
__________________

Last edited by Arkshine; 06-10-2016 at 19:11.
Arkshine is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-11-2016 , 04:00   Re: No Censure 1.0
Reply With Quote #6

And why my plugin was unaproved while swear replacement was approved?
Because I used the basics from it to not do myself.
And guess what?
No matter which function I use fopen or read file , because it's called once in plugins init, so don't push on me.
And why should I use charsmax function if I know it's value and use directly?

And about nc_hide_msg "1" you are wrong, it hides message but doesn't show warning message. For this ia used "2".

With lowercase you are right, containi is used more frequently, so i better lowercase the
words when reading, then use contain down.

Arkshine, i can use "switch" and what you said above, but I tell You that I used "swear replacement" which was approved and I thought its well coded thats why I didn't change it.

Last edited by siriusmd99; 06-11-2016 at 04:05.
siriusmd99 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-11-2016 , 04:49   Re: No Censure 1.0
Reply With Quote #7

Quote:
Originally Posted by siriusmd99 View Post
No matter which function I use fopen or read file , because it's called once in plugins init, so don't push on me.
If we had that mindset while writing all our plugins, we would unnecessarily increase map load time. Why not just improve it if it can be improved?

Quote:
Originally Posted by siriusmd99 View Post
And why should I use charsmax function if I know it's value and use directly?
He already told you - maintainability and it's less prone to human errors. If you ever change the buffer size, you won't have to do the same in several other places in code.
klippy is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 06-11-2016 , 05:03   Re: No Censure 1.0
Reply With Quote #8

I can change all this things , no problem.

But one question , If swear filter was bad coded then why it was approved , because I got confused didn't know its bad coded.
siriusmd99 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-11-2016 , 05:24   Re: No Censure 1.0
Reply With Quote #9

If you are not willing to open your mind, you are going to hit a wall.

I've no idea what is "swear replacement". Not sure why you're talking about this plugin, which has not been approved by me. If you do a better a plugin in order to replace an existing & abandoned plugin, then you just need to say it and the old plugin will be unapproved.

Quote:
No matter which function I use fopen or read file , because it's called once in plugins init,
It doesn't matter if executed one time here. You're using a deprecated method to read a file with several entries. This is bad practice, for you and the others who will look at your code. Using the new file natives is easy, there is no valid reason to not use them.

Quote:
why should I use charsmax function if I know it's value and use directly
I already told you. Maintainability, and less prone to error, since you just need to provide the buffer length on the variable and not manually doing length - 1 (assuming you don't forget to di -1 as well) at each occurrence in your code. If you or someone need to change the length for some reason, you can do it just one time where you variable is located.

Quote:
And about nc_hide_msg "1" you are wrong
You're right. Because of your code badly indented, I thought you were returning PLUGIN_HANDLED only when iCvar == 2. Another thing to do: don't mix spaces and tab for the indentation.

Quote:
but I tell You that I used "swear replacement" which was approved
That proves you don't understand what you're doing yet if you need to rely on what does a plugin, especially for basic knowledge. As I said, don't release if you are a beginner, it's not helpful for everyone. Now it's done, I hope you will take this opportunity to learn more and improving your plugin.
__________________
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-11-2016 , 07:58   Re: No Censure 1.0
Reply With Quote #10

You should have checked the date of the plugin "02-16-05 , 01:29 PM Simple Swear Replacement 1.5". Quality standards and AMXX changed a lot in 11 years.
Don't just take code from a plugin and blindly use it because it's approved. He have a lot of old and badly coded plugins and they are approved.

Just wanted to point out this two things.
__________________

Last edited by HamletEagle; 06-11-2016 at 08:00.
HamletEagle is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode