AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault (https://forums.alliedmods.net/showthread.php?t=58220)

Rolnaaba 07-21-2007 12:44

nVault
 
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?

Alka 07-21-2007 14:52

Re: nVault
 
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;
}


Rolnaaba 07-21-2007 17:53

Re: nVault
 
so it looks like I did it correctly, but will the szData varriable be filled correctly?

Alka 07-21-2007 18:03

Re: nVault
 
Quote:

Originally Posted by Rolnaaba (Post 506293)
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 :P....
Quote:

Originally Posted by Rolnaaba (Post 506293)
... but will the szData varriable be filled correctly?

Why not?

Rolnaaba 07-21-2007 18:42

Re: nVault
 
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.

Alka 07-22-2007 03:53

Re: nVault
 
Oh...you'r right! ;P


All times are GMT -4. The time now is 21:34.

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