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

Remove line from users.ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 10:25   Remove line from users.ini
Reply With Quote #1

hello..

how to remove line from users.ini wich contains some IP

sorry for my bad english

Last edited by Carrion; 03-31-2020 at 22:20.
Carrion is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2020 , 18:54   Re: Remove line from users.ini
Reply With Quote #2

The user shouldn't be in users if they do not have flags?

Set dDelete to true to remove the line from users.ini. Set to false (default) only comments out the line. Not thoroughly tested.
PHP Code:
RemoveAdmin( const szRemoveAuthID[] , bool:bDelete=false )
{
    new 
szAuthID34 ] , bool:bUserFound;
    new 
iFile iNewFile bool:bSkipLine;
    new 
szUsersFile64 ] , szNewUsersFile64 ] , szLine128 ];
    
    
copyszUsersFileget_configsdirszUsersFile charsmaxszUsersFile ) ) ] , charsmaxszUsersFile ) ,"/users.ini" );
    
formatexszNewUsersFile charsmaxszNewUsersFile ) , "%s_2" szUsersFile );
    
    if ( ( 
iFile fopenszUsersFile "rt" ) ) )
    {
        
iNewFile fopenszNewUsersFile "wt" );
        
        while( 
fgetsiFile szLine charsmaxszLine ) ) )
        {
            
parseszLine szAuthID charsmaxszAuthID ) );
            
            if ( 
equaliszAuthID szRemoveAuthID ) )
            {
                if ( !
bDelete )
                {
                    
formatszLine charsmaxszLine ) , ";%s" szLine );
                }
                else
                {
                    
bSkipLine true;
                }
                
                
bUserFound true;
            }
            
            if ( !
bSkipLine )
            {
                
fputsiNewFile szLine );
            }
            else
            {
                
bSkipLine false;
            }
        }
    }

    
fcloseiNewFile );
    
fcloseiFile );
    
    
delete_fileszUsersFile );
    
rename_fileszNewUsersFile szUsersFile true );
    
    return 
bUserFound;

__________________

Last edited by Bugsy; 03-30-2020 at 18:55.
Bugsy is offline
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 19:10   Re: Remove line from users.ini
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
The user shouldn't be in users if they do not have flags?
user is already in users.ini , its other part of code, he got VIP flags for example 1000 kills and after he makes for example 5000 kills he will get AdMIN flags..., code adding users with VIP flags and after 5000 kills ADMIN flags, but i want to remove the old lines which contains vip flags , so this last i`m trying to make
Carrion is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-30-2020 , 19:23   Re: Remove line from users.ini
Reply With Quote #4

Quote:
Originally Posted by Carrion View Post
user is already in users.ini , its other part of code, he got VIP flags for example 1000 kills and after he makes for example 5000 kills he will get AdMIN flags..., code adding users with VIP flags and after 5000 kills ADMIN flags, but i want to remove the old lines which contains vip flags , so this last i`m trying to make
Why don't you just set the remaining flags when reaching 5000 kills? No need to remove anything from users.ini when you're about to add the same flags again.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 19:59   Re: Remove line from users.ini
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
Why don't you just set the remaining flags when reaching 5000 kills? No need to remove anything from users.ini when you're about to add the same flags again.

if u mean this method -> set_user_flags(target, get_user_flags(target) | new_flags)
bc every month stats will reset(csx) ( reseting is for other award top3 plugin)

Last edited by Carrion; 03-30-2020 at 19:59.
Carrion is offline
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 20:08   Re: Remove line from users.ini
Reply With Quote #6

Remove line from users.ini

Last edited by Carrion; 03-31-2020 at 22:20.
Carrion is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2020 , 20:17   Re: Remove line from users.ini
Reply With Quote #7

I dont fully understand what you need. Users.ini should only hold your permanent admins. Any temporary flags should not be contained in users.ini, but set with set_user_flags() while the plugin is running.
__________________
Bugsy is offline
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 20:44   Re: Remove line from users.ini
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
I dont fully understand what you need. Users.ini should only hold your permanent admins. Any temporary flags should not be contained in users.ini, but set with set_user_flags() while the plugin is running.
everymonth after reseting user will lost kills, so this plugin will keep users in users.ini forever...
if user makes 1000 kills he will get vIP flags, after 5000 he will get admin flags...
so when he get admin i want to remove from users.ini old access

example

Code:
"IP" "" "bi" "de" ; "Carrion"; 03/31/2020 - 03:33:52
"IP" "" "bcdefiju" "de" ; "Carrion"; 03/31/2020 - 03:45:55
remove first line after user get new flags

Last edited by Carrion; 03-30-2020 at 20:46.
Carrion is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2020 , 20:49   Re: Remove line from users.ini
Reply With Quote #9

So how is the plugin supposed to know which to remove?

RemoveAdmin( "192.167.1.1" , "bi" )

?
__________________
Bugsy is offline
Carrion
Member
Join Date: Mar 2020
Old 03-30-2020 , 20:58   Re: Remove line from users.ini
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
So how is the plugin supposed to know which to remove?

RemoveAdmin( "192.167.1.1" , "bi" )

?
first plugin checking users stats(kills)
then plugin checks user IP
then plugin check users.ini
and if users.ini LINE contain ip of user its remove line
then adding new line with new admin flags

sorry for my bad english
Carrion 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 08:59.


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