Raised This Month: $32 Target: $400
 8% 

Solved Passing parameters using SQL_ThreadQuery


Post New Thread Reply   
 
Thread Tools Display Modes
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 10-07-2019 , 22:13   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #11

Quote:
Originally Posted by Bugsy View Post
Maybe SQL_ThreadQuery() isn't able to handle an enumerator-sized array that contains string(s). I've personally passed data in the past using the below. Try doing a test, eliminating the string portion of your enumerator and see if it works. If it does, we can probably figure out a workaround.

Edit: I just tested it myself and enum sized arrays, that include strings, pass to the callback handler perfectly.
PHP Code:

enum QueryTypes
{
    
qtPlayerConnected,
    
qtPlayerDisconnected,
    
qtGetNewAdmins,
    
qtGetNewPermAdmins,
    
qtSetPlayerAsAdmin,
    
qtRemoveAllAdmins,
    
qtPruneDatabase,
    
qtShowStats,
    
qtShowTop15
}

enum _:QueryInfo
{
    
QueryTypes:qiQueryType,
    
qiPlayerID
}

new 
QueryDataQueryInfo ];
QueryDataqiQueryType ] = qtPlayerConnected;
QueryDataqiPlayerID ] = id;
formatexg_szBuffer charsmaxg_szBuffer ) , Query_PlayerConnected pdDataid ][ pdAuthID ] );
SQL_ThreadQueryg_SQLTuple "QueryHandle" g_szBuffer QueryData sizeofQueryData ) ); 
Hi, thanks for the reply. So, i removed the string part and still got wrong values. Also, i reinstalled HLDS (download stuff again with steamcmd) and AMXX just to be sure, but still got wrong values. I'll try in another machine because, honestly, i have no idea what else to try. I'll try tomorrow to do a simple plugin with other values to test more.
__________________
marcelowzd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-07-2019 , 22:18   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #12

Make a small test plugin to see if you can get it to work. If you can, then you know it's some coding issue in your plugin and not something wrong with your game/amx-x/modules etc.
__________________
Bugsy is online now
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 10-08-2019 , 19:07   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #13

PHP Code:
#include < amxmodx >
#include < sqlx >

new Handle:g_hSqlTuple;

enum _:eImportant
{
    
INTEGER,
    
Float:FLOAT,
    
STRING32 ]
};

public 
plugin_init( )
{
    new const 
szPlugin[ ] = "Test SQL";
    new const 
szVersion[ ] = "0.0.1";
    new const 
szAuthor[ ] = "Test";

    
register_pluginszPluginszVersionszAuthor );

    
register_clcmd"test_sql""OnSqlTest" );
}

public 
plugin_precache( )
{
    
g_hSqlTuple SQL_MakeDbTuple"localhost""root""root""Servidor" );
}

public 
OnSqlTestiClient )
{
    new 
aDataeImportant ];

    
aDataINTEGER ] = 3;
    
aDataFLOAT ] = 3.0;
    
copyaDataSTRING ], charsmaxaDataSTRING ] ), "MyTest" );

    
log_amx"Let's see --> %i --> %f --> %s"aDataINTEGER ], aDataFLOAT ], aDataSTRING ] );

    
FunctionTestaData );

    
SQL_ThreadQueryg_hSqlTuple"SqlHandler""SELECT * FROM Tops"aDatasizeofaData ) );
}

public 
FunctionTestaDataeImportant ] )
{
    
log_amx"Function Test --> %i --> %f --> %s"aDataINTEGER ], aDataFLOAT ], aDataSTRING ] );
}

public 
SqlHandleriFailStateHandle:hQueryszError[ ], aDataeImportant ], iSize )
{
    
log_amx"Sql Handler --> %i --> %f --> %s"aDataINTEGER ], aDataFLOAT ], aDataSTRING ] );

and the output...
Code:
L 10/08/2019 - 20:06:06: [NewTest.amxx] Let's see --> 3 --> 3.000000 --> MyTest
L 10/08/2019 - 20:06:06: [NewTest.amxx] Function Test --> 3 --> 3.000000 --> MyTest
L 10/08/2019 - 20:06:07: [NewTest.amxx] Sql Handler --> 12 --> 0.000000 -->
Also tried using it like this (same output)
PHP Code:
public SqlHandleriFailStateHandle:hQueryszError[ ], aData[ ], iSize )
{
    
log_amx"Sql Handler --> %i --> %f --> %s"aDataINTEGER ], aDataFLOAT ], aDataSTRING ] );

UPDATE: Ok so i decided to test it with AMXX 1.8.2 and metamod v1.21p37 and i got interesting results
First is that i received a "Tag Mismatch" warning while compiling the plugin in AMXX 1.8.2 in line aData[ FLOAT ] = 3.0, but the output is more
interesting
Code:
L 10/08/2019 - 20:21:13: [NewTest.amxx] Let's see --> 3 --> 3.000000 --> MyTest
L 10/08/2019 - 20:21:13: [NewTest.amxx] Function Test --> 3 --> 3.000000 --> MyTest
L 10/08/2019 - 20:21:13: [NewTest.amxx] Sql Handler --> 1 --> 0.000000 --> est SQL
For some reason, it appears to have taken the plugin's name (well, 90% of it at least)

Just as info, it's a brand new server, AMXX has the package core + cstrike addons and i'm using metamod v1.21p37 for all tests
__________________

Last edited by marcelowzd; 10-08-2019 at 19:27.
marcelowzd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2019 , 19:15   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #14

Your query callback is missing the integer error code parameter.

public QueryHandle( FailState , Handle:Query , const Error[] , Errcode , const Data[ QueryInfo ] , DataSize )
__________________
Bugsy is online now
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 10-08-2019 , 19:32   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #15

Quote:
Originally Posted by Bugsy View Post
Your query callback is missing the integer error code parameter.

public QueryHandle( FailState , Handle:Query , const Error[] , Errcode , const Data[ QueryInfo ] , DataSize )
True, stupid error, i'll redo the tests.
__________________
marcelowzd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-08-2019 , 19:34   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #16

This has to be the cause, everything else in the test plugin is perfect. Your plugin from the OP is also missing this.
__________________
Bugsy is online now
marcelowzd
Senior Member
Join Date: Feb 2011
Location: São Paulo, Brazil
Old 10-08-2019 , 19:39   Re: Passing parameters using SQL_ThreadQuery
Reply With Quote #17

Quote:
Originally Posted by Bugsy View Post
This has to be the cause, everything else in the test plugin is perfect. Your plugin from the OP is also missing this.
You're my hero, it is working, and i'm stupid, but at least it works now, much appreciated.
__________________
marcelowzd is offline
Reply


Thread Tools
Display Modes

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 11:27.


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