hey
i need you guys to show me what's the best method to store local info for it to be retrieved after map change or server restart
for example with nvault, fvault, etc
since i have little to no knowledge about this please post and amxx script as an example so i can understand easier
the data i need to store is the following:
PHP Code:
g_zombieclassnext[id]
g_humanclassnext[id]
g_ammopacks[id]
also i've got some code which stores the data until map change
maybe it will come in handy...please help
PHP Code:
// Temporary Database vars (used to restore players stats in case they get disconnected)
new db_name[MAX_STATS_SAVED][32] // player name
new db_ammopacks[MAX_STATS_SAVED] // ammo pack count
new db_zombieclass[MAX_STATS_SAVED] // zombie class
new db_slot_i // additional saved slots counter (should start on maxplayers+1)
new db_humanclass[MAX_STATS_SAVED] // human class
// Save player's stats to database
save_stats(id)
{
// Check whether there is another record already in that slot
if (db_name[id][0] && !equal(g_playername[id], db_name[id]))
{
// If DB size is exceeded, write over old records
if (db_slot_i >= sizeof db_name)
db_slot_i = g_maxplayers+1
// Move previous record onto an additional save slot
copy(db_name[db_slot_i], charsmax(db_name[]), db_name[id])
db_ammopacks[db_slot_i] = db_ammopacks[id]
db_zombieclass[db_slot_i] = db_zombieclass[id]
db_humanclass[db_slot_i] = db_humanclass[id]
db_slot_i++
}
// Now save the current player stats
copy(db_name[id], charsmax(db_name[]), g_playername[id]) // name
db_ammopacks[id] = g_ammopacks[id] // ammo packs
db_zombieclass[id] = g_zombieclassnext[id] // zombie class
db_humanclass[id] = g_humanclassnext[id] // human class
}
// Load player's stats from database (if a record is found)
load_stats(id)
{
// Look for a matching record
static i
for (i = 0; i < sizeof db_name; i++)
{
if (equal(g_playername[id], db_name[i]))
{
// Bingo!
g_ammopacks[id] = db_ammopacks[i]
g_zombieclass[id] = db_zombieclass[i]
g_zombieclassnext[id] = db_zombieclass[i]
g_humanclass[id] = db_humanclass[i]
g_humanclassnext[id] = db_humanclass[i]
return;
}
}
}
__________________