Raised This Month: $ Target: $400
 0% 

nVault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-21-2007 , 12:44   nVault
Reply With Quote #1

this is my first time using nVault, am I doing this correectly, I kinda just pulled it outta my butt....
Code:
#define PLUGIN_VAULT "avp_vault" new vault = nvault_open(PLUGIN_VAULT);     if(vault == INVALID_HANDLE) {     avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);     return PLUGIN_CONTINUED; }     //saves nvault_set(vault, szKey, szData);     nvault_close(vault);
I format the key/data earlier I am not sure I am using the nvault system right or not...

then loading:
Code:
new vault = nvault_open(PLUGIN_VAULT);     if(vault == INVALID_HANDLE) {     avp_log("ERROR: Unable to open vault file %s", PLUGIN_VAULT);     return PLUGIN_CONTINUED; } new szKey[128], szData[256], data; data = nvault_get(vault, szKey, szData, 255);         nvault_close(vault); if(data) {     parse(szData, ........); //parse dfata blah blah } else {     //if this is called key not found???? I dunno.... }

is that right?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-21-2007 , 14:52   Re: nVault
Reply With Quote #2

Here is something from 'Points System' by Deviance! ;)

Code:
public save_points(id)
{
 new valut = nvault_open("points");
 
 if(valut == INVALID_HANDLE)
  set_fail_state("nValut returned invalid handle");
 
 new key[62], value[10], authid[33];
 
 get_user_authid(id, authid, 32); 
 
 format(key, 61,"%s-points", authid);
 format(value, 9,"%d", points[id]);
 
 nvault_set(valut, key, value);
 nvault_close(valut);
 
 return 0;
}
 
public load_points(id)
{
 new valut = nvault_open("points");
 
 if(valut == INVALID_HANDLE)
  set_fail_state("nValut returned invalid handle");
 
 new key[100], authid[33];
 
 get_user_authid(id, authid, 32);
 
 formatex(key, 99,"%s-points", authid);
 
 points[id] = nvault_get(valut, key);
 nvault_close(valut);
 
 return 0;
}
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-21-2007 , 17:53   Re: nVault
Reply With Quote #3

so it looks like I did it correctly, but will the szData varriable be filled correctly?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-21-2007 , 18:03   Re: nVault
Reply With Quote #4

Quote:
Originally Posted by Rolnaaba View Post
so it looks like I did it correctly...
Hum...'saving' you did it right but loading ?! Don't use parse...or.. ! My exemple is working fine ....
Quote:
Originally Posted by Rolnaaba View Post
... but will the szData varriable be filled correctly?
Why not?
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-21-2007 , 18:42   Re: nVault
Reply With Quote #5

I parse because your example does this:
points[id] = nvault_get(valut, key);

you retrieve only a integer, but I recieve a string with much more information, and parse should work fine, just as long as I used the nvault functions correctly.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-22-2007 , 03:53   Re: nVault
Reply With Quote #6

Oh...you'r right! ;P
__________________
Still...lovin' . Connor noob! Hello
Alka 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:33.


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