Raised This Month: $ Target: $400
 0% 

nVault help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-02-2005 , 21:08   nVault help
Reply With Quote #1

I'm getting a warning with the nvault_lookup function...I'm not exactly sure how to check by key and see if an entry is already there...the warning says: "warning 202: number of arguments does not match definition" will this still work with the warning or am I using it wrong?

Code:
public client_authorized(id) {     new vaultid = nvault_open("credits")     new authid[32], vault_time[21]     get_user_authid(id,authid,31)     if(nvault_lookup(vaultid,authid)!=0) <---look here     {         vault_time = nvault_get(vaultid,authid,20)         connecttime[id] = str_to_num(vault_time)     }     else     {         connecttime[id] = numnewcredits * credittime         num_to_str(connecttime[id],vault_time,20)         nvault_set(vaultid,authid,vault_time)     }     nvault_close(vaultid)     return PLUGIN_CONTINUE }

I'm also getting an error with the nvault_get function...I'm not exactly sure how to use this now compared to the old vault way...the error is saying: "error 033: array must be indexed <variable "vault_time">"

Code:
public client_disconnect(id) {     new vaultid = nvault_open("credits")     Armor[id] = 0     Health[id] = 0     Speed[id] = 0     Gravity[id] = 0     Stealth[id] = 0     hpstlr[id] = 0     regeneration[id] = 0     weapontraining[id] = 0     jumpmodule[id] = 0     climb[id] = 0     promotion[id] = 0     gHasuammo[id] = 0     sshoe[id] = 0     wired[id] = 0     esp[id] = 0     laser[id] = 0     sgrenade[id] = 0     crowbar[id] = 0     itemcap[id] = 0     creditsspent[id] = 0     lastplaytime[id] = 0     remove_task(id)     new authid[32]     new playtime = (get_user_time(id) - lastplaytime[id])     get_user_authid(id,authid,31)     new tmp_vault_time,vault_time[21]     vault_time = nvault_get(vaultid,authid,20) <---look here     tmp_vault_time = str_to_num(vault_time)     tmp_vault_time += playtime     num_to_str(tmp_vault_time,vault_time,20)     nvault_set(vaultid,authid,vault_time)     nvault_close(vaultid)     return PLUGIN_CONTINUE }
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-02-2005 , 23:31  
Reply With Quote #2

Its used like so:
Code:
nvault_lookup( Vault , szKey , szOutPut , len , TimeStamp); //TimeStamp is an output as well
Where Vault is
Code:
new Vault = nvault_open( "MyVault" );
szKey and szOutPut is:
Code:
nvault_set(Vault , szKey , szOutput); //technically input here
and TimeStamp is the timestamp of when you set the value
To remove on key and value use
Code:
//When checking if its not there like this remember that if it is all the outputs will still be stored so dont call it again afterwards. if(!nvault_lookup( Vault , szKey , szOutPut , len , TimeStamp) {     //Already gone     return PLUGIN_HANDLED } nvault_prune( Vault , (TimeStamp -1) , (TimeStamp +1)); //I know you cant have both set to TimeStamp but I never played around //with it to see which is needed to be set 1 less or 1 more so I used both.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-02-2005 , 23:39  
Reply With Quote #3

so how would I go about finding if an entry is already in the vault? nvault_lookup looks like the only function that would work but the only data I have right now is their key...is there anyway with the nvault to find if an entry is in the vault already by providing their key like with the old vault system?
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-03-2005 , 00:23  
Reply With Quote #4

Use that last scripting part with the if(!nvault_lookup(.....
If its not there whatever is in the if statement will be called if it is there all the output data will be outputted.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-03-2005 , 00:30  
Reply With Quote #5

anyone have any idea about the nvault_get error?

Quote:
nvault_get - Gets a vault value by returning an int setting a byref float or setting a string & maxlength.
by this info I'm guessing when reading something like 1231424 in the vault it will return 1231424 as a string? I dunno why its not working

I'm going to try and get it working with all nvault_lookup's and see if it works...
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-03-2005 , 01:29  
Reply With Quote #6

ok I got it compiling...and when I ran it on my server it started up fine but whenever you bought anything the server would crash and give this error in the logs:

Quote:
L 09/03/2005 - 00:20:27: [AMXX] Run time error 5 (memory access)
L 09/03/2005 - 00:20:27: [AMXX] Displaying call trace (plugin "cstrike\addons\amxmodx\plugins\creditswithnv ault.amxx")
L 09/03/2005 - 00:20:27: [AMXX] [0] creditswithnvault.sma::client_authorized (line 1449)
this is what was in my credits.vault file:

Quote:
TLVn  ‹$C STEAM_0:1:84401
I attached the source below
Attached Files
File Type: sma Get Plugin or Get Source (creditswithnvault.sma - 143 views - 44.7 KB)
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 09-03-2005 , 01:45  
Reply With Quote #7

dont use nvault_close at all, it causes a crash. I brought this up to BAIL already.
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-03-2005 , 01:56  
Reply With Quote #8

Yea i found that out myself. Open the vault in plugin_init just dont close it anywhere and your good
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
atambo
Senior Member
Join Date: Oct 2004
Location: Pittsburgh, PA
Old 09-03-2005 , 02:22  
Reply With Quote #9

alright well that fixed the crash problem but now I can buy just fine (I even added prints to show me what it was reading from the vault and it works fine when buying) but when I type /credits it will set my credits to 0 for some reason...and the journel is always size 0 and the vault never shows up

are there any other problems with the nvault that I should know about?...lol I was hoping I could get some pruning going
__________________
atambo is offline
Send a message via AIM to atambo Send a message via MSN to atambo Send a message via Yahoo to atambo
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 09-03-2005 , 09:30  
Reply With Quote #10

it works fine for me.....

Heres a sample

Code:
//Name for binary vault file #define VAULTNAME "somevault" #define DAYS_TO_SAVE 30 new gVaultHandle //---------------------------------------------------------------------------------------------- public some_function() {     gVaultHandle = nvault_open(VAULTNAME)     if (gVaultHandle == INVALID_HANDLE) {         log_amx("Error opening nVault file: %s",VAULTNAME)     }         //Setting Data     nvault_set(gVaultHandle, key, data)         //Getting Data     new data[1501], timestamp     nvault_lookup(gVaultHandle, key, data, 1500, timestamp)         //Pruning     if (clearAll)   nvault_prune(gVaultHandle, 0, 0)     else            nvault_prune(gVaultHandle, 0, get_systime() - DAYS_TO_SAVE * 24 * 3600))         //Close (dont use right now cause it crashes)     //nvault_close(gVaultHandle) }
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
Reply



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


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