LaserHydra submitted a new resource:
Chat Guard - Block specific words and letters from the chat
Read more about this resource...
Chat Guard [Replaced]
Discussion in 'Plugin Support' started by LaserHydra, Jun 24, 2015.
-
not working
Code:{ "ForbiddenWords": [ "fuck", "bitch", "fag", "faggot", "fagget", "fucker", "cunt", "nigger", "nig", "nigga", "niga", "queer", "homo", "fucking" ] }
-
Lol, when you restart the plugin config flies. Doesn't work anyway...
-
-
-
-
The problem lies here:
Code:void Loaded() { LoadDefaultConfig(); } protected override void LoadDefaultConfig() { PrintWarning("Creating a new configuration file."); Config.Clear(); List<string> forbidden = new List<string>() { "fuck", "bitch", "dick" }; Config["ForbiddenWords"] = forbidden; SaveConfig(); }
This is specified as the list above and saved to the Config.
At no point do you actually load the config that the server owner has set. Instead it writes over it. -
-
A couple of minor bugs:
- Using /whisper /pm /o (etc), this filters the chat, but then broadcasts the message to everyone. (More problematic for whispering / pm'ing people)
- Occasionally appears to change the chat colour permanently from white to green. (Not sure when this happened, exactly)
- Filters out people's names and regular words such as:
Ruper Von Dicksby.
I'd like a cocktail please.
My name is Dick Whittington
Sir Bashitall
Lord Richard Riddick -
-
Cool, cool!
-
[DOUBLEPOST=1436272511][/DOUBLEPOST]
Code:void Loaded() { LoadDefaultConfig(); } protected override void LoadDefaultConfig() { PrintWarning("Creating a new configuration file."); Config.Clear(); List<string> forbidden = new List<string>() { "fuck", "bitch" }; if (Config["ForbiddenWords"] != forbidden) { Config["ForbiddenWords"] = Config["ForbiddenWords"]; } else { Config["ForbiddenWords"] = forbidden; } SaveConfig(); }
Last edited by a moderator: Jul 7, 2015 -
Heh - yeah, that's only a small thing really and may be too tricky to fix at this stage.
But the publicly broadcasted "private messages" is more of a pressing issue. -
-
Possibly something 'like' this. Not got access to my codebase to work out the fiddly bits, but basically:
This may need some tweaking, but this is the general idea (bit rushed as about to run to a meeting at work!)
Code:void Loaded() { var oldConfigList = GetTheNewestConfigFromTheConfigFile( ); if(forbidden = null) { LoadDefaultConfig(); return; } if(forbidden != oldConfigList) { forbidden = oldConfigList; SaveConfig(); } } protected override void LoadDefaultConfig() { PrintWarning("Creating a new configuration file."); Config.Clear(); List<string> forbidden = new List<string>() { "fuck", "bitch", "dick" }; Config["ForbiddenWords"] = forbidden; SaveConfig(); }List<string> GetTheNewestConfigFromTheConfigFile( ) { List<string> ConfigList; // Get the config code here return ConfigList; }
-
-
if(forbidden == null)
-
if(Config["ForbiddenWords"]!= forbidden)
???
but why, if forbidden? frobidden is preset and not changed -
Sorry, it looks like we were working at cross-purposes there.
I didn't see the code example you originally posted.
That looks like it might be fine.
[DOUBLEPOST=1436277896][/DOUBLEPOST]Small adjustment:
Code:void Loaded() { LoadDefaultConfig(); } protectedoverridevoid LoadDefaultConfig() { PrintWarning("Creating a new configuration file."); // THIS WILL CLEAR THE CONFIG (So you won't be able to check it - move it into the IF statement?) ------- > Config.Clear(); // MAKE THIS A GLOBAL VARIABLE ---- > List<string> forbidden =new List<string>(){"fuck", "bitch"}; if(Config["ForbiddenWords"] == null) { // Create a new config here..... SaveConfig(); return; } if(Config["ForbiddenWords"]!= forbidden) { Config.Clear(); forbidden= Config["ForbiddenWords"]; SaveConfig(); } else { Config["ForbiddenWords"]= forbidden; } SaveConfig(); }
-