Raised This Month: $ Target: $400
 0% 

help with using sqlx


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2024 , 17:18   Re: help with using sqlx
Reply With Quote #2

Not tested
PHP Code:

#include <amxmodx>
#include <sqlx>

new Handle:g_SQLTuple;

new 
g_szBuffer256 ];

public 
plugin_init() 
{
    
SQL_SetAffinity"sqlite" );
    
g_SQLTuple SQL_MakeDbTuple"host" "user" "pass" "DBName" );
}

public 
client_authorizedid )
{
    new 
szSteamID35 ];
    
get_user_authidid szSteamID charsmaxszSteamID ) );

    
formatexg_szBuffer charsmaxg_szBuffer ) , "SELECT * FROM players WHERE steam_id = '%s';" szSteamID );
    
SQL_ThreadQueryg_SQLTuple "SQLCallBack" g_szBuffer szSteamID sizeofszSteamID )  );
}

public 
SQLCallBack(FailStateHandle:QueryError[], Errcode, const Data[], DataSize)
{
    new 
szSteamID35 ];
    
    if ( !
Errcode )
    {
        if ( 
SQL_NumResultsQuery ) )
        {
            
SQL_ReadResultQuery szSteamID charsmaxszSteamID ) );
            
            
console_print"SteamID Found" );
        }
        else
        {
            
formatexg_szBuffer charsmaxg_szBuffer ) , "INSERT INTO players (steam_id) VALUES ('%s');" Data );
            
SQL_ThreadQueryg_SQLTuple "SQLCallBack" g_szBuffer );
            
            
console_print"SteamID Inserted" );
        }
    }

__________________

Last edited by Bugsy; 02-09-2024 at 18:03.
Bugsy is offline
 



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 00:33.


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