Raised This Month: $ Target: $400
 0% 

Help Changing this part of swear filter plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flashhh!
Senior Member
Join Date: Nov 2005
Old 03-18-2006 , 01:01   Help Changing this part of swear filter plugin
Reply With Quote #1

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! is offline
Flashhh!
Senior Member
Join Date: Nov 2005
Old 03-18-2006 , 03:25  
Reply With Quote #2

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.
Flashhh! is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-18-2006 , 07:32  
Reply With Quote #3

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
[ --<-@ ] Black Rose is offline
Flashhh!
Senior Member
Join Date: Nov 2005
Old 03-18-2006 , 12:29  
Reply With Quote #4

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"
Any ideas why this error?
Flashhh! is offline
capndurk
Senior Member
Join Date: Feb 2006
Old 03-18-2006 , 12:41  
Reply With Quote #5

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
capndurk is offline
Flashhh!
Senior Member
Join Date: Nov 2005
Old 03-18-2006 , 13:07  
Reply With Quote #6

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?
Flashhh! is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-18-2006 , 13:30  
Reply With Quote #7

yeah, post it.
[ --<-@ ] Black Rose is offline
capndurk
Senior Member
Join Date: Feb 2006
Old 03-18-2006 , 13:37  
Reply With Quote #8

Sorry, I didn't see that if statement with pos in it before.
capndurk is offline
Flashhh!
Senior Member
Join Date: Nov 2005
Old 03-18-2006 , 13:44  
Reply With Quote #9

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.
Flashhh! is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-18-2006 , 14:19  
Reply With Quote #10

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 }
[ --<-@ ] Black Rose 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 16:44.


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