Raised This Month: $ Target: $400
 0% 

[SOLVED] Saving upgrades with nVault


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-25-2015 , 11:00   [SOLVED] Saving upgrades with nVault
Reply With Quote #1

I'm trying to save the player's upgrades with nVault.

PHP Code:
new g_iUpgrades[33][33
PHP Code:
new const g_szUpgrades[][] = {
    
"Increase Alien Speed""2130""Your ^3Alien running speed ^1is now ^4increased",
    
"Additional Alien Health""2650""You will now get more ^3health points ^1as an ^4Alien",
    
"Additional predator Health""3200""You will now get more ^3health points ^1as a ^4Predator",
    
"Decrease Scream Cooldown""750""You can now ^3scream ^1more often",
    
"Unlock Ultra Classes""5000""You now have access to the ^3Ultra Classes^1"

PHP Code:
public SaveData(idszAuthId[35])
{
    new 
szVaultKey[64], szVaultData[256]
    
format(szVaultKeycharsmax(szVaultKey), "%s"szAuthId)
    
    for(new 
0sizeof(g_szUpgrades) - 2+= 3)
        
add(szVaultDatacharsmax(szVaultData), "%i#"g_iUpgrades[id][i])
    
    
nvault_set(g_VaultszVaultKeyszVaultData)
    return 
PLUGIN_CONTINUE
}

LoadData(id)
{
    new 
szAuthId[35], szVaultKey[64], szVaultData[256]
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
format(szVaultKeycharsmax(szVaultKey), "%s"szAuthId)
    
    for(new 
0sizeof(g_szUpgrades) - 2+= 3)
        
add(szVaultDatacharsmax(szVaultData), "%i#"g_iUpgrades[id][i])
    
    
nvault_get(g_VaultszVaultKeyszVaultDatacharsmax(szVaultData))
    
replace_all(szVaultDatacharsmax(szVaultData), "#"" ")
    
    
/* The "fun" part starts here */
    
new szUpgrades[32]
    
    for(new 
0sizeof(g_szUpgrades) - 2+= 3)
    {
        
parse(szVaultDataszUpgrades1)
        
g_iUpgrades[id][i] = str_to_num(szUpgrades[i])
    }
    
/* This code doesn't work */
    
    
return PLUGIN_CONTINUE

PHP Code:
stock set_upgrade(idiUpgrade)
    
g_iUpgrades[id][iUpgrade] = 1

stock is_upgraded
(idiUpgrade)
    return 
g_iUpgrades[id][iUpgrade
I'm used to saving things with only one number, but I have no idea how to save a value that has two arrays - g_iUpgrades[id][iUpgrade]. The "iUpgrade" is the upgrade's ID, according to "g_szUpgrades", so it can be 0, 3, 6, 9, 12... Is this even a good way of saving the upgrades?

Last edited by OciXCrom; 10-27-2015 at 15:43.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
 


Thread Tools
Display Modes

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 22:14.


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