You should implement some kind of queue and process it once the database is available.
To get you started
Code:
#include <amxmodx>
#include <sqlx>
const TASK_PROCCESS_QUEUE = 100
new Handle:g_dbTuple
new Stack:g_queue
public plugin_init()
{
g_queue = CreateStack()
}
public client_authorized(index, const authid[])
{
// Database isn't available yet
if (g_dbTuple == Empty_Handle)
{
// Push this player to the queue
PushStackCell(g_queue, get_user_userid(index))
// Start processing the queue
if (!task_exists(TASK_PROCCESS_QUEUE)) {
set_task(1.0, "ProccessQueue", TASK_PROCCESS_QUEUE, .flags="b")
}
}
}
public ProccessQueue(task)
{
// Database isn't available yet
if (g_dbTuple == Empty_Handle) {
return
}
// Queue is empty
if (IsStackEmpty(g_queue)) {
// You can probably stop processing the queue here
//remove_task(task)
return
}
new userid
PopStackCell(g_queue, userid)
new player = find_player_ex(FindPlayer_MatchUserId|FindPlayer_IncludeConnecting, userid)
// Player has disconnected
if (player == 0) {
return
}
// Do something here
}
By the way, I assume you're dealing with the player's steamid, if that is the case you should replace client_connect with client_authorized. client_connect is called too soon, the player will likely not have a valid steam id at this point.
__________________