Raised This Month: $ Target: $400
 0% 

Saving data problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 02-07-2010 , 07:45   Saving data problem
Reply With Quote #1

It must print in end of the file '0 0#' but it prints '#0 0 0 0 0#0'
I tested this with Nvault Editor.
PHP Code:
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d#",  g_iPlayerPotions[id][hero_id][iPotions], g_iPlayerPotionsInv[id][hero_id][iPotions] ) 

PHP Code:
Save_Data(id)
{
    new 
szKey[66];
    
Save_GetKeyidszKeycharsmaxszKey ) );

    new 
iLen 0;
    static 
szData[30000];
    
    
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d#"g_PlayerChars[id], g_CurrentMana[id] );

    for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
    {
        
iLen += formatex szDataiLen ], charsmax(szData) - iLen"%d %d %d %d %d %d %d %d %d %d %d %d#"g_PlayerLevel[id][hero_id], g_PlayerXp[id][hero_id], g_PlayerSkPoints[id][hero_id], g_PlayerStPoints[id][hero_id], g_Strength[id][hero_id], g_Dexterity[id][hero_id], g_Vitality[id][hero_id], g_Energy[id][hero_id], 
        
g_Coins[id][hero_id], g_CoinsInv[id][hero_id], g_PlayerHero[id][hero_id], g_PlayerCharActive[id][hero_id] )
    }    
    for( new 
iSkill 0iSkill <= g_skillcounteriSkill++ ) 
    {
        for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
        {
            
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d#"g_iSkills[id][hero_id][iSkill] );
        }    
    }
    for( new 
iItems 0iItems <= g_charcounter iItems++ )
    {
        for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
        {
            
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d %d %d %d#",  g_iPlayerItem[id][hero_id][iItems], g_iPlayerItemInv[id][hero_id][iItems], g_iPlayerItemBolts[id][hero_id][iItems], 
            
g_iPlayerItemWorn[id][hero_id][iItems], g_iPlayerItemRepair[id][hero_id][iItems] )
        }
    }
    for( new 
iPotions 0iPotions MAX_POTIONS iPotions++ )
    {
        for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
        {
            
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d#",  g_iPlayerPotions[id][hero_id][iPotions], g_iPlayerPotionsInv[id][hero_id][iPotions] )
        }    
    }
    
    
nvault_setg_NvaultszKeyszData );

__________________
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-07-2010 , 09:34   Re: Saving data problem
Reply With Quote #2

Quote:
Originally Posted by xbatista View Post
It must print in end of the file '0 0#' but it prints '#0 0 0 0 0#0'
I'm a bit confused, are you saying you are only supposed to be saving "0 0#" but "#0 0 0 0 0#0" is getting saved? Or are you just referring to the end portion "0#" vs "0#0"?

See if the below works or you can just trim off the trailing zero if you can confirm it isn't storing any data.

PHP Code:
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d%s",  g_iPlayerPotions[id][hero_id][iPotions], g_iPlayerPotionsInv[id][hero_id][iPotions] , "#" 
__________________
Bugsy is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 02-07-2010 , 09:38   Re: Saving data problem
Reply With Quote #3

I mean at the end of the vault file is '#0 0 0 0 0#0' , why not '0 0#' ?
In my code is '%d %d#' at the end of iLen
__________________

Last edited by xbatista; 02-07-2010 at 09:42.
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-07-2010 , 09:41   Re: Saving data problem
Reply With Quote #4

Before saving, make sure a number is stored in the very last-written g_iPlayerPotionsInv[id][hero_id][iPotions] and see if that ends up in your vault entry.
__________________
Bugsy is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 02-07-2010 , 09:45   Re: Saving data problem
Reply With Quote #5

Yes it's stored

EDIT : End of entry
Attached Thumbnails
Click image for larger version

Name:	valut.jpg
Views:	173
Size:	28.3 KB
ID:	59251  
__________________

Last edited by xbatista; 02-07-2010 at 09:50.
xbatista is offline
Send a message via Skype™ to xbatista
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-07-2010 , 10:07   Re: Saving data problem
Reply With Quote #6

Try using a delimiter other then # and see if you get the same result.
__________________
Bugsy is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 02-07-2010 , 10:08   Re: Saving data problem
Reply With Quote #7

Try this and see if the end is still incorrect. Maybe there is some length limit and it's cutting off some part of the string.
PHP Code:
Save_Data(id)
{
    new 
szKey[66];
    
Save_GetKeyidszKeycharsmaxszKey ) );

    new 
iLen 0;
    static 
szData[30000];
    
/*
    iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d %d#", g_PlayerChars[id], g_CurrentMana[id] );
     
    for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
    {
        iLen += formatex ( szData[ iLen ], charsmax(szData) - iLen, "%d %d %d %d %d %d %d %d %d %d %d %d#", g_PlayerLevel[id][hero_id], g_PlayerXp[id][hero_id], g_PlayerSkPoints[id][hero_id], g_PlayerStPoints[id][hero_id], g_Strength[id][hero_id], g_Dexterity[id][hero_id], g_Vitality[id][hero_id], g_Energy[id][hero_id], 
        g_Coins[id][hero_id], g_CoinsInv[id][hero_id], g_PlayerHero[id][hero_id], g_PlayerCharActive[id][hero_id] )
    }    
    for( new iSkill = 0; iSkill <= g_skillcounter; iSkill++ ) 
    {
        for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
        {
            iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d#", g_iSkills[id][hero_id][iSkill] );
        }    
    }
    for( new iItems = 0; iItems <= g_charcounter ; iItems++ )
    {
        for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
        {
            iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d %d %d %d %d#",  g_iPlayerItem[id][hero_id][iItems], g_iPlayerItemInv[id][hero_id][iItems], g_iPlayerItemBolts[id][hero_id][iItems], 
            g_iPlayerItemWorn[id][hero_id][iItems], g_iPlayerItemRepair[id][hero_id][iItems] )
        }
    }*/
    
for( new iPotions 0iPotions MAX_POTIONS iPotions++ )
    {
        for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
        {
            
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d#",  g_iPlayerPotions[id][hero_id][iPotions], g_iPlayerPotionsInv[id][hero_id][iPotions] )
        }    
    }
    
    
nvault_setg_NvaultszKeyszData );

__________________
Impossible is Nothing
Sylwester is offline
Old 02-07-2010, 10:13
Bugsy
This message has been deleted by Bugsy. Reason: nm
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 02-07-2010 , 10:14   Re: Saving data problem
Reply With Quote #8

Quote:
Originally Posted by Sylwester View Post
Try this and see if the end is still incorrect. Maybe there is some length limit and it's cutting off some part of the string.
PHP Code:
Save_Data(id)
{
    new 
szKey[66];
    
Save_GetKeyidszKeycharsmaxszKey ) );

    new 
iLen 0;
    static 
szData[30000];
    
/*
    iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d %d#", g_PlayerChars[id], g_CurrentMana[id] );
     
    for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
    {
        iLen += formatex ( szData[ iLen ], charsmax(szData) - iLen, "%d %d %d %d %d %d %d %d %d %d %d %d#", g_PlayerLevel[id][hero_id], g_PlayerXp[id][hero_id], g_PlayerSkPoints[id][hero_id], g_PlayerStPoints[id][hero_id], g_Strength[id][hero_id], g_Dexterity[id][hero_id], g_Vitality[id][hero_id], g_Energy[id][hero_id], 
        g_Coins[id][hero_id], g_CoinsInv[id][hero_id], g_PlayerHero[id][hero_id], g_PlayerCharActive[id][hero_id] )
    }    
    for( new iSkill = 0; iSkill <= g_skillcounter; iSkill++ ) 
    {
        for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
        {
            iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d#", g_iSkills[id][hero_id][iSkill] );
        }    
    }
    for( new iItems = 0; iItems <= g_charcounter ; iItems++ )
    {
        for(new hero_id = 0; hero_id < MAX_CHARS + 1 ; hero_id++)
        {
            iLen += formatex( szData[ iLen ], charsmax(szData) - iLen, "%d %d %d %d %d#",  g_iPlayerItem[id][hero_id][iItems], g_iPlayerItemInv[id][hero_id][iItems], g_iPlayerItemBolts[id][hero_id][iItems], 
            g_iPlayerItemWorn[id][hero_id][iItems], g_iPlayerItemRepair[id][hero_id][iItems] )
        }
    }*/
    
for( new iPotions 0iPotions MAX_POTIONS iPotions++ )
    {
        for(new 
hero_id 0hero_id MAX_CHARS hero_id++)
        {
            
iLen += formatexszDataiLen ], charsmax(szData) - iLen"%d %d#",  g_iPlayerPotions[id][hero_id][iPotions], g_iPlayerPotionsInv[id][hero_id][iPotions] )
        }    
    }
    
    
nvault_setg_NvaultszKeyszData );

So what I must do now? ^^
Attached Thumbnails
Click image for larger version

Name:	vault2.jpg
Views:	131
Size:	20.9 KB
ID:	59252  
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-07-2010 , 10:14   Re: Saving data problem
Reply With Quote #9

static szData[30000];
wtf ? O_o"
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 02-07-2010 , 10:19   Re: Saving data problem
Reply With Quote #10

Quote:
Originally Posted by xPaw View Post
static szData[30000];
wtf ? O_o"
What? ^^
You said that if I'll use 'new' it will print error in log, btw I use this to save large data
__________________
xbatista is offline
Send a message via Skype™ to xbatista
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:20.


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