Raised This Month: $ Target: $400
 0% 

Lag/Freeze FastQuery


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Archerus
AlliedModders Donor
Join Date: Oct 2010
Old 01-30-2015 , 08:22   Lag/Freeze FastQuery
Reply With Quote #1

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,
__________________
Fondateur du Clan RmG
Spécialisations:
Configuration serveurs
Configuration Web
Configuration Teamspeak

Pour tout problèmes concernant nos services me contacter


Last edited by Archerus; 01-30-2015 at 16:12.
Archerus is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-30-2015 , 15:18   Re: Lag/Freeze FastQuery
Reply With Quote #2

PHP Code:
RandomFunction()
{
    
decl String:szQuery[256];
    
Format(szQuerysizeof(szQuery), "MySQL Query Here");
    
SQL_TQuery(hDatabaseSQL_CallbackszQuery);
}

public 
SQL_Callback(Handle:ownerHandle:hndl, const String:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Query Error: %s"error);
    }
    else
    {
        
// Your Candy Store.
    
}

Kolapsicle is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 01-30-2015 , 15:29   Re: Lag/Freeze FastQuery
Reply With Quote #3

If this is public plz make a custom log file instead of LogError for something that doesn't really literally pause your plugin.

Plugins broadcasting every time something doesn't connect as an ErrorLog detracts from them imo.
__________________

Last edited by Chdata; 01-30-2015 at 15:30.
Chdata is offline
Archerus
AlliedModders Donor
Join Date: Oct 2010
Old 01-30-2015 , 16:04   Re: Lag/Freeze FastQuery
Reply With Quote #4

Hi,



I do not understand how to change this part of code, sorry

Thanks for you answers

Cordially,
__________________
Fondateur du Clan RmG
Spécialisations:
Configuration serveurs
Configuration Web
Configuration Teamspeak

Pour tout problèmes concernant nos services me contacter

Archerus is offline
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 07:41.


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