AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] Can I use SQL in the course of the game? (https://forums.alliedmods.net/showthread.php?t=295297)

Fastmancz 03-21-2017 16:39

[CS:GO] Can I use SQL in the course of the game?
 
Hello,

I have to you question. Can I use SQL queries during the game? Because I have a problem that sometimes crashes the server. I use standard SQL query (SQL_TQuery).

Example:
PHP Code:

public void MySQL(Handle ownerHandle hquery, const char[] errorany client)
{
    if(
hquery == INVALID_HANDLE)
    {
        
LogError("[SQL]  Error: %s\n\n\n"error);
    }

    
char steamid[32];
    
GetClientAuthId(clientAuthId_Enginesteamidsizeof(steamid));
    
Format(querysizeof(query), "SELECT * FROM xxxxx WHERE steamid LIKE '%s'"steamid);
    
SQL_TQuery(DBMySQL_Dataqueryclient);

    
CloseHandle(h_query);
}

public 
void MySQL_Data(Handle ownerHandle hquery, const char[] errorany client)
{
    if(
hquery == INVALID_HANDLE)
    {
        
LogError("[SQL]  Error: %s\n\n\n"error);
    }
    .....
    
    
CloseHandle(h_query);


It can also cause this, that I did not use closed handles (return Plugin_Handled, etc.)?

Thank you for the explanation and answer.

Mitchell 03-21-2017 18:59

Re: [CS:GO] Can I use SQL in the course of the game?
 
what is 'h_query' and why are you closing it? Most plugins use sql queries mid game perfectly fine.

Fastmancz 03-22-2017 02:10

Re: [CS:GO] Can I use SQL in the course of the game?
 
Thank you for the reply. I checked what it is. I have found that basically I do not use it.

PHP Code:

Handle h_query INVALID_HANDLE

Is it possible to somehow check the handles? I mean the debug plugin. I found the command:
sm_dump_handles

Thanks for answer.

Totenfluch 03-22-2017 08:53

Re: [CS:GO] Can I use SQL in the course of the game?
 
Invalid info
Spoiler

Mitchell 03-22-2017 09:48

Re: [CS:GO] Can I use SQL in the course of the game?
 
Quote:

Originally Posted by Totenfluch (Post 2505664)
you should close hquery not h_query

You shouldn't need to close that either, unless the wiki is passing out bad information.

Fastmancz 03-22-2017 13:19

Re: [CS:GO] Can I use SQL in the course of the game?
 
Thanks for reply. How do I know which handles is the need to close? It is necessary for SQL_TQuery to close the handles?

Drixevel 03-22-2017 13:52

Re: [CS:GO] Can I use SQL in the course of the game?
 
Quote:

Originally Posted by Fastmancz (Post 2505756)
Thanks for reply. How do I know which handles is the need to close? It is necessary for SQL_TQuery to close the handles?

You should only have to open 1 database handle globally if you want to use it consistently and just create threaded queries using 'SQL_TQuery' without closing any of the handles inside of it unless you pass a datapack through it, you need to close that.

Fastmancz 03-23-2017 14:20

Re: [CS:GO] Can I use SQL in the course of the game?
 
Thanks for reply. I looked in the log and I found this:

Mysql Error: Lost connection to MySQL server during query

Which in turn will cause a server crash. Where there may be an error?

Fyren 03-24-2017 07:53

Re: [CS:GO] Can I use SQL in the course of the game?
 
Code similar to what you gave in your first post shouldn't crash the server and neither should losing your database connection. You might want to try posting a crash dump if possible (perhaps using Accelerator).


All times are GMT -4. The time now is 03:40.

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