Raised This Month: $51 Target: $400
 12% 

Names in .ini file


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-09-2010 , 18:09   Re: Names in .ini file
#11

Quote:
Originally Posted by lucas_7_94 View Post
Not tested

PHP Code:
//...

public client_putinserverid )
{
    for ( new 
0sizeoflawl ); i++ )
    {
        static 
szName33 ]
        
get_user_nameidszNamecharsmaxszName ) )
        
        if(
containiszNamelawl] ) )
        {
            
set_user_godmodeid)
        }
    }

PHP Code:

public client_putinserverid )
{
    static 
szName33 ]
    
get_user_nameidszNamecharsmaxszName ) )
    for ( new 
0sizeoflawl ); i++ )
    {        
        if(
containiszNamelawl] ) )
        {
            
set_user_godmodeid)
        }
    }

fixt.

Don't get the same name repetitively.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 04-09-2010 , 21:35   Re: Names in .ini file
#12

I'm in the school sorry , i'm back.

Thanks you Xanimos.

Post Reedited
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
AfteR.
Veteran Member
Join Date: Dec 2008
Location: λ
Old 04-13-2010 , 18:51   Re: Names in .ini file
#13

Thanks Lucas, it worked
AfteR. is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 04-13-2010 , 21:50   Re: Names in .ini file
#14

Quote:
Originally Posted by AfteR. View Post
Thanks Lucas, it worked
not problem.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-13-2010 , 22:07   Re: Names in .ini file
#15

Here's a version using Trie.

2 console cmds used to add\remove names from ini
amx_addname <name>
amx_removename <name>

You can use partial name with these cmds: "amx_addname bug" for bugsy

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

new Trie:g_tNames;
new 
g_szFile64 ];

public 
plugin_init() 
{
    new 
szData35 ];
    
    
g_tNames TrieCreate();
    
    
copyg_szFileget_localinfo"amxx_datadir" g_szFile charsmaxg_szFile ) ) ] , charsmaxg_szFile ) , "/names.ini" );
    
    new 
fopeng_szFile "rt" );
    
    while( !
feof) )
    {
        
fgetsszData charsmaxszData ) );
     
        
trimszData );
        
        if( !
szData[0] || ( szData[0] == ';' ) || ( ( szData[0] == '/' ) && ( szData[1] == '/' ) ) ) 
            continue;
            
        
TrieSetCellg_tNames szData );
    }
    
    
fclose);
    
    
register_concmd"amx_addname" "AddName" ADMIN_BAN "<Name> - Add name to list" );
    
register_concmd"amx_removename" "RemoveName" ADMIN_BAN "<Name> - Remove name from list" );
}

public 
client_putinserverid )
{
    new 
szName33 ];
    
    
get_user_nameid szName charsmaxszName ) );
    
    if ( 
TrieKeyExistsg_tNames szName ) )
    {
        
set_user_godmodeid );
    }
}

public 
AddNameid level cid )
{
    if ( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
        
    new 
szArg33 ];
    
    if ( !
read_argvszArg charsmaxszArg ) ) )
        return 
PLUGIN_HANDLED;
        
    new 
iPlayer cmd_targetid szArg CMDTARGET_ALLOW_SELF CMDTARGET_NO_BOTS )
         
    if ( !
iPlayer )
        return 
PLUGIN_HANDLED;
            
    
get_user_nameiPlayer szArg charsmaxszArg ) );
    
    if ( !
TrieKeyExistsg_tNames szArg ) )
    {
        
TrieSetCellg_tNames szArg );
        
write_fileg_szFile szArg );
        
console_printid "* Added Name ^"%s^" to list." szArg );
    }
    else
    {
        
console_printid "* Name ^"%s^" already exists in list." szArg );
    }
    
    return 
PLUGIN_HANDLED;
}

public 
RemoveNameid level cid )
{
    if ( !
cmd_accessid level cid ) )
        return 
PLUGIN_HANDLED;
        
    new 
szArg33 ];
    
    if ( !
read_argvszArg charsmaxszArg ) ) )
        return 
PLUGIN_HANDLED;
        
    new 
iPlayer cmd_targetid szArg CMDTARGET_ALLOW_SELF CMDTARGET_NO_BOTS )
         
    if ( !
iPlayer )
        return 
PLUGIN_HANDLED;
            
    
get_user_nameiPlayer szArg charsmaxszArg ) );
    
    if ( !
TrieKeyExistsg_tNames szArg ) )
    {
        
console_printid "* Name ^"%s^" is not on the list." szArg );
        return 
PLUGIN_HANDLED;
    }
    
    new 
iFileHandle iFilePos szLineItem35 ];
    
    
iFileHandle fopeng_szFile "rt" );

    while( !
feofiFileHandle ) )
    {
        
fgetsiFileHandle szLineItem charsmaxszLineItem ) );
        
        
trimszLineItem );
        
        
iFilePos++;

        if( !
szLineItem[0] || ( szLineItem[0] == ';' ) || ( ( szLineItem[0] == '/' ) && ( szLineItem[1] == '/' ) ) )
            continue;
        
        if( 
equalszLineItem szArg ) )
        {
            
formatszLineItem charsmaxszLineItem ) , ";%s" szLineItem );
            
write_fileg_szFile szLineItem iFilePos );
            
TrieDeleteKeyg_tNames szArg );
            
console_printid "* Name ^"%s^" was removed from list." szArg );
            break;
        }
    }
        
    
fclose(iFileHandle);
    
    return 
PLUGIN_HANDLED;

__________________

Last edited by Bugsy; 04-14-2010 at 00:14.
Bugsy is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-13-2010 , 23:32   Re: Names in .ini file
#16

in first func
Code:
 if( !szData[0] || szData[0] == ';' || szData[0] == '/' && szData[1] == '/' ) 
            continue;

Code:
 if( !szData[0] || szData[0] == ';' || (szData[0] == '/' && szData[1] == '/' ) )
            continue;
--------------------

Code:
if( szArg[ 0 ] == ';' )
            continue;


Code:
if( szLineItem[ 0 ] == ';' )
            continue;
in last function.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-13-2010 , 23:56   Re: Names in .ini file
#17

Ty sir
__________________
Bugsy is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 04-14-2010 , 02:55   Re: Names in .ini file
#18

Quote:
Originally Posted by Xanimos View Post
Umm,...anyone can come into your server with a name. Why limit it by the name?
Because he is no-steam.
01101101 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-14-2010 , 09:06   Re: Names in .ini file
#19

Quote:
Originally Posted by 01101101 View Post
Because he is no-steam.
Show proof, otherwise such accusations are void.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
AfteR.
Veteran Member
Join Date: Dec 2008
Location: λ
Old 04-14-2010 , 16:03   Re: Names in .ini file
#20

Quote:
Originally Posted by 01101101 View Post
Because he is no-steam.
Really?

Oh, I forgot: I was not banned for using no-steam, remember? (Not saying I use it, lol)

http://forums.alliedmods.net/showpos...&postcount=122
AfteR. is offline
Closed Thread



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 23:36.


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