Raised This Month: $101 Target: $400
 25% 

FVault - A new vault system!


Post New Thread Reply   
 
Thread Tools Display Modes
AntiBots
Veteran Member
Join Date: May 2008
Location: La Plata, Bs As, Argenti
Old 09-05-2008 , 01:13   Re: FVault - A new vault system!
Reply With Quote #11

Good job
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 09-18-2008 , 09:52   Re: FVault - A new vault system!
Reply With Quote #12

This include's principle is to save stuff using regualr .txt/.cfg files right?
That's what I want to try.
I'll try just reading and writing to a file normally, and if I'll get into some issues I'll use your inc.
Nice job.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-12-2009 , 17:22   Re: FVault - A new vault system!
Reply With Quote #13

Added 3 new functions and updated 2.

New:
  • PHP Code:
    /** 
     * Sets data of a key permanently (can't be removed with fvault_prune)
     * 
     * @param vaultname    Vault name to look in
     * @param key        Key name to which data will be set
     * @param data        Data to set to key
     * @return        Does not return a value.
     */
    fvault_pset_data(const vaultname[], const key[], const data[]) 
  • PHP Code:
    /**
     * Prunes the vault for keys that are within the given timestamps
     * 
     * @param vaultname    Vault name to look in
     * @param start        If timestamp is after this Unix Time (set -1 to prune from very start)
     * @param end        If timestamp is before this Unix Time (set -1 to prune to most time)
     * @return        Returns number of keys pruned
     */
    fvault_prune(const vaultname[], const start=-1, const end=-1
  • PHP Code:
    /**
     * Updates the timestamp on a key located within the vault
     * 
     * @param vaultname    Vault name to look in
     * @param key        Key to update timestamp (if it doesn't exist, a blank value will be set)
     * @param timestamp    Unix Time to set for the key (-1 for current time)
     * @return        Returns 2 on new entry, 1 on success, 0 on failure for the key having a permanent timestamp
     */
    fvault_touch(const vaultname[], const key[], const timestamp=-1

Updated:
  • PHP Code:
    /** 
     * Retrieves data specified by a key
     * 
     * @param vaultname    Vault name to look in
     * @param key        Key name to look for the data
     * @param data        String which data will be copied to
     * @param len        Length of data
     * @param timestamp    The unix time of when the data was last set ( -1 if permanent data, 0 if old fvault version ) ( optional param )
     * @return        Returns 1 on success, 0 on failue.
     */
    fvault_get_data(const vaultname[], const key[], data[], len, &timestamp=0
  • (params didn't change; only difference is it adds the current timestamp)
    PHP Code:
    /** 
     * Sets data of a key with current timestamp
     * 
     * @param vaultname    Vault name to look in
     * @param key        Key name to which data will be set
     * @param data        Data to set to key
     * @return        Does not return a value.
     */
    fvault_set_data(const vaultname[], const key[], const data[]) 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-21-2009 , 10:57   Re: FVault - A new vault system!
Reply With Quote #14

PHP Code:
new const g_vault_name[] = "vault1"

guardar_ap(id)
{
    new 
data[16]
    
num_to_str(g_exp[id], datasizeof(data) - 1)
    
    
fvault_set_data(g_vault_nameg_szname[id], data)
    
    new 
end_prune_time get_systime() - (14 24 60 60)
    
fvault_prune(g_vault_name_end_prune_time)

Is this right? If i want to remove the key if not used within 2 weeks
__________________
alan_el_more is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-21-2009 , 11:16   Re: FVault - A new vault system!
Reply With Quote #15

Quote:
Originally Posted by alan_el_more View Post
Is this right? If i want to remove the key if not used within 2 weeks
That would remove all keys, not just that one.
If you want to remove one key for the timestamp, then you would do something like this:
Code:
stock fvault_prune_key( const szVault[ ], const szKey[ ], const iPruneStart=-1, const iPruneEnd=-1 ) {     static szData[ 2 ], iTimeStamp;     if( fvault_get_data( szVault, szKey, szData, 1, iTimeStamp ) && iTimeStamp != -1 ) {         if( iPruneStart == -1 ) {             if( iPruneEnd == -1             || iTimeStamp <= iPruneEnd ) {                 fvault_remove_key( szVault, szKey );                 return 1;             }         }         else if( iPruneEnd == -1 ) {             if( iTimeStamp >= iPruneStart ) {                 fvault_remove_key( szVault, szKey );                 return 1;             }         }         else if( iPruneStart <= iTimeStamp <= iPruneEnd ) {             fvault_remove_key( szVault, szKey );             return 1;         }     }         return 0; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 09-21-2009 at 11:35.
Exolent[jNr] is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-21-2009 , 11:32   Re: FVault - A new vault system!
Reply With Quote #16

Code:
Warning: Function "fvault_remove_key" should return a value on line 327
Warning: Function "fvault_remove_key" should return a value on line 334
Warning: Function "fvault_remove_key" should return a value on line 339
Code:
if(iPruneEnd == -1 || iTimeStamp <= iPruneEnd)
{
        return fvault_remove_key(szVault, szKey)
// Line 327}
Code:
if(iTimeStamp >= iPruneStart)
{
        return fvault_remove_key(szVault, szKey)
// Line 334}
Code:
else if(iPruneStart <= iTimeStamp <= iPruneEnd)
{
       return fvault_remove_key(szVault, szKey)
// Line 339}
__________________
alan_el_more is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-21-2009 , 11:35   Re: FVault - A new vault system!
Reply With Quote #17

I guess I forgot fvault_remove_key( ) doesn't return a value.
My post has been edited.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
alan_el_more
Veteran Member
Join Date: Jul 2008
Location: amxmodx-es.com
Old 09-26-2009 , 11:38   Re: FVault - A new vault system!
Reply With Quote #18

If i save a lot of data. You may have some bugs to load / save?
PD: i use "A simple mod exp" but instead of authorized, use putinserver
__________________
alan_el_more is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 10-11-2009 , 08:25   Re: FVault - A new vault system!
Reply With Quote #19

PHP Code:

// How to find all keys within a vault:

new const vaultname[] = "myvault";

new 
total fvault_size(vaultname);

new 
key[32], data[64];
for( new 
0totali++ )
{
    
fvault_get_keyname(ikeysizeof(key) - 1);
    
fvault_get_data(vaultnamekeydatasizeof(data) - 1);
    
    
server_print("Key: %s | Data: %s"keydata);



PHP Code:
// How to find all keys within a vault:

new const vaultname[] = "myvault";

new 
total fvault_size(vaultname);

new 
key[32], data[64];
for( new 
0totali++ )
{
    
fvault_get_keyname(vaultname,ikeysizeof(key) - 1); //forgot vaultname?
    
fvault_get_data(vaultnamekeydatasizeof(data) - 1);
    
    
server_print("Key: %s | Data: %s"keydata);

__________________
I am out of order!
grimvh2 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-12-2009 , 14:14   Re: FVault - A new vault system!
Reply With Quote #20

Thanks. It has been fixed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 21:45.


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