AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Vault Save/Load (https://forums.alliedmods.net/showthread.php?t=53707)

soccdoodcss 04-09-2007 14:21

Vault Save/Load
 
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
    
}



Dark Kingdom 04-10-2007 17:53

Re: Vault Save/Load
 
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?

pRED* 04-10-2007 18:13

Re: Vault Save/Load
 
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?

soccdoodcss 04-10-2007 22:24

Re: Vault Save/Load
 
Nope, but now that I think about it, it might be changing the authid to the LAN one because I'm testing on LAN.

pRED* 04-10-2007 22:59

Re: Vault Save/Load
 
lol if you're testing it on lan everyone will have the same authid..

soccdoodcss 04-11-2007 23:10

Re: Vault Save/Load
 
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.


All times are GMT -4. The time now is 06:40.

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