Raised This Month: $51 Target: $400
 12% 

Solved nvault_util doesn't work :/


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-15-2017 , 08:17   nvault_util doesn't work :/
Reply With Quote #1

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.

Last edited by yas17sin; 02-18-2017 at 22:22.
yas17sin is offline
Send a message via ICQ to yas17sin
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-15-2017 , 14:09   Re: nvault_util doesn't work :/
Reply With Quote #2

BeCause the g_iVault isnt a global variable


Please read about the pawn language
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-15-2017 at 14:10.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-15-2017 , 16:25   Re: nvault_util doesn't work :/
Reply With Quote #3

so can you fix it. :/

yeah know i am still learning.
yas17sin is offline
Send a message via ICQ to yas17sin
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-15-2017 , 16:39   Re: nvault_util doesn't work :/
Reply With Quote #4

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);

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-15-2017 at 18:21.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-15-2017 , 16:54   Re: nvault_util doesn't work :/
Reply With Quote #5

it still not working it save and i think there is a prob with load.

Last edited by yas17sin; 02-15-2017 at 16:54.
yas17sin is offline
Send a message via ICQ to yas17sin
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-15-2017 , 17:26   Re: nvault_util doesn't work :/
Reply With Quote #6

Check the edit

PS : i fixed it on the phone
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-15-2017 at 17:44.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-15-2017 , 18:17   Re: nvault_util doesn't work :/
Reply With Quote #7

This has nothing to do with nVault Utility either. This is nVault module stuff.
__________________
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-15-2017 , 18:19   Re: nvault_util doesn't work :/
Reply With Quote #8

i never read the file idk the differences
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-15-2017 , 18:47   Re: nvault_util doesn't work :/
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
i never read the file idk the differences
Your help was good, it's the OP that my post was directed towards.
__________________
Bugsy is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 02-16-2017 , 08:56   Re: nvault_util doesn't work :/
Reply With Quote #10

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

Last edited by yas17sin; 02-16-2017 at 08:58.
yas17sin is offline
Send a message via ICQ to yas17sin
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 07:30.


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