AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help Changing this part of swear filter plugin (https://forums.alliedmods.net/showthread.php?t=25657)

Flashhh! 03-18-2006 01:01

Help Changing this part of swear filter plugin
 
Hello I need to change this part of this swear filter. I only need to reaplace the '*' that appear when the bad word was type by only a "good word" instead the *.

Part of original code is:


Code:

public swearcheck(id)
{
        new szSaid[192]
        read_args(szSaid,191)
        new bool:found = false
        new pos, i = 0
        while ( i < g_swearsNum )
        {
        if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
                new len = g_swearsNames[i][0]
                while(len--)
                szSaid[pos++] = '*' // I think this part must be change!
                found = true
                continue
        }
        ++i
        }
        if ( found ){
                new cmd[32]
                read_argv(0,cmd,31)         
                engclient_cmd(id,cmd,szSaid)   
        }
        return PLUGIN_CONTINUE
}

Modify code (dont work):

Code:

{
        new szSaid[192]
        read_args(szSaid,191)
        new bool:found = false
        new pos, i = 0
        while ( i < g_swearsNum )
        {
        if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
                new len = g_swearsNames[i][0]
                while(len--)
                szSaid[pos++] = client_print ("good word")
                found = true
                continue
        }
        ++i
        }
        if ( found ){
                new cmd[32]
                read_argv(0,cmd,31)         
                engclient_cmd(id,cmd,szSaid)   
        }
        return PLUGIN_CONTINUE
}

Which is the comand I must put in this line if I want to replace the * by only one word:
Code:

szSaid[pos++] = '*'

Flashhh! 03-18-2006 03:25

Please its only one line that should be change. I want to replace the "*" by a fixed word that should be put in that line. I cant make it work.. I really need help.

[ --<-@ ] Black Rose 03-18-2006 07:32

client print have more arguments.

and i don't think you can add a whole word in one cell

Code:
#define word "gaben" public swearcheck(id) {    new szSaid[192]    read_args(szSaid,191)    new bool:found = false    new pos, i = 0    while ( i < g_swearsNum )    {    if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ) {       replace(szSaid, 191, g_swearsNames[i][1], word)       found = true       continue    }    ++i    }    if ( found ){       new cmd[32]       read_argv(0,cmd,31)       engclient_cmd(id,cmd,szSaid)    }    return PLUGIN_CONTINUE }
dunno if it would work, try it

Flashhh! 03-18-2006 12:29

Thanks Black Rose, I include your modifications but when I compile I read warning 204: symbol is assigned a value that is never used: "pos" :cry:
Any ideas why this error?

capndurk 03-18-2006 12:41

Because there's a variable called pos that is created but never used. If you want, Flash, you can just delete it and you won't have the warning, but it will only take out a miniscule amount of size in the file.

Replace:

Code:
new pos, i = 0

With:

Code:
new i = 0

Flashhh! 03-18-2006 13:07

Quote:

Originally Posted by capndurk
Because there's a variable called pos that is created but never used. If you want, Flash, you can just delete it and you won't have the warning, but it will only take out a miniscule amount of size in the file.

Replace:

Code:
new pos, i = 0

With:

Code:
new i = 0

Sorry but It didnt compile. I didnt know that was too dificult to change a * by a word... Could help if I post the enterly code?

[ --<-@ ] Black Rose 03-18-2006 13:30

yeah, post it.

capndurk 03-18-2006 13:37

Sorry, I didn't see that if statement with pos in it before. :x

Flashhh! 03-18-2006 13:44

Its an old but great plugin of SuicideDog

Code:

#include <amxmodx>
#include <amxmisc>

// max number of words in word list
#define MAX_WORDS 192

new g_swearsNames[MAX_WORDS][32]
new g_swearsNum

public plugin_init()
{
        register_plugin("Swear Filter","1.0a","SuicideDog")
        register_clcmd("say","swearcheck")
        register_clcmd("say_team","swearcheck")
        readList()
}

readList()
{
    // file to read words from
        new szCustomDir[64]
        new filename[64]
        get_customdir( szCustomDir, 63 )
        format(filename, 63, "%s/swear/swearwords.ini", szCustomDir )

        if(!file_exists(filename) ){
                log_message("Swear Filter: file %s not found", filename)
                return
        }
        new iLen
        while( g_swearsNum < MAX_WORDS && read_file(filename, g_swearsNum ,g_swearsNames[g_swearsNum][1],30,iLen) )
        {
        if( g_swearsNames[g_swearsNum][0] == ';') continue
        g_swearsNames[g_swearsNum][0] = iLen
        ++g_swearsNum
        }
        log_message("Swear Filter: loaded %d words",g_swearsNum )
}

public swearcheck(id)
{
        new szSaid[192]
        read_args(szSaid,191)
        new bool:found = false
        new pos, i = 0
        while ( i < g_swearsNum )
        {
        if ( (pos = containi(szSaid,g_swearsNames[i][1])) != -1 ){
                new len = g_swearsNames[i][0]
                while(len--)
                szSaid[pos++] = '*'
                found = true
                continue
        }
        ++i
        }
        if ( found ){
                new cmd[32]
                read_argv(0,cmd,31)         
                engclient_cmd(id,cmd,szSaid)   
        }
        return PLUGIN_CONTINUE
}

I want to chang the * by a word.

[ --<-@ ] Black Rose 03-18-2006 14:19

Code:
#include <amxmodx> #include <amxmisc> // max number of words in word list #define MAX_WORDS 192 #define word "lol" new g_swearsNames[MAX_WORDS][32] new g_swearsNum public plugin_init() {     register_plugin("Swear Filter","1.0a","SuicideDog")     register_clcmd("say","swearcheck")     register_clcmd("say_team","swearcheck")     readList() } readList() {     new szCustomDir[64]     new filename[64]     get_customdir( szCustomDir, 63 )     format(filename, 63, "%s/swear/swearwords.ini", szCustomDir )         if(!file_exists(filename) ) {         log_message("Swear Filter: file %s not found", filename)         return     }     new iLen     while( g_swearsNum < MAX_WORDS && read_file(filename, g_swearsNum ,g_swearsNames[g_swearsNum][1],30,iLen) ) {         if( g_swearsNames[g_swearsNum][0] == ';') continue         g_swearsNames[g_swearsNum][0] = iLen         ++g_swearsNum     }     log_message("Swear Filter: loaded %d words",g_swearsNum ) } public swearcheck(id) {     new szSaid[192]     read_args(szSaid,191)     new bool:found = false     new i = 0     while ( i < g_swearsNum ) {         if ( ( containi(szSaid,g_swearsNames[i][1])) != -1 ) {             replace(szSaid, 191, g_swearsNames[i][1], word)             found = true             continue         }         ++i     }     if ( found ) {         new cmd[32]         read_argv(0,cmd,31)         engclient_cmd(id,cmd,szSaid)     }     return PLUGIN_CONTINUE }


All times are GMT -4. The time now is 16:44.

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