AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault help. (https://forums.alliedmods.net/showthread.php?t=129505)

Mandiii 06-13-2010 14:52

nVault help.
 
When someone dies their kills/deaths is stored in a vault.
PHP Code:

public client_death(killervictimwpnindexhitplaceTK)
{
    new 
szKills[4];
    new 
szDeaths[4];
    new 
szKey[40];
    new 
szKeyTwo[40];
    
    
formatex(szKey39"%sKILLS"g_szAuthID[killer]);
    
formatex(szKeyTwo39"%sDEATHS"g_szAuthID[victim]);
    
    
formatex(szKills3"%d"get_user_frags(killer));
    
formatex(szDeaths3"%d"get_user_deaths(victim));
    
    
nvault_set(g_VaultszKeyszKills);
    
nvault_set(g_VaultszKeyTwoszDeaths);


I get the values this way:
PHP Code:

    new szKey[40];
    
formatex(szKey39"%sKILLS"g_szAuthID[id]);
    new 
iKills nvault_get(g_VaultszKey); 

PHP Code:

    new szKey[40];
    
formatex(szKey39"%sDEATHS"g_szAuthID[id]);
    new 
iDeaths nvault_get(g_VaultszKey); 

How should i do to get both Deaths and Kills in the same function as seperate variables?

grimvh2 06-13-2010 14:58

Re: nVault help.
 
PHP Code:

// to save 
formatex(datasizeof(data)-1,"%i %i"killsdeaths)

// when loading
new kills[10],deaths[10]
new 
ikillsideaths
parse
(datakillssizeof(kills)-1deathssizeof(deaths)-1)

ikills str_to_num(kills)
ideaths str_to_num(deaths


Mandiii 06-13-2010 15:06

Re: nVault help.
 
Quote:

Originally Posted by grimvh2 (Post 1207805)
PHP Code:

// to save 
formatex(datasizeof(data)-1,"%i %i"killsdeaths)

// when loading
new kills[10],deaths[10]
new 
ikillsideaths
parse
(datakillssizeof(kills)-1deathssizeof(deaths)-1)

ikills str_to_num(kills)
ideaths str_to_num(deaths


So if i just put it like this then it will work?
PHP Code:

public cmdGetDeathsNKills(id)
{
    new 
kills[10],deaths[10]
    new 
ikillsideaths
    parse
(datakillssizeof(kills)-1deathssizeof(deaths)-1)

    
ikills str_to_num(kills)
    
ideaths str_to_num(deaths)
    
    
client_print(idprint_chat"You have %d kills and %d deaths"ikillsideaths)



grimvh2 06-13-2010 15:20

Re: nVault help.
 
U still gotta use nvault lal, only gave u an example of how u should load and save ur datas.
and I dont see why u need 2 keys for kills and deaths. U can easely put it into 1 key.

Mandiii 06-13-2010 15:24

Re: nVault help.
 
Quote:

Originally Posted by grimvh2 (Post 1207833)
U still gotta use nvault lal, only gave u an example of how u should load and save ur datas.
and I dont see why u need 2 keys for kills and deaths. U can easely put it into 1 key.

Could you give me a fully working example then? Preferrebly compatible with my approach.

grimvh2 06-13-2010 15:41

Re: nVault help.
 
PHP Code:

// save
new szData[64], szAuthid[32]
get_user_authid(idszAuthidsizeof(szAuthid)-1)

formatex(szDatasizeof(szData)-1,"%i %i"get_user_frags(id), cs_get_user_deaths(id))

nvault_set(g_VaultszAuthidszData); 

//load

new szData[64], szAuthid[32], szKills[10], szDeaths[10], kills,deaths
get_user_authid
(idszAuthidsizeof(szAuthid)-1)
nvault_get(g_VaultszAuthidszData); 

parse(szDataszKills9szDeaths9)

kills str_to_num(szKills)
deaths str_to_num(szDeaths

Get it now? (didnt test that so might have typos)
Note : i prefer using fvault (from exolents tut)

Mandiii 06-13-2010 15:44

Re: nVault help.
 
EDIT: Saw that you edited it now.


All times are GMT -4. The time now is 14:52.

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