AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem plugin BadNames condition IF (containi) (https://forums.alliedmods.net/showthread.php?t=221337)

aEEk 07-20-2013 17:45

Problem plugin BadNames condition IF (containi)
 
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 );
        }
    }



DWIGHTpN 07-21-2013 17:51

Re: Problem plugin BadNames condition IF (containi)
 
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;
            }
        }
    }



Black Rose 07-21-2013 18:03

Re: Problem plugin BadNames condition IF (containi)
 
Here's your problem.
Code:
containi(name, "www")       != -11

aEEk 07-21-2013 19:14

Re: Problem plugin BadNames condition IF (containi)
 
Quote:

Originally Posted by DWIGHTpN (Post 1995957)
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 (Post 1995961)
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?

akcaliberg 07-21-2013 21:57

Re: Problem plugin BadNames condition IF (containi)
 
contain

->

containi

DWIGHTpN 07-22-2013 06:26

Re: Problem plugin BadNames condition IF (containi)
 
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...

aEEk 07-22-2013 07:10

Re: Problem plugin BadNames condition IF (containi)
 
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...

Black Rose 07-22-2013 10:16

Re: Problem plugin BadNames condition IF (containi)
 
Quote:

Originally Posted by aEEk (Post 1996301)
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;         }     } }

aEEk 07-23-2013 18:40

Re: Problem plugin BadNames condition IF (containi)
 
It's OK! No errors, no bugs , yet :D I hope that server will not fall.


All times are GMT -4. The time now is 06:26.

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