Someone mentioned you were looking for me, lol.
Well you'll want to look into threading your SQL Queries, because running nonthreaded queries will lag the almighty hell out of your server.
-SQL_TConnect
-SQL_TQuery
I can give you some example database code of how it should be looking..
PHP Code:
#include <sourcemod>
enum Player_Data
{
String:SteamID[32],
Money,
Bank,
};
new g_playerData[MAXPLAYERS + 1][Player_Data]
new Handle:dbConnection = INVALID_HANDLE;
public OnPluginStart()
{
SQL_TConnect(connectCB, "database");
}
//We'll use something similar to this if we want to load data
public connectCB(Handle:owner, Handle:child, const String:error[], any:data)
{
if(child == INVALID_HANDLE)
{
LogError("[ERROR] >> %s", error); //Error Preface
PrintToServer("[ERROR] >> %s", error);
SQL_TConnect(connectCB, "db");
return;
}
dbConnection = child;
PrintToServer(">> Connected to MySQL Database! :D :D");
return;
}
//Standard, non customized callback for queries of which do not return results
public sql_Callback(Handle:query, Handle:child, const String:error[], any:data)
{
if(query == INVALID_HANDLE || child == INVALID_HANDLE)
{
LogError("[ERROR] >> %s", error); //Error Preface
return;
}
}
public OnClientPutInServer(client)
{
GetClientAuthId(client, AuthId_Steam3, g_playerData[client][SteamID], 32);
decl String:query[256];
Format(query, sizeof(query), "SELECT * FROM player_stats WHERE steam_id = '%s'", g_playerData[Client][SteamID]);
SQL_TQuery(dbConnection, sql_Load, query, GetClientUserId(Client));
}
public sql_Load(Handle:nothing, Handle:result, const String:error[], any:data)
{
new Client = GetClientOfUserId(data)
if(IsFakeClient(Client))
{
return;
}
if(Client == 0)
{
return;
}
if(result == INVALID_HANDLE)
{
LogError("[ERROR] >> %s", error); //Error Preface
return;
}
//Load Stats
if(!SQL_GetRowCount(result))
{
decl String:query[256];
Format(query, sizeof(query), "INSERT INTO player_stats (steam_id) VALUES ('%s');", g_playerData[Client][SteamID]);
SQL_TQuery(sqlDB, sqlQuery, query);
PrintToChat(Client, "Data not found for you, so we'll set you up with an account..");
}
else if(SQL_FetchRow(result))
{
g_playerData[Client][Money] = SQL_FetchInt(result, 1);
g_playerData[Client][Bank] = SQL_FetchInt(result, 2);
}
}
That's generally how you'll want to approach this