I'm try to get some data from the database
This is the code:
Code:
#include < amxmodx >
#include < sqlx >
#define hostname "hidden"
#define sql_user "hidden"
#define sql_pass "hidden"
#define sql_db "hidden"
new Handle:g_hTuple;
new g_szError[ 512 ];
public plugin_init( )
{
g_hTuple = SQL_MakeDbTuple( hostname, sql_user, sql_pass, sql_db );
register_clcmd( "say vipstatus", "cmd_Vipstatus" );
}
public cmd_Vipstatus( iIndex )
{
new szSteamID[ 35 ];
get_user_authid( iIndex, szSteamID, charsmax( szSteamID ) );
new iError, Handle:hSQLConnection = SQL_Connect( g_hTuple, iError, g_szError, 511 );
if( hSQLConnection == Empty_Handle )
{
set_fail_state( g_szError );
}
new Handle:hQuery = SQL_PrepareQuery( hSQLConnection, "SELECT `package_id`, `server_id` FROM `vips` WHERE `steamid` = '%s';", szSteamID );
static szServerID[ 3 ], iPackageID;
if( !SQL_Execute( hQuery ) )
{
SQL_QueryError( hQuery, g_szError, 511 );
log_amx( "Query Error: %s", g_szError );
}
else if( SQL_NumResults( hQuery ) )
{
iPackageID = SQL_ReadResult( hQuery, 0 );
SQL_ReadResult( hQuery, 1, szServerID, charsmax( szServerID ) );
client_print( iIndex, print_chat, "You are a VIP with the package ID: %i on server %s", iPackageID, szServerID );
}
SQL_FreeHandle( hQuery );
SQL_FreeHandle( hSQLConnection );
}
public plugin_end( )
{
SQL_FreeHandle( g_hTuple );
}
The connection succeed but when i write 'vipstatus' in chat it just lag the server for a second and doesn't show anything.
I run the query on the database and it returning my requested values;
What is the problem with my code?
Thanks for the Help!