Raised This Month: $ Target: $400
 0% 

Solved Remove line from file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-10-2022 , 23:46   Re: Remove line from file
Reply With Quote #1

If you're trying to remove entries based on the timestamp, maybe consider using nvault since it has a built in mechanism to prune the data based on timestamps.
__________________
fysiks is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-11-2022 , 12:18   Re: Remove line from file
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
If you're trying to remove entries based on the timestamp, maybe consider using nvault since it has a built in mechanism to prune the data based on timestamps.
No, i created a vip system works like "Name|SteamID" "Pw" "Flags" "Expire Date", if the user has expired will lost his access but i try to add new option for remove the user from the file when expired.

I tried to use stock that i mentioned in the first post:
Code:
ReloadFile( ) {     TrieClear( g_tDatabase );         new g_szFile[ 128 ]         formatex( g_szFile, charsmax( g_szFile ), "%s/%s", g_szConfigs, g_iAccountFile )         new iFile = fopen( g_szFile, "rt" );         if( iFile )     {         new szData[ 512 ]                 while( fgets( iFile, szData, charsmax( szData ) ) )         {                 trim( szData );                         switch( szData[ 0 ] )             {                 case EOS, ';',  '#', '/':                 {                     continue;                 }                 default:                 {                     if                     (                         parse                         (                             szData, eData[ Player_Name ]        , charsmax( eData[ Player_Name ] ),                             eData[ Player_Password ]        , charsmax( eData[ Player_Password ] ),                             eData[ Player_AccessFlags ]     , charsmax( eData[ Player_AccessFlags ] ),                             eData[ Player_Expire_Date ]     , charsmax( eData[ Player_Expire_Date ] )                         ) < 4                     )                     {                         continue;                     }                                         if( eData[ Player_Expire_Date ][ 0 ] )                     {                         if( HasDateExpired( eData[ Player_Expire_Date ] ) )                         {                             eData[ Player_Suspended ] = true;                             RemoveExpired( eData[ Player_Name ] );                         }                     }                                         if( eData[ Player_Name ][ 0 ] )                     {                         TrieSetArray( g_tDatabase, eData[ Player_Name ], eData, sizeof eData );                     }                                         arrayset( eData, 0, sizeof( eData ) );                 }             }         }         fclose( iFile );     } }

It's work like create a new file without line of the user who expired and delete old file and rename the new file but as you see the old file didn't deleted etc..


I'm not sure if i can do that using "TrieDeleteKey" but tried and it did not work:
PHP Code:
CheckPlayerVIPid )
{
    new 
szPassword18 ];

    
get_user_infoid"_pw"szPasswordcharsmaxszPassword ) );
        
    if( 
TrieGetArrayg_tDatabaseg_iPlayerid ][ AuthID ], eDatasizeof eData ) || TrieGetArrayg_tDatabaseg_iPlayerid ][ Name ], eDatasizeof eData ) )
    {
        if( ( 
eDataPlayer_Password ][ ] && equaleDataPlayer_Password ], szPassword ) ) || !eDataPlayer_Password ][ ] )
        {
            if( 
eDataPlayer_Suspended ]  && ! eDataPlayer_AccessFlags ][ ] )
            {
                
g_iPlayerid ][ VIP ] = 0;
                
g_iPlayerid ][ VIP ] = read_flags"z" );
                
TrieDeleteKeyg_tDatabaseeDataPlayer_Name ] )
                return 
PLUGIN_HANDLED;
            }
            else
            {
                
g_iPlayerid ][ VIP ] |= read_flagseDataPlayer_AccessFlags ] );
                return 
PLUGIN_HANDLED;
            }
        }
        else if( 
eDataPlayer_Password ][ ] && ! equaleDataPlayer_Password ], szPassword ) )
        {
            
server_cmd"kick #%d ^"You have no entry to this server^""get_user_useridid ) );   
        }
    }
    
    return 
PLUGIN_CONTINUE;

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 02-11-2022 at 12:21.
Supremache 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 11:43.


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