Quote:
Originally Posted by fysiks
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:
CheckPlayerVIP( id )
{
new szPassword[ 18 ];
get_user_info( id, "_pw", szPassword, charsmax( szPassword ) );
if( TrieGetArray( g_tDatabase, g_iPlayer[ id ][ AuthID ], eData, sizeof eData ) || TrieGetArray( g_tDatabase, g_iPlayer[ id ][ Name ], eData, sizeof eData ) )
{
if( ( eData[ Player_Password ][ 0 ] && equal( eData[ Player_Password ], szPassword ) ) || !eData[ Player_Password ][ 0 ] )
{
if( eData[ Player_Suspended ] && ! eData[ Player_AccessFlags ][ 0 ] )
{
g_iPlayer[ id ][ VIP ] = 0;
g_iPlayer[ id ][ VIP ] = read_flags( "z" );
TrieDeleteKey( g_tDatabase, eData[ Player_Name ] )
return PLUGIN_HANDLED;
}
else
{
g_iPlayer[ id ][ VIP ] |= read_flags( eData[ Player_AccessFlags ] );
return PLUGIN_HANDLED;
}
}
else if( eData[ Player_Password ][ 0 ] && ! equal( eData[ Player_Password ], szPassword ) )
{
server_cmd( "kick #%d ^"You have no entry to this server^"", get_user_userid( id ) );
}
}
return PLUGIN_CONTINUE;
}
__________________