Raised This Month: $ Target: $400
 0% 

best way to store local info?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-29-2011 , 18:55   best way to store local info?
Reply With Quote #1

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 (0sizeof db_namei++)
    {
        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;
        }
    }

__________________

Last edited by georgik57; 03-29-2011 at 18:57.
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Reply



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


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