PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
new pc_sql_host
new pc_sql_user
new pc_sql_pass
new pc_sql_db
new Handle:g_sql_tuple
public plugin_init() {
register_plugin("SQL test", "0.1", "Turshija");
pc_sql_host = register_cvar("db_host", "XXX.XXX.XXX.XXX");
pc_sql_user = register_cvar("db_user", "username here");
pc_sql_pass = register_cvar("db_pass", "password here", FCVAR_PROTECTED);
pc_sql_db = register_cvar("db_name", "db name here");
set_task(0.1, "grab_cvars")
}
public grab_cvars(){
new sql_host[32], sql_user[32], sql_pass[32], sql_db[32]
get_pcvar_string(pc_sql_host, sql_host, 31)
get_pcvar_string(pc_sql_user, sql_user, 31)
get_pcvar_string(pc_sql_pass, sql_pass, 31)
get_pcvar_string(pc_sql_db, sql_db, 31)
g_sql_tuple = SQL_MakeDbTuple(sql_host, sql_user, sql_pass, sql_db)
}
public client_connect (id){
new name[32],auth[32];
new cache[500];
get_user_name(id, name, 31);
get_user_authid(id, auth, 31);
formatex(cache,500, "SELECT * FROM table WHERE auth='%s'",auth);
// here..
new data[1];
data[0] = id;
// and here.. the last parameters
SQL_ThreadQuery( g_sql_tuple, "QueryCheckAuth", cache, data, 1);
return PLUGIN_CONTINUE;
}
public QueryCheckAuth( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) {
if( iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED ) {
log_amx( "Error!" );
} else if( SQL_NumResults( hQuery ) ) {
// taking the ID previously sent through 'data'.
new id = iData[0];
// and using it
server_cmd("kick #%d",get_user_userid(id));
}
}
I didn't checked the entire code, but this is the idea.
Use this tutorial too... maybe it helps you.
https://forums.alliedmods.net/showthread.php?t=46779