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(id, szAuthId[35])
{
new szVaultKey[64], szVaultData[256]
format(szVaultKey, charsmax(szVaultKey), "%s", szAuthId)
for(new i = 0; i < sizeof(g_szUpgrades) - 2; i += 3)
add(szVaultData, charsmax(szVaultData), "%i#", g_iUpgrades[id][i])
nvault_set(g_Vault, szVaultKey, szVaultData)
return PLUGIN_CONTINUE
}
LoadData(id)
{
new szAuthId[35], szVaultKey[64], szVaultData[256]
get_user_authid(id, szAuthId, charsmax(szAuthId))
format(szVaultKey, charsmax(szVaultKey), "%s", szAuthId)
for(new i = 0; i < sizeof(g_szUpgrades) - 2; i += 3)
add(szVaultData, charsmax(szVaultData), "%i#", g_iUpgrades[id][i])
nvault_get(g_Vault, szVaultKey, szVaultData, charsmax(szVaultData))
replace_all(szVaultData, charsmax(szVaultData), "#", " ")
/* The "fun" part starts here */
new szUpgrades[32]
for(new i = 0; i < sizeof(g_szUpgrades) - 2; i += 3)
{
parse(szVaultData, szUpgrades, 1)
g_iUpgrades[id][i] = str_to_num(szUpgrades[i])
}
/* This code doesn't work */
return PLUGIN_CONTINUE
}
PHP Code:
stock set_upgrade(id, iUpgrade)
g_iUpgrades[id][iUpgrade] = 1
stock is_upgraded(id, iUpgrade)
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?