AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New fvault custom function (https://forums.alliedmods.net/showthread.php?t=146826)

.MMYTH. 01-01-2011 16:47

New fvault custom function
 
I make a new function to add to my custom fvault and i want know if is correct:

PHP Code:

stock fvault_remove_data(const vaultname[], const key[], const data[])
{
    new 
filename[128];
    
_FormatVaultName(vaultnamefilenamesizeof(filename) - 1);
    
    if( !
file_exists(filename) )
    {
        return;
    }
    
    new 
file fopen(_temp_vault"wt");
    
    new 
vault fopen(filename"rt");
    
    new 
_data[512], _other[3];
    
    while( !
feof(vault) )
    {
        
fgets(vault_datasizeof(_data) - 1);
        
parse(_data_keysizeof(_key) - 1_othersizeof(_other) - 1);
        
        
replace(_datacharsmax(_data), data"")
        
trim(data)
    }
    
    
fclose(file);
    
fclose(vault);


?

GXLZPGX 01-01-2011 17:04

Re: New fvault custom function
 
Quote:

Originally Posted by .MMYTH. (Post 1383922)
I make a new function to add to my custom fvault and i want know if is correct:

PHP Code:

stock fvault_remove_data(const vaultname[], const key[], const data[])
{
    new 
filename[128];
    
_FormatVaultName(vaultnamefilenamesizeof(filename) - 1);
    
    if( !
file_exists(filename) )
    {
        return;
    }
    
    new 
file fopen(_temp_vault"wt");
    
    new 
vault fopen(filename"rt");
    
    new 
_data[512], _other[3];
    
    while( !
feof(vault) )
    {
        
fgets(vault_datasizeof(_data) - 1);
        
parse(_data_keysizeof(_key) - 1_othersizeof(_other) - 1);
        
        
replace(_datacharsmax(_data), data"")
        
trim(data)
    }
    
    
fclose(file);
    
fclose(vault);


?

Suggestion: Test it

Exolent[jNr] 01-01-2011 17:32

Re: New fvault custom function
 
Already included in FVault.

Code:
/**  * Removes a key from a vault  *  * @param vaultname    Vault name to look in  * @param key        Key to remove  * @return        No return  */ fvault_remove_key(const vaultname[], const key[])

Also, that code is far from correct.

ConnorMcLeod 01-01-2011 18:24

Re: New fvault custom function
 
I doubt anyone has already succeeded in delete or add any data without writing anything in any file.


All times are GMT -4. The time now is 02:09.

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