This is the procedure (This one is for Levels System, same can be applied to Coins System)
Can't provide the whole source because I've modified alot in the code which may affect your gameplay or trigger errors on your server. That's very enough to fix the original one.
Code: Select all
public LoadData(id)
{
new szData[256], szDataXp[256], szName[32], key[64], key_xp[64]
get_user_name(id, szName, charsmax(szName)) // In my server I save data for Names, Edit this if you use AuthID
format(key, 63, "%s-/", szName)
format(key_xp, 63, "%s-/", szName)
nvault_get(g_szVaultLevel, key, szData, 255)
nvault_get(g_szVaultXP, key_xp, szDataXp, 255)
replace_all(szData, 255, "#", " ")
replace_all(szDataXp, 255, "#", " ")
new givelevel[32], give_exp[32]
parse(szData, givelevel, 31)
parse(szDataXp, give_exp, 31)
g_iLevel[id] = str_to_num(givelevel)
g_iXP[id] = str_to_num(give_exp)
return PLUGIN_CONTINUE
}
public SaveData(id)
{
new szAuthID[32]
get_user_name(id, szAuthID, charsmax(szAuthID)) // In my server I save data for Names, Edit this if you use AuthID
new szData[256], szDataXp[256], key[64], key_xp[64]
format(key, 63, "%s-/", szAuthID)
format(szData, 255, "%i#", g_iLevel[id])
format(key_xp, 63, "%s-/", szAuthID)
format(szDataXp, 255, "%i#", g_iXP[id])
nvault_set(g_szVaultLevel, key, szData)
nvault_set(g_szVaultXP, key_xp, szDataXp)
return PLUGIN_CONTINUE;
}