Raised This Month: $ Target: $400
 0% 

3d Array saving (MySQL) [90 Queires?]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-16-2013 , 09:42   Re: 3d Array saving (MySQL)
Reply With Quote #1

Not, is not complete it is saving a stats, but i need basically to save weapon stats for each SteamID, and if exists the weapon + Steamid, will update the registry.

g_iWeapons[33][MAX_WEAPONS][STATS];
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-27-2014 , 01:37   Re: 3d Array saving (MySQL)
Reply With Quote #2

Hi, BUMP again!

I created the function to save in db, but is using so many queries (One query to one weapon if the player died by weapon or fired the weapon)

I can optmize this part?

PHP Code:
    new sWeapon[32],sQuery[256];
    
    for(new 
iWeapon;iWeapon sizeof(g_iWeapon[]);iWeapon++)
    {
        if(
g_iWeapon[id][iWeapon][Shots] || g_iWeapon[id][iWeapon][Deaths])
        {
            
get_weaponname(iWeapon,sWeapon,charsmax(sWeapon));
            
            
format
            
(
                
sQuery,
                
charsmax(sQuery),
                
"CALL PugSaveWeapon(%i, '%s', %i, %i, %i, %i, %i, %i, '%s')",
                
iWeapon,
                
sWeapon,
                
g_iWeapon[id][iWeapon][Kills],
                
g_iWeapon[id][iWeapon][Deaths],
                
g_iWeapon[id][iWeapon][Headshots],
                
g_iWeapon[id][iWeapon][Shots],
                
g_iWeapon[id][iWeapon][Hits],
                
g_iWeapon[id][iWeapon][Damage],
                
sSteam
            
);
            
            
SQL_ThreadQuery(g_hSQL,"PugHandlerSQL",sQuery); // Arround 9 queries per player disconnect, if is a 10 player servers, this will be 90 queries at change map and changelevel
        
}
    } 
The table in DB

PHP Code:
CREATE TABLE IF NOT EXISTS pug_weapon
(
    
id INT NOT NULL AUTO_INCREMENT,
    
weapon SMALLINT NOT NULL DEFAULT 0,
    
string VARCHAR(32NOT NULL DEFAULT '',
    
kills SMALLINT NOT NULL DEFAULT 0,
    
deaths SMALLINT NOT NULL DEFAULT 0,
    
headshots SMALLINT NOT NULL DEFAULT 0,
    
shots SMALLINT NOT NULL DEFAULT 0,
    
hits SMALLINT NOT NULL DEFAULT 0,
    
damage SMALLINT NOT NULL DEFAULT 0,
    
steam VARCHAR(35NOT NULL DEFAULT '',
    
PRIMARY KEY (id),
    
FOREIGN KEY (steamREFERENCES pug_players(steam)
); 
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-27-2014 at 01:37.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 15:51.


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