AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nvault problem (https://forums.alliedmods.net/showthread.php?t=281935)

skz 04-24-2016 17:23

nvault problem
 
Hi guys,

Im doesnt use nvault for anything, but in this plugin im making i think is the best option because I work always with sqlx.

Im very noob at nvault, someone can help me? The first 2 variables save, but the last 2 dont

PHP Code:

public load(id)
{
    
pokevault nvault_open("lendas_data")
   
    new 
key[100], szAuthID[35]
   
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
formatex(keycharsmax(key),"%s-lendas"szAuthID)
   
    if(
nvault_get(pokevaultkey))
    {
        new 
vaultdata[250]
        
format(vaultdatacharsmax(vaultdata), "%i %i %i %i"g_Desligado[id], g_Som_Desligado[id],  g_Musica_desligada[id],  g_Dano[id])
        
nvault_get(pokevaultkeyvaultdatacharsmax(vaultdata))
       
        new 
disable[2], sdisable[2], ssom[2], sg_Dano[3]
       
        
parse(vaultdatadisablecharsmax(disable), sdisablecharsmax(sdisable), ssomcharsmax(ssom), sg_Danocharsmax(sg_Dano))
       
        new 
disablen str_to_num(disable)
        new 
sdisablen str_to_num(sdisable)
        new 
ssomn str_to_num(ssom)
        new 
sg_Danon str_to_num(sg_Dano)
       
        
g_Desligado[id] = disablen true false
        g_Som_Desligado
[id] = sdisablen true false
        g_Musica_desligada
[id] = ssomn truefalse
        g_Dano
[id] = sg_Danon
    
}
   
    
nvault_close(pokevault)
}
 
public 
save(id)
{
    
pokevault nvault_open("lendas_data")
   
    new 
key[62], vaultdata[250], szAuthID[35]
    
get_user_authid(idszAuthIDcharsmax(szAuthID))
    
format(key61,"%s-poke"szAuthID)
   
    
format(vaultdatacharsmax(vaultdata), "%i %i %i %i"g_Desligado[id] ? 0g_Som_Desligado[id] ? 0g_Musica_desligada[id] ? 0g_Dano[id])
    
nvault_set(pokevaultkeyvaultdata)
   
    
nvault_close(pokevault)
   
    
g_Desligado[id] = false
    g_Som_Desligado
[id] = false
    g_Musica_desligada
[id] = false
    g_Dano
[id] = 0



Syturi0 04-24-2016 22:44

Re: nvault problem
 
Your code is a total mess.

I recommend you to use fVault instead (https://forums.alliedmods.net/showthread.php?t=76453).
It has more features than nVault and its overall easier/simpler to use.
Also use global variables with values of 1/0 instead of true/false.

Here is an example using fVault:

LOAD
PHP Code:

new sSteamID[35]
get_user_authid(idsSteamIDcharsmax(sSteamID))

new 
sData[50]
fvault_get_data(g_FvaultsSteamIDsDatacharsmax(sData))

new 
sz1[2], sz2[2],
sz3[2], sz4[2],

parse(sData,
sz1charsmax(sz1),
sz2charsmax(sz2),
sz3charsmax(sz3),
sz3charsmax(sz3),
)

g_1[id] = str_to_num(sz1)
g_2[id] = str_to_num(sz2)
g_3[id] = str_to_num(sz3)
g_4[id] = str_to_num(sz4

SAVE
PHP Code:

new sSteamID[35]
get_user_authid(idsSteamIDcharsmax(sSteamID))

new 
sData[50]
formatex(sDatacharsmax(sData),
"%s %d %d %d",
g_1[id],
g_2[id], 
g_3[id],
g_4[id],
)

fvault_set_data(g_FvaultsSteamIDsData


fysiks 04-24-2016 22:59

Re: nvault problem
 
If you know how to use SQLx, why are you trying to use something else? SQLX is much more powerful than nvault.


All times are GMT -4. The time now is 12:09.

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