public Plugin myinfo = { name = "Message Filter", author = "Sgt. Gremulock", description = "Allows server operators to modify messages that are said in chat to include different text (configured via a config file).", version = PLUGIN_VERSION, url = "grem-co.com" };
public void OnPluginStart() { CreateConVar("sm_messagefilter_version", PLUGIN_VERSION, "Plugin's version.", FCVAR_NOTIFY); }
void BrowseKeyValues() { KeyValues kv = new KeyValues("Message Filter"); if (!FileExists(CONFIG)) { kv.JumpToKey("Example", true); kv.SetString("replacement", "guy"); kv.Rewind(); kv.ExportToFile(CONFIG); LogMessage("Generated config file: %s\nEdit the file to your liking and then reload the plugin!", CONFIG); kv.Close(); return; }
if (!kv.ImportFromFile(CONFIG)) SetFailState("Cannot load the config file (%s)!", CONFIG); if (!kv.GotoFirstSubKey()) SetFailState("Failure navigating to the first key in the config file (%s)!", CONFIG);
public Plugin myinfo = { name = "Message Filter", author = "Sgt. Gremulock", description = "Allows server operators to modify messages that are said in chat to include different text (configured via a config file).", version = PLUGIN_VERSION, url = "sourcemod.net" };
public void OnPluginStart() { CreateConVar("sm_messagefilter_version", PLUGIN_VERSION, "Plugin's version.", FCVAR_NOTIFY); }
void BrowseKeyValues() { KeyValues kv = new KeyValues("Message Filter"); if (!FileExists(CONFIG)) { kv.JumpToKey("Example", true); kv.SetString("replacement", "guy"); kv.Rewind(); kv.ExportToFile(CONFIG); LogMessage("Generated config file: %s\nEdit the file to your liking and then reload the plugin!", CONFIG); kv.Close(); return; }
if (!kv.ImportFromFile(CONFIG)) SetFailState("Cannot load the config file (%s)!", CONFIG); if (!kv.GotoFirstSubKey()) SetFailState("Failure navigating to the first key in the config file (%s)!", CONFIG);
if (hHashMap != null && hHashMap.Size > 0) // Idk if this part is necessary but I did it anyway. { hHashMap.Clear(); hHashMap = null; }
hHashMap = new StringMap(); char buffer[2][256]; do { kv.GetSectionName(buffer[0], 256); kv.GetString("replacement", buffer[1], 256); hHashMap.SetString(buffer[0], buffer[1]); LogMessage("Successfully added replacement for message: '%s' (Replacement: '%s').", buffer[0], buffer[1]); } while kv.GotoNextKey(); kv.Close(); }
If you still don't understand what this plugin is supposed to do, it basically replaces words or phrases in certain chat messages. However, this is where the trouble comes in...
StringMap.GetString is case sensitive. Does anybody have a work around for making it case insensitive?
Is one way to do it to just simply add every possible (capital letter and non-capital letter) combination for a phrase into the StringMap and have it set as multiple keys for the replacement message? I feel like that would definitely be a poor decision performance wise.
Or, would I have to (not preferred) format the message buffer (in the config) to be all lowercase?
Thanks,
Grant
Last edited by ThatKidWhoGames; 05-19-2018 at 10:17.