Hello,
I currently have a lag / freeze from one of my plugins, and I find it comes but I do not know how to solve it.
Here are the codes (they told me that SQL_TQuery solve the problem, but I do not know how to do):
Code:
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontbroadcoast)
{
if(!cvar_Active) return Plugin_Continue;
for( new client=1; client<MaxClients; client++)
{
if(IsClientInGame(client))
{
new cvar_maxcumul=GetConVarInt(gMaxCumul);
if(Player_Deaths[client]>=cvar_maxcumul)
{
Player_Deaths[client] /= 2;
Player_Frags[client] /= 2;
}
Player_Ratio[client] = float(Player_Frags[client])/float(Player_Deaths[client]);
isPlayerLuciole[client]=0;
isPlayerPgm[client]=0;
if(!IsFakeClient(client))
{
new String:auth[MAX_AUTHID_LENGTH];
GetClientAuthString(client, auth, sizeof(auth));
decl String:steamid[MAX_AUTHID_LENGTH-8];
Format(steamid,sizeof(steamid),"%s",auth[8]);
if(isConfigDownload[client])
{
decl String:pseudo[MAX_NAME_LENGTH], String:pseudo_esc[128];
GetClientName(client, pseudo, sizeof(pseudo));
SQL_EscapeString(hDatabase, pseudo, pseudo_esc, sizeof(pseudo_esc));
new String:query[150];
Format(query, sizeof(query), "UPDATE css_players SET pseudo='%s' ,frag='%d', death='%d' WHERE steamid='%s'", pseudo_esc, Player_Frags[client], Player_Deaths[client], steamid);
SQL_LockDatabase(hDatabase);
if(!SQL_FastQuery(hDatabase, query))
{
new String:error[255];
SQL_GetError(hDatabase, error, sizeof(error));
PrintToServer("[ANTIROXX] Failed to query (error: %s)", error);
LogError("[ANTIROXX] %s", query);
}
SQL_UnlockDatabase(hDatabase);
}
else { CheckSteamID(client, steamid); }
}
}
}
return Plugin_Continue;
Code:
new String:query[150];
Format(query, sizeof(query), "insert into css_players (steamid, frag, death) values ('%s',%d, %d)", steamid, Player_Frags[client], Player_Deaths[client]);
SQL_LockDatabase(hDatabase);
if(!SQL_FastQuery(hDatabase, query))
{
new String:errorsql[255];
SQL_GetError(hDatabase, errorsql, sizeof(errorsql));
PrintToServer("[ANTIROXX] Failed to query (error: %s)", errorsql);
LogError("[ANTIROXX] %s", query);
}
SQL_UnlockDatabase(hDatabase);
plx[client] = 0;
}
Thank you to all who can help me.
Best Regards,
__________________