This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Problem with nVault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 06:03   Problem with nVault
Reply With Quote #1

Hello,
I use nvault and I took this code(below) for save level and xp but I have a problem with code...

Problem: When I start play and XP & Level = 0 all is ok and when I make retry all is ok, but when I have XP>0 & Level>0 and make retry the code stops work and appear console problems

Console Problems: Look


Spoiler


I check my modules and there is nVault...
I think there is a problem in this code above. Can u fix it?

EDIT: I want code without say debug in plugins.ini

Last edited by tcPane; 08-19-2012 at 06:04.
tcPane is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2012 , 06:51   Re: Problem with nVault
Reply With Quote #2

format(VaultData, 255, "%i#%i#", PlayerXP[id], PlayerLevel[id])

Why is that line there ?



Edit :

Following code should work, use Hungarian notation for clarity, because the code you were using was not clear about integers arrays and strings arrays, though it was understandable enough :

PHP Code:
#include <amxmodx>
#include <nvault>

new g_szAuthid33 ][ 32 ]
new 
g_nVault

new g_iPlayerXP33 ]
new 
g_iPlayerLevel33 ]

public 
plugin_init()
{
    
g_nVault nvault_open"vault_name" )
}

public 
plugin_end()
{
    
nvault_closeg_nVault )
}

public 
client_authorizedid )
{
    
get_user_authid(idg_szAuthidid ], charsmaxg_szAuthid[] ) )
    
Load_Dataid )
}

public 
client_disconnectid )
{
    if( 
g_szAuthidid ][ ] )
    {
        
Save_Dataid )
        
g_szAuthidid ][ ] = EOS
    
}
}

Load_Data(id)
{
    new 
szVaultData[32], szPlaye_XP[12], szPlayerLevel[12];

    if( 
nvault_get(g_nVaultg_szAuthidid ], szVaultDatacharsmax(szVaultData)) )
    {

        
parse(szVaultDataszPlaye_XPcharsmax(szPlaye_XP), szPlayerLevelcharsmax(szPlayerLevel));

        
g_iPlayerXP[id] = str_to_num(szPlaye_XP);
        
g_iPlayerLevel[id] = str_to_num(szPlayerLevel);
        return 
1;
    }

    
g_iPlayerXP[id] = g_iPlayerLevel[id] = 0;
    return 
0;
}

Save_Data(id)
{
    new 
szVaultData[32]
    
formatex(szVaultDatacharsmax(szVaultData), "%d %d"g_iPlayerXP[id], g_iPlayerLevel[id]);
    
nvault_set(g_nVaultg_szAuthidid ], szVaultData);

    return 
1;

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-19-2012 at 08:58.
ConnorMcLeod is offline
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 07:42   Re: Problem with nVault
Reply With Quote #3

I can't understand enough this code, but can u make me cvar which can change type of save:

save_type 1-nick;2-ip;3-steamid
tcPane is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2012 , 07:59   Re: Problem with nVault
Reply With Quote #4

No, steamid is the best you can use for that kind of stuff, ip is not reliable in case few players play from the same place, and name is not reliable at all since any player can use any name.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 08:44   Re: Problem with nVault
Reply With Quote #5

Ok thank you. Also can u explain me for what is "return(0);(1)" function? Instead return PLUGIN_HANDLED?
tcPane is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2012 , 09:00   Re: Problem with nVault
Reply With Quote #6

I had forgotten 1 return, fixed.

There is no reason to use PLUGIN_CONTINUE and PLUGIN_HANDLED returns because it is not a forward or a callback routine, so, return 1 on save success, and if something has been loaded, if there was no entry, return 0, anyway you can completely remove the return values, just keep the 1st return in Load_Data with no value.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 09:11   Re: Problem with nVault
Reply With Quote #7

I cant understand that with returns. Can u give me other simple code for example?
tcPane is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-19-2012 , 09:20   Re: Problem with nVault
Reply With Quote #8

PHP Code:
is_user_idiotid )
{
    new 
name[32]
    
get_user_name(idnamecharsmax(name))
    if( 
containi(name"napoleon") != -)
    {
        return 
1
    
}
    return 
0


You don't expect this from returning CONTINUE or HANDLED, 0 or 1 is more clear about result.


About engine forward client_kill for example :

It is more clear to use HANDLED and CONTINUE so you know which block and which let continue the thing.
PHP Code:
public client_killid )
{
    new 
name[32]
    
get_user_name(idnamecharsmax(name))
    if( 
containi(name"napoleon") == -)
    {
        
client_print(idprint_chat"Suicide yourself would be stupid !!")
        return 
PLUGIN_HANDLED // return 1 wouldn't be so readable
    
}
    
client_print(idprint_chat"What a nice idea !!")
    return 
PLUGIN_CONTINUE // return 0 wouldn't be so readable

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-19-2012 at 09:20.
ConnorMcLeod is offline
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 09:26   Re: Problem with nVault
Reply With Quote #9

All is okay, thank you
tcPane is offline
tcPane
Senior Member
Join Date: Sep 2010
Old 08-19-2012 , 11:10   Re: Problem with nVault
Reply With Quote #10

Sorry for doubleposting, but for 1st time I see g_szAuthid[ id ][ 0 ] = EOS
for what is EOS and what it mean?
tcPane is offline
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:19.


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