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(32) NOT 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(35) NOT NULL DEFAULT '',
PRIMARY KEY (id),
FOREIGN KEY (steam) REFERENCES pug_players(steam)
);
__________________