 |
|
Junior Member
|

02-09-2024
, 17:43
Re: help with using sqlx
|
#3
|
Quote:
Originally Posted by Bugsy
Not tested
PHP Code:
#include <amxmodx>
#include <sqlx>
new Handle:g_SQLTuple;
new g_szBuffer[ 256 ];
public plugin_init()
{
new const szSteamID[] = "STEAM12345";
formatex( g_szBuffer , charsmax( g_szBuffer ) , "SELECT * FROM players WHERE steam_id = '%s';" , szSteamID );
SQL_SetAffinity( "sqlite" );
g_SQLTuple = SQL_MakeDbTuple( "host" , "user" , "pass" , "DBName" );
SQL_ThreadQuery( g_SQLTuple , "SQLCallBack" , g_szBuffer , szSteamID , sizeof( szSteamID ) );
}
public SQLCallBack(FailState, Handle:Query, Error[], Errcode, const Data[], DataSize)
{
new szSteamID[ 35 ];
if ( !Errcode )
{
if ( SQL_NumResults( Query ) )
{
SQL_ReadResult( Query , 0 , szSteamID , charsmax( szSteamID ) );
console_print( 0 , "SteamID Found" );
}
else
{
formatex( g_szBuffer , charsmax( g_szBuffer ) , "INSERT INTO players (steam_id) VALUES ('%s');" , Data );
SQL_ThreadQuery( g_SQLTuple , "SQLCallBack" , g_szBuffer );
console_print( 0 , "SteamID Inserted" );
}
}
}
|
Can you show me how to use this in client_putinserver, I tried to try it myself but I guess it didn't work.
|
|
|
|