AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved nvault_util doesn't work :/ (https://forums.alliedmods.net/showthread.php?t=293933)

yas17sin 02-15-2017 08:17

nvault_util doesn't work :/
 
hi i need help with nvault_util it's set to save per steam id but it save but i think he can't load or something like that please help me.

P.S : i need to change to save per names if someone can do it.

Code :
PHP Code:

#include <nvault_util>

public plugin_init()
{
    new 
g_iVault nvault_open("Level-System");
    
    if ( 
g_iVault == INVALID_HANDLE )
    
set_fail_state"Error opening nVault" );
}
public 
plugin_end() 
    
nvault_close(g_iVault);

stock Save(id)
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle");
    
    new 
szAuthId[35]; 
    
get_user_authid(idszAuthIdcharsmax(szAuthId));
    
    new 
szName[32]; 
    
get_user_name(idszNamecharsmax(szName));
    
    new 
szData[256];
    
formatex(szDatacharsmax(szData), "%i %i"g_iXp[id], g_iLevel[id]);
    
    
nvault_remove(g_iVaultszAuthId);
    
nvault_set(g_iVaultszAuthIdszData);
        
    
format(szAuthIdcharsmax(szAuthId), "%s"szAuthId);
    
nvault_remove(g_iVaultszAuthId);
    
nvault_set(g_iVaultszAuthIdszName);
}

stock Load(id)
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle");
        
    new 
szSavedName[32];
    new 
szName[32]; get_user_name(idszNamecharsmax(szName));
    new 
szAuthId[32]; get_user_authid(idszAuthIdcharsmax(szAuthId));
    
    new 
szData[256], iTimeStamp;
    if(!
nvault_lookup(g_iVaultszAuthIdszDatacharsmax(szData), iTimeStamp))
    {
        
nvault_set(g_iVaultszAuthId"0");
        
        
format(szAuthIdcharsmax(szAuthId), "%s"szAuthId);
        
nvault_set(g_iVaultszAuthIdszName);
        
        return 
PLUGIN_HANDLED;
    }
    
    
ParseLoadData(idszData);
    
    
format(szAuthIdcharsmax(szAuthId), "%s"szAuthId);
    
nvault_get(g_iVaultszAuthIdszSavedName);
    
    if(!
equal(szNameszSavedName))
    {
        
nvault_remove(g_iVaultszAuthId);
        
nvault_set(g_iVaultszAuthIdszName);
    }
    return 
PLUGIN_HANDLED;
}
ParseLoadData(idszData[256])
{
    static 
szNum[11];
    
strbreak(szDataszNumcharsmax(szNum), szDatacharsmax(szData));
    
g_iXp[id] = str_to_num(szNum);
    
    
strbreak(szDataszNumcharsmax(szNum), szDatacharsmax(szData));
    
g_iLevel[id] = str_to_num(szNum);
}
public 
client_disconnect(id)
{
    
Save(id);
    return 
PLUGIN_HANDLED;
}
public 
client_putinserver(id)
{
    
Load(id);
    return 
PLUGIN_HANDLED;


Please any help would be great.
Thanks.

Natsheh 02-15-2017 14:09

Re: nvault_util doesn't work :/
 
BeCause the g_iVault isnt a global variable


Please read about the pawn language

yas17sin 02-15-2017 16:25

Re: nvault_util doesn't work :/
 
so can you fix it. :/

yeah know i am still learning.

Natsheh 02-15-2017 16:39

Re: nvault_util doesn't work :/
 
PHP Code:

#include <nvault>
new g_iVault // i just created a global variable
public plugin_init()
{
    
g_iVault nvault_open("Level-System");
    
    if ( 
g_iVault == INVALID_HANDLE )
                
set_fail_state"Error opening nVault" );
}
public 
plugin_end() 
    
nvault_close(g_iVault);

Save(id)
{
    new 
szAuthId[32]; 
    
get_user_authid(idszAuthIdcharsmax(szAuthId));
    
    new 
szName[32]; 
    
get_user_name(idszNamecharsmax(szName));
    
    new 
szData[200];
    
formatex(szDatacharsmax(szData), "^"%s^" ^"%i^" ^"%i^""szNameg_iXp[id], g_iLevel[id]);
    
    
//nvault_remove(g_iVault, szAuthId);
    
nvault_set(g_iVaultszAuthIdszData);
        
    
//format(szAuthId, charsmax(szAuthId), "%s", szAuthId);
    //nvault_remove(g_iVault, szAuthId);
    //nvault_set(g_iVault, szAuthId, szName);
}

Load(id)
{   
    new 
szAuthId[32]; get_user_authid(idszAuthIdcharsmax(szAuthId));
    
    new 
szData[200], iTimeStamp;
    if(
nvault_lookup(g_iVaultszAuthIdszDatacharsmax(szData), iTimeStamp))
    {
              new 
szSavedname[32], szXp[16], szLevel[16];
              
parse(szDataszSavednamecharsmax(szSavedname), szXpcharsmax(szXp), szLevelcharsmax(szLevel))
              
remove_quotes(szSavedname)
              
remove_quotes(szXp)
              
remove_quotes(szLevel)
              
set_user_info(id"name"szSavedname)
              
g_iXp[id] = str_to_num(szXp)
              
g_iLevel[id] = str_to_num(szLevel)
     }
}


public 
client_disconnect(id)
{
    
Save(id);
}

public 
client_putinserver(id)
{
    
Load(id);



yas17sin 02-15-2017 16:54

Re: nvault_util doesn't work :/
 
it still not working it save and i think there is a prob with load.

Natsheh 02-15-2017 17:26

Re: nvault_util doesn't work :/
 
Check the edit

PS : i fixed it on the phone

Bugsy 02-15-2017 18:17

Re: nvault_util doesn't work :/
 
This has nothing to do with nVault Utility either. This is nVault module stuff.

Natsheh 02-15-2017 18:19

Re: nvault_util doesn't work :/
 
i never read the file :P idk the differences

Bugsy 02-15-2017 18:47

Re: nvault_util doesn't work :/
 
Quote:

Originally Posted by Natsheh (Post 2495732)
i never read the file :P idk the differences

Your help was good, it's the OP that my post was directed towards.

yas17sin 02-16-2017 08:56

Re: nvault_util doesn't work :/
 
Thanks you so much Natsheh.

but there is one problem if somee player join and he have long name with spaces his name change for only his first word like :

"my name is" then the name automatic change to the first word "my".

can you fix this please


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

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