Raised This Month: $ Target: $400
 0% 

Save and Load Problems (nVault)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-25-2010 , 10:15   Save and Load Problems (nVault)
Reply With Quote #1

Alright, so here's the basic problem:

When there's no vault file, I can change the map, and it will work perfectly fine, but if someone kills someone, and it saves something to the vault, and I change the map, it crashes. What could possibly be the problem?

PHP Code:
public Save_Data(id)  
{  
    new 
AuthID[35
    
get_user_authid(id,AuthID,34
    
    new 
vaultkey[64], vaultdata[256
    
    if(
pub_Class[id] == WARRIOR)
    {
        
formatex(vaultkey,63,"%s-xp-%i-class",AuthIDWARRIOR)
    }
    else
    {
        
formatex(vaultkey,63,"%s-xp-%i-class",AuthIDASSASSIN);
    }
    
    
formatex(vaultdata254"%i#%i#%i#%i#%i#%i"pub_Stats[id][EXP], 
        
pub_Stats[id][LVL], pub_Stats[id][AGILITY], pub_Stats[id][TRANSPARENCY],
        
pub_Stats[id][STRENGTH], pub_Stats[id][HEALTH]
    );
    
    
nvault_set(g_Vaultvaultkeyvaultdata);
    
    
formatex(vaultkeycharsmax(vaultkey), "%s-stats"AuthID);
    
nvault_set(g_Vaultvaultkeypub_Stats[id][STATSCOUNT]);
}

public 
Load_Data(id

    new 
AuthID[35
    
get_user_authid(id,AuthID,34
    
    new 
vaultkey[64];
    
formatex(vaultkey,63,"%s-xp-%i-class",AuthIDpub_Class[id]) 
    
    new 
Data[256]
    
nvault_get(g_VaultvaultkeyDatacharsmax(Data));
    
replace_all(Datacharsmax(Data), "#"" ");
    
    new 
exp[10], lvl[10], agi[10], trans[10], str[10], health[10];
    
parse(Dataexpcharsmax(exp), lvlcharsmax(lvl), agicharsmax(agi),
        
transcharsmax(trans), strcharsmax(str), healthcharsmax(health)
    );
    
    
pub_Stats[id][EXP] = str_to_num(exp);
    
pub_Stats[id][LVL] = str_to_num(lvl);
    
pub_Stats[id][AGILITY] = str_to_num(agi);
    
pub_Stats[id][TRANSPARENCY] = str_to_num(trans);
    
pub_Stats[id][STRENGTH] = str_to_num(str);
    
pub_Stats[id][HEALTH] = str_to_num(health);
    
    
formatex(vaultkeycharsmax(vaultkey), "%s-stats"AuthID);
    
pub_Stats[id][STATSCOUNT] = nvault_get(g_Vaultvaultkey);

Some possibly useful information:
-The nVault is closed at plugin_end()
-The nVault only loads data when the person joins a team
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-25-2010 , 10:18   Re: Save and Load Problems (nVault)
Reply With Quote #2

nvault_set(g_Vault, vaultkey, pub_Stats[id][STATSCOUNT]);

Looks like here you are attempting to write an integer value? If so you must first convert to string.
__________________
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-25-2010 , 10:20   Re: Save and Load Problems (nVault)
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
nvault_set(g_Vault, vaultkey, pub_Stats[id][STATSCOUNT]);

Looks like here you are attempting to write an integer value? If so you must first convert to string.
Yes, it's an integer, thank you very much, I'll compile and try it.

PHP Code:
new Stats[63];
num_to_str(pub_Stats[id][STATSCOUNT], Statscharsmax(Stats) )
nvault_set(g_VaultvaultkeyStats); 
Correct?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-25-2010 , 10:24   Re: Save and Load Problems (nVault)
Reply With Quote #4

Yes, but the number cannot possibly be that big (62 digits), reduce the string size to a realistic number. If you still get errors then maybe your vault file is corrupt, try shutting down your server, delete vault file, and restart.
__________________

Last edited by Bugsy; 11-25-2010 at 10:29.
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-25-2010 , 10:52   Re: Save and Load Problems (nVault)
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Yes, but the number cannot possibly be that big (62 digits), reduce the string size to a realistic number. If you still get errors then maybe your vault file is corrupt, try shutting down your server, delete vault file, and restart.
Thats true. I was just keeping possibilities up, so if for any reason it got to a huge number like that, I wouldn't have problems.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 11-25-2010 at 11:11.
GXLZPGX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-25-2010 , 12:21   Re: Save and Load Problems (nVault)
Reply With Quote #6

You are limited to a 32-bit signed integer in Pawn (without considering any memory trickery) so the max number of digits you will encounter is 10, plus 1 to make room for the sign if negative plus one for null char so you can safely size the number string at 12.

Values storable in a 32-bit signed int are -2,147,483,647 to 2,147,483,647 which should be plenty.
__________________

Last edited by Bugsy; 11-25-2010 at 12:24.
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-25-2010 , 22:26   Re: Save and Load Problems (nVault)
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
You are limited to a 32-bit signed integer in Pawn (without considering any memory trickery) so the max number of digits you will encounter is 10, plus 1 to make room for the sign if negative plus one for null char so you can safely size the number string at 12.

Values storable in a 32-bit signed int are -2,147,483,647 to 2,147,483,647 which should be plenty.
More than plenty. Thank you!
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Reply


Thread Tools
Display Modes

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 11:17.


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