Not tested
PHP Code:
#include <amxmodx>
#include <sqlx>
new Handle:g_SQLTuple;
new g_szBuffer[ 256 ];
public plugin_init()
{
SQL_SetAffinity( "sqlite" );
g_SQLTuple = SQL_MakeDbTuple( "host" , "user" , "pass" , "DBName" );
}
public client_authorized( id )
{
new szSteamID[ 35 ];
get_user_authid( id , szSteamID , charsmax( szSteamID ) );
formatex( g_szBuffer , charsmax( g_szBuffer ) , "SELECT * FROM players WHERE steam_id = '%s';" , szSteamID );
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" );
}
}
}
__________________