I can't tell. I just took your plugin and change it a bit. This works:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>
#define PLUGIN "Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
#define FILENAME "badwords.ini" // Define the words list TXT file name.
#define MAX_WORDS 32 // Define the max bad words wich can be in the file.
#define LEN_WORDS 32 // Define the max length of words
#define LEN_CHAT 127 // Define the max length of retrieved chat message
#define CVAR_CENSOR 1 // Define the censor cvar.
#define CVAR_KICK 2 // Define the kick cvar.
new g_arrszWords[MAX_WORDS][LEN_WORDS+1]
new g_iWordCount
new g_pcvFD
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pcvFD = register_cvar("fd_cvar", "1")
register_clcmd("say", "FlameHandler")
register_clcmd("say_team", "FlameHandler")
g_iWordCount = LoadWords()
}
LoadWords()
{
new wordsfile[64], count = 0
get_configsdir(wordsfile, sizeof(wordsfile) - 1)
format(wordsfile, sizeof(wordsfile) - 1, "%s/%s", wordsfile, FILENAME)
if( !file_exists(wordsfile) ) return 0
new f = fopen(wordsfile, "rt")
new data[128]
while( !feof(f) && count < MAX_WORDS)
{
fgets(f, data, sizeof(data) - 1)
// Trim must be before !data[0] check :)
trim(data) // Trim newline and carriage return
if( !data[0] || data[0] == ';'
|| data[0] == '/' && data[1] == '/' ) continue; // Skip line if comment or blank
copy(g_arrszWords[count], LEN_WORDS, data) // Put word into global array
// console_print(0,"Word(%d): %s", count, g_arrszWords[count]) // debug
count++
}
fclose(f)
return count
}
public FlameHandler(id)
{
static cvar
cvar = get_pcvar_num(g_pcvFD)
// If the cvar forced as off, not doing nothing.
if (!cvar || !g_iWordCount)
return PLUGIN_CONTINUE
// Variable definize.
new szText[LEN_CHAT+1]
// Read the user message.
read_args(szText, LEN_CHAT)
// If there is a flame in the text.
if (isFound(szText))
{
// If the cvar is "1", it censor the message.
switch(cvar)
{
case CVAR_CENSOR: return PLUGIN_HANDLED
case CVAR_KICK:
{
new nUserID = get_user_userid(id)
server_cmd("kick #%d You used a bad word! don't repeat you'r self!", nUserID)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_CONTINUE
}
stock bool:isFound(const szCheckText[])
{
// Code section.
// Looping the badwords array.
new Regex:rgxMatch
new nNumber, nError[128]
for (new j = 0; j < g_iWordCount; j++)
{
rgxMatch = regex_match(szCheckText, g_arrszWords[j], nNumber, nError, 127, "i")
// If is match, return true.
if (rgxMatch >= REGEX_OK)
{
//server_print("regexok") // debug line
// Free the regex memmory.
regex_free(rgxMatch)
return true
}
}
return false
}
I don't understand why you are trying to use an offsetsfor max words.
__________________