Raised This Month: $ Target: $400
 0% 

containi() always seems to match


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[DumB]Steamsucks
Junior Member
Join Date: Feb 2006
Location: uk
Old 03-03-2006 , 12:13   containi() always seems to match
Reply With Quote #1

i have an ini file { minus the stars u know why there in there ) like so

f*ck|c*n8|nob|assh*le
sh*t|dick|wan*a|bas*ard

and the code i have is

Code:
#include <amxmodx> #include <amxmisc> #include <file> #include <cstrike> new Sarray[3][300] new inifile[101] new arg[192] new readdata[401]         // the data on the line it is reading new linelength = 0       // how long the line is new currline=0 stock explode( output[][], input[], delimiter, textlen, maxMatches )     {     new nIdx = 0     new nLen = (1 + copyc( output[nIdx], textlen, input, delimiter ))     new len = strlen(input)         while( nLen < len && nIdx < maxMatches )         nLen += (1 + copyc( output[++nIdx], textlen, input[nLen], delimiter ))     return nIdx + 1 } public plugin_init() {     register_plugin("Speak English", "0.1a", "[DumB]SteamSucks")         register_clcmd("say", "cmd_say")     register_clcmd("say_team", "cmd_sayteam")         inifile ="words.txt"    } public cmd_say(id)     {         new szFile[100]         get_configsdir( szFile , 99 )         format(szFile , 99 , "%s/%s", szFile, inifile)               read_args(arg, 191)     remove_quotes(arg) // Say Message are encase in Quotes           while(read_file(szFile,currline,readdata,400,linelength) != 0){  //checks every line in inifile, stores what it finds in readdata, and what line its on in currline                 explode(Sarray,readdata,'|',linelength,3)                 server_print("Badwords so far are: %s | %s | %s",Sarray[0],Sarray[1],Sarray[2])         server_print("words said are: %s",arg)                 if( !containi(arg,Sarray[2]) || !containi(arg,Sarray[1])  || !containi(arg,Sarray[2])) {             currline = 0             return PLUGIN_CONTINUE             } else {             client_print(id, print_chat, "Speak english only on this server please!!!")             server_cmd("kick %d Speak english",id)             client_cmd(id , "disconnect")             return PLUGIN_HANDLED           }                 currline++ //goes to the next line       }     currline = 0     return PLUGIN_HANDLED

when i say hi there in game in say it kicks me and i get this from console debug

Code:
Badwords so far are: f*ck | c*nt | w*nk*
words said are: hi there
Dropped ss from server
Reason:  Client sent 'drop'
none of the words i said where contained in any of the sarry items so why has it matched them any ideas any one ?

regards
__________________
If it works then i wrote it if it erros on less then 50 lines i had help with it if it breaks totally it wasnt me..
[DumB]Steamsucks is offline
Send a message via MSN to [DumB]Steamsucks
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-03-2006 , 12:24  
Reply With Quote #2

i think you need to do like so:
Code:
if ( containi( message, "word" ) != -1 )

and shouldnt
Code:
if( !containi(arg,Sarray[2]) || !containi(arg,Sarray[1])  || !containi(arg,Sarray[2])) {
be
Code:
if( !containi(arg,Sarray[0]) || !containi(arg,Sarray[1])  || !containi(arg,Sarray[2])) {


and he wouldn't even have time to se the first msg
Code:
            client_print(id, print_chat, "Speak english only on this server please!!!")             server_cmd("kick %d Speak english",id)             client_cmd(id , "disconnect")
[ --<-@ ] Black Rose is offline
[DumB]Steamsucks
Junior Member
Join Date: Feb 2006
Location: uk
Old 03-03-2006 , 12:30  
Reply With Quote #3

Quote:
Originally Posted by [ --<-@
Black Rose]i think you need to do like so:
Code:
if ( containi( message, "word" ) != -1 )

and shouldnt
Code:
if( !containi(arg,Sarray[2]) || !containi(arg,Sarray[1])  || !containi(arg,Sarray[2])) {
be
Code:
if( !containi(arg,Sarray[0]) || !containi(arg,Sarray[1])  || !containi(arg,Sarray[2])) {


and he wouldn't even have time to se the first msg
Code:
            client_print(id, print_chat, "Speak english only on this server please!!!")             server_cmd("kick %d Speak english",id)             client_cmd(id , "disconnect")

i also tried the != -1 and that didnt make a difference also i put a none message in to the client while in game and it still kicked me

and i do see the speak english please on this server before it kicks me

any other ideas it would appear that it is ignoring the ini file loaded words array and just booting on any word including null string ?
__________________
If it works then i wrote it if it erros on less then 50 lines i had help with it if it breaks totally it wasnt me..
[DumB]Steamsucks is offline
Send a message via MSN to [DumB]Steamsucks
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 03-03-2006 , 14:11  
Reply With Quote #4

Code:
/* Checks if source contains string with case ignoring. On success function
* returns position in source, on failure returns -1. */
native containi(const source[],const string[]);
u should also have it like this (note && instead of ||):
Code:
if(containi(arg,Sarray[0]) < 0 && containi(arg,Sarray[1]) < 0 && containi(arg,Sarray[2]) < 0) {
__________________
plop
p3tsin is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-03-2006 , 17:11  
Reply With Quote #5

Quote:
Originally Posted by [ --<-@
Black Rose]i think you need to do like so:
Code:
if ( containi( message, "word" ) != -1 )
The way he's doing it is fine. When the string is found in the source it returns 0.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x 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 20:25.


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