Raised This Month: $ Target: $400
 0% 

Problem plugin BadNames condition IF (containi)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aEEk
Member
Join Date: May 2012
Location: Romania
Old 07-20-2013 , 17:45   Problem plugin BadNames condition IF (containi)
Reply With Quote #1

I have a problem with a BadNames plugin:
If i set any names (out of condition if), plugin change name in "Test BadNames"
I want to change name only under condition if (from plugin).

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define z_Name "Test BadNames"

public plugin_init ( )
    
register_plugin"BAD_NAMES""1.0""aEEk" );

   
public 
client_connect id )
    
set_task 2.0"checkname"id );

   
public 
client_infochanged id )
    
set_task 2.0"checkname"id );

   
public 
checkname id )
{
    if (
is_user_connected(id))
    {
     new 
name[32]
        
get_user_name(idname31)
        if(
containi(name"player") != -|| containi(name"unnamed") != -|| containi(name".ro") != -|| containi(name".com") != -|| containi(name".xxx") != -|| containi(name".rs") != -|| containi(name".info") != -|| containi(name".in") != -|| containi(name".net") != -|| containi(name"www") != -11 || containi(name"connect") != -|| containi(name":27015") != -|| containi(name"89.") != -|| containi(name".org") != -)
        {    
        
client_cmd id"name ^"%s^""z_Name );
        }
    }


Last edited by aEEk; 07-21-2013 at 20:31. Reason: Problem not solved
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 07-21-2013 , 17:51   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #2

Try this :

PHP Code:
#include <amxmodx>
#include <amxmisc>

new const new_name[ ] = "Test BadNames"
new const bad_names[ ][ ] = {
    
"player",
    
"unnamed",
    
".ro",
    
".xxx",
    
".rs",
    
".info",
    
".in",
    
".net",
    
"www",
    
"connect",
    
"27015",
    
".org",
    
"89."
}

public 
plugin_init ( )
    
register_plugin"BAD_NAMES""1.0""aEEk" );

   
public 
client_connect id )
    
set_task 2.0"checkname"id );

   
public 
client_infochanged id )
    
set_task 2.0"checkname"id );

   
public 
checkname id )
{
    if (
is_user_connected(id))
    {
        static 
name[33];
        
get_user_infoid"name"namesizeof name 1);
        for( new 
0;sizeof(bad_names);i++ ) {
            if( 
contain(namebad_names] ) != -) {
                
set_user_infoid"name"new_name );
                break;
            }
        }
    }


Last edited by DWIGHTpN; 07-21-2013 at 17:51.
DWIGHTpN is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-21-2013 , 18:03   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #3

Here's your problem.
Code:
containi(name, "www")       != -11
Black Rose is offline
aEEk
Member
Join Date: May 2012
Location: Romania
Old 07-21-2013 , 19:14   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #4

Quote:
Originally Posted by DWIGHTpN View Post
Try this :

PHP Code:
#include <amxmodx>
#include <amxmisc>

new const new_name[ ] = "Test BadNames"
new const bad_names[ ][ ] = {
    
"player",
    
"unnamed",
    
".ro",
    
".xxx",
    
".rs",
    
".info",
    
".in",
    
".net",
    
"www",
    
"connect",
    
"27015",
    
".org",
    
"89."
}

public 
plugin_init ( )
    
register_plugin"BAD_NAMES""1.0""aEEk" );

   
public 
client_connect id )
    
set_task 2.0"checkname"id );

   
public 
client_infochanged id )
    
set_task 2.0"checkname"id );

   
public 
checkname id )
{
    if (
is_user_connected(id))
    {
        static 
name[33];
        
get_user_infoid"name"namesizeof name 1);
        for( new 
0;sizeof(bad_names);i++ ) {
            if( 
contain(namebad_names] ) != -) {
                
set_user_infoid"name"new_name );
                break;
            }
        }
    }

Thanks !

Quote:
Originally Posted by Black Rose View Post
Here's your problem.
Code:
containi(name, "www") != -11
Thanks for observation But in final i will use DWIGHT Script

Thank you so much, guys! but is a PROBLEM(NOT SOLVED!
when i set name with big letters (ex: .CoM), plugin don't have effect on client... can be solved?

Last edited by aEEk; 07-21-2013 at 20:55. Reason: Problem with big LETTERS
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 07-21-2013 , 21:57   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #5

contain

->

containi

Last edited by akcaliberg; 07-21-2013 at 21:58.
akcaliberg is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 07-22-2013 , 06:26   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <amxmisc>

new const new_name[ ] = "Test BadNames"
new const bad_names[ ][ ] = {
    
"player",
    
"unnamed",
    
".ro",
    
".xxx",
    
".rs",
    
".info",
    
".in",
    
".net",
    
"www",
    
"connect",
    
"27015",
    
".org",
    
"89."
}

public 
plugin_init ( )
    
register_plugin"BAD_NAMES""1.0""aEEk" );

   
public 
client_connect id )
    
set_task 2.0"checkname"id );

   
public 
client_infochanged id )
    
set_task 2.0"checkname"id );

   
public 
checkname id )
{
    if (
is_user_connected(id))
    {
        static 
name[33];
        
get_user_infoid"name"namesizeof name 1);
        
strtolower(name); 
        for( new 
0;sizeof(bad_names);i++ ) {
            if( 
contain(namebad_names] ) != -) {
                
set_user_infoid"name"new_name );
                break;
            }
        }
    }

This for ".Com", "wWw", "CoNNeCt" etc...
DWIGHTpN is offline
aEEk
Member
Join Date: May 2012
Location: Romania
Old 07-22-2013 , 07:10   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #7

thanks. now, plugin working perfect.

One more question: If I were to place a special domain ( for example: special.ro) even if it contains ".ro" within its name, without harming the client(player), will it work? Will there be any problem? I should use else if with FMRES_IGNORED;? hmm...
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-22-2013 , 10:16   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #8

Quote:
Originally Posted by aEEk View Post
thanks. now, plugin working perfect.

One more question: If I were to place a special domain ( for example: special.ro) even if it contains ".ro" within its name, without harming the client(player), will it work? Will there be any problem? I should use else if with FMRES_IGNORED;? hmm...
Adding a "whitelist" is absolutely possible.
You just add this as a global, just like bad_names[][]:
Code:
new const good_names[][] = {     "special.ro" }
And also adding this before your loop that checks for bad names:
Code:
        for ( new i = 0 ; i < sizeof(good_names) ; i++ ) {             if ( containi(name, good_names[i] ) != -1 ) {                 return;             }         }
This is what you would end up with (except i removed str_to_lower and replaced it with containi):
Code:
#include <amxmodx> new const new_name[] = "Test BadNames" new const bad_names[][] = {     "player",     "unnamed",     ".ro",     ".xxx",     ".rs",     ".info",     ".in",     ".net",     "www",     "connect",     "27015",     ".org",     "89." } new const good_names[][] = {     "special.ro" } public plugin_init()     register_plugin("BAD_NAMES", "1.0", "aEEk");     public client_connect(id)     set_task(2.0, "checkname", id);     public client_infochanged(id)     set_task (2.0, "checkname", id);     public checkname(id) {         if ( ! is_user_connected(id) )         return         static name[33];     get_user_info(id, "name", name, sizeof name - 1);         for ( new i = 0 ; i < sizeof(good_names) ; i++ ) {         if ( containi(name, good_names[i] ) != -1 ) {             return;         }     }         for ( new i = 0 ; i < sizeof(bad_names) ; i++ ) {         if ( containi(name, bad_names[i] ) != -1 ) {             set_user_info(id, "name", new_name);             break;         }     } }

Last edited by Black Rose; 07-22-2013 at 10:32.
Black Rose is offline
aEEk
Member
Join Date: May 2012
Location: Romania
Old 07-23-2013 , 18:40   Re: Problem plugin BadNames condition IF (containi)
Reply With Quote #9

It's OK! No errors, no bugs , yet I hope that server will not fall.

Last edited by aEEk; 07-26-2013 at 18:55.
aEEk is offline
Send a message via Yahoo to aEEk Send a message via Skype™ to aEEk
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 06:26.


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