Raised This Month: $ Target: $400
 0% 

Vault Save/Load


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
soccdoodcss
Veteran Member
Join Date: Nov 2006
Location: Wisconsin
Old 04-09-2007 , 14:21   Vault Save/Load
Reply With Quote #1

I need to save and load data by authid and name.

PHP Code:
public save_xp(id)
{
    new 
authid[35]
    
get_user_authid(id,authid,34)
    
    new 
name[35]
    
get_user_name(id,name,34)
    
    new 
vaultkey[64],vaultdata[96]
    
formatex(vaultkey,63,"%s-%s-SSTATS",authid,name)
    
formatex(vaultdata,95,"%i#%i",kills[id],deaths[id])
    
set_vaultdata(vaultkey,vaultdata)

The save seems to work as I can see it in my vault file. However the following which is the loading process doesn't seem to be working... any ideas? Thanks in advance.

PHP Code:
public load_xp(id)
{
    new 
authid[35]
    
get_user_authid(id,authid,34)
    
    new 
name[35]
    
get_user_name(id,name,34)
    new 
vaultkey[64],vaultdata[96]
    
formatex(vaultkey,63,"%s-%s-SSTATS",authid,name)
    if(
vaultdata_exists(vaultkey))
    {
        
get_vaultdata(vaultkey,vaultdata,95)
        
replace_all(vaultdata,95,"#"," ")
        new 
pre_kills[8],pre_deaths[8]
        
parse(vaultdata,pre_kills,7,pre_deaths,7)
        
kills[id]=str_to_num(pre_kills)
        
deaths[id]=str_to_num(pre_deaths)
    }
    else
    {
        
kills[id]=0
        deaths
[id]=0
    
}

__________________
"Now safe beneath their wisdom and their feet.
Here I will teach you truly how to sleep."
soccdoodcss is offline
Send a message via AIM to soccdoodcss
Dark Kingdom
BANNED
Join Date: Apr 2007
Location: VT
Old 04-10-2007 , 17:53   Re: Vault Save/Load
Reply With Quote #2

PHP Code:
public SaveXP(id)
{
    new 
authid[32]; 
    
get_user_authid(id,authid,31); 
    
    new 
vaultkey[64], vaultdata[64]; 
    
    
format(vaultkey,63,"",authid
    
format(vaultdata,63,"%",currentscore[id]) 
    
set_vaultdata(vaultkey,vaultdata
    
    
format(vaultkey,63,"",authid
    
format(vaultdata,63,"",currentdeaths[id]) 
    
set_vaultdata(vaultkey,vaultdata


public 
LoadXP(id)
{
    new 
authid[32]; 
    
get_user_authid(id,authid,31); 
    
    new 
vaultkey[64], vaultdata[64]; 
    
    
format(vaultkey,63,"",authid
    
get_vaultdata(vaultkey,vaultdata,63)
    
score[id] = str_to_num(vaultdata)
    
    
format(vaultkey,63,"",authid
    
get_vaultdata(vaultkey,vaultdata,63
    
deaths[id] = str_to_num(vaultdata)     

Something like this?
Dark Kingdom is offline
pRED*
Join Date: Dec 2006
Old 04-10-2007 , 18:13   Re: Vault Save/Load
Reply With Quote #3

No his way is much more efficient than having two separate vault load and saves.

I would also recommend using nvault (its part of core..) because it's faster again..

As for the problem.. No clue. Everything looks fine to me. Are you getting any compile or logged errors?
pRED* is offline
soccdoodcss
Veteran Member
Join Date: Nov 2006
Location: Wisconsin
Old 04-10-2007 , 22:24   Re: Vault Save/Load
Reply With Quote #4

Nope, but now that I think about it, it might be changing the authid to the LAN one because I'm testing on LAN.
__________________
"Now safe beneath their wisdom and their feet.
Here I will teach you truly how to sleep."
soccdoodcss is offline
Send a message via AIM to soccdoodcss
pRED*
Join Date: Dec 2006
Old 04-10-2007 , 22:59   Re: Vault Save/Load
Reply With Quote #5

lol if you're testing it on lan everyone will have the same authid..
pRED* is offline
soccdoodcss
Veteran Member
Join Date: Nov 2006
Location: Wisconsin
Old 04-11-2007 , 23:10   Re: Vault Save/Load
Reply With Quote #6

Which is why I saved by name too

EDIT: Although not in this version... I have another one with names too, but still doesn't work.
__________________
"Now safe beneath their wisdom and their feet.
Here I will teach you truly how to sleep."
soccdoodcss is offline
Send a message via AIM to soccdoodcss
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 06:40.


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