Raised This Month: $ Target: $400
 0% 

NVault invalid id


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noob cannon lol
SourceMod Donor
Join Date: Sep 2005
Old 05-15-2006 , 23:00   NVault invalid id
Reply With Quote #1

I get this error when i use stock functions i created for a plugin im making. I'm using the frequentfraggerprogram's time tracking as a framework for doing this.:

Code:
L 05/14/2006 - 08:42:28: [nVault] Invalid vault id: 0

L 05/14/2006 - 08:42:28: [AMXX] Displaying debug trace (plugin "zp_ffp2.amxx")
L 05/14/2006 - 08:42:28: [AMXX] Run time error 10: native error (native "nvault_set")
L 05/14/2006 - 08:42:28: [AMXX]    [0] zp_ffp2.sma::add_points (line 662)
L 05/14/2006 - 08:42:28: [AMXX]    [1] zp_ffp2.sma::PressedAbilities (line 703)
L 05/14/2006 - 08:42:28: [AMXX]    [2] zp_ffp2.sma::PressedAbilities (line 702)
L 05/14/2006 - 08:42:36: [nVault] Invalid vault id: 0
This is a stock function to add points- it fails when i try to input strings and strings through constants. Some of this code is sloppy as hell, but I won't care for now.:
Code:
stock add_points(id, vault[32], points) {     new authid[32]     get_user_authid(id,authid,31)     client_print(0, print_chat, "%s", authid)//debugging     client_print(0, print_chat, "%s", vault)//debugging     client_print(0, print_chat, "step1")//debugging     new VaultHandle = nvault_open(vault)     client_print(0, print_chat, "step2")//debugging         // Check if the vault opens properly?     if( VaultHandle == INVALID_HANDLE ){         log_amx("Error opening nVault file: %s", VAULTNAME3)     }                 new before = check_vault(id, vault)     new final = before + points     client_print(0, print_chat, "%f", float(final))//debugging     client_print(0, print_chat, "step3")    //debugging         new vault_info[5]     num_to_str(final,vault_info,4)     client_print(0, print_chat, "%s", vault_info)//debugging     client_print(0, print_chat, "step4") //debugging     nvault_set(VaultHandle, authid, vault_info)     client_print(0, print_chat, "step5") //debugging         nvault_close(VaultHandle) }

This is code within a menu callback that executes add_points
Code:
                new gravity[32]                 format(gravity, 31, "gravity")                 add_points(id, gravity, 1)

This is the stock function check_vault- i know that this is working fine and returns the correct number.
Code:
stock check_vault(id, vault[32]) {     new authid[32]     get_user_authid(id,authid,31)     g_VaultHandle = nvault_open(vault)         // Check if the vault opens properly?     if( g_VaultHandle == INVALID_HANDLE )     {         log_amx("Error opening nVault file: %s", VAULTNAME);     }                 new vault_info[21], TimeStamp                 nvault_lookup(g_VaultHandle, authid, vault_info, 20, TimeStamp)     new info = str_to_num(vault_info)     nvault_close(g_VaultHandle)         return info }

There are three compiler warnings
Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// zp_ffp2.sma
// C:\Program Files\Steam\SteamApps\mrdeathllama\half-life\zp\addons\amxmodx\scripting\zp_ffp2.sma(478) : warning 213: tag mismatch
// C:\Program Files\Steam\SteamApps\mrdeathllama\half-life\zp\addons\amxmodx\scripting\zp_ffp2.sma(480) : warning 213: tag mismatch
// C:\Program Files\Steam\SteamApps\mrdeathllama\half-life\zp\addons\amxmodx\scripting\zp_ffp2.sma(779) : warning 204: symbol is assigned a value that is never used: "gCurrentTime"
// Header size:           1560 bytes
// Code size:            18884 bytes
// Data size:            10860 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:   47688 bytes
// 
// 3 Warnings.
// Done.
//
// Compilation Time: 1.89 sec
// ----------------------------------------

// File not found.

Press enter to exit ...
noob cannon lol is offline
Send a message via AIM to noob cannon lol Send a message via MSN to noob cannon lol
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-15-2006 , 23:54  
Reply With Quote #2

Why don't you do the normal and smart thing of opening a vault once on plugin_init() and closing it on plugin_end() and store the vaultid as a global variable?
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
noob cannon lol
SourceMod Donor
Join Date: Sep 2005
Old 05-16-2006 , 01:05  
Reply With Quote #3

I've created constants for that:
like
#define VAULT_GRAVITY "gravity"

and such.

Also, the methodology used in the frequent fragger program didn't involve opening and closing on init and end, and this is my first experience with nvault, so I didn't do that.
noob cannon lol is offline
Send a message via AIM to noob cannon lol Send a message via MSN to noob cannon lol
BAILOPAN
Join Date: Jan 2004
Old 05-16-2006 , 03:23  
Reply With Quote #4

Keeping the handles open is a good idea. Re-opening them means re-mapping the file into memory which is expensive, and closing them means re-mapping memory back to disk.
__________________
egg
BAILOPAN is offline
noob cannon lol
SourceMod Donor
Join Date: Sep 2005
Old 05-16-2006 , 18:01  
Reply With Quote #5

That's good information for optimization, but can anyone point out for me an error or get me on the right track?
noob cannon lol is offline
Send a message via AIM to noob cannon lol Send a message via MSN to noob cannon lol
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 16:30.


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