You are not showing your full code so we cannot see if you are opening your vault like you need to be. That appears to be the cause of your error. Please use php tags when posting code, and indent your code.
Add at plugin_init()
PHP Code:
g_vault = nvault_open( "vaultname" )
__________________