16.09.2011, 23:44
hi,
i'm writing my first filterscript and i've already faced a problem. I am trying to load the mysql row to enum OnPlayerConnect callback, but the query never executes.
Debug.txt shows only that connection was successfull, the query isn't showed at all. I was experimenting a little, and if i change the OnPlayerConnect to OnPlayerSpawn callback, the filterscript works.
So, is it even possible to query a database from onplayerconnect cb?
my code:
sqlQuery is a global variable, PlayerName(playerid) is a stock function that returns a name, and enum matches perfectly to sscanf.
and this is the debug.txt
script is loaded correctly, added in server.cfg.
any advice is appreciated.
br
i'm writing my first filterscript and i've already faced a problem. I am trying to load the mysql row to enum OnPlayerConnect callback, but the query never executes.
Debug.txt shows only that connection was successfull, the query isn't showed at all. I was experimenting a little, and if i change the OnPlayerConnect to OnPlayerSpawn callback, the filterscript works.
So, is it even possible to query a database from onplayerconnect cb?
my code:
pawn Код:
public OnPlayerConnect(playerid)
{
format(sqlQuery, sizeof(sqlQuery), "SELECT * FROM accounts WHERE username = '%s'", PlayerName(playerid));
mysql_query(sqlQuery);
mysql_store_result();
if(mysql_num_rows())
{
while(mysql_fetch_row_format(sqlQuery, "|"))
{
sscanf(sqlQuery, "p<|>e<is[24]s[40]s[255]s[15]ii>", PlayerData[playerid]);
}
}
mysql_free_result();
return 1;
}
and this is the debug.txt
Код:
[01:15:27] MySQL Debugging activated (09/17/11) [01:15:27] --------------------------- [01:15:27] [01:15:27] >> mysql_connect( ) [01:15:27] CMySQLHandler::CMySQLHandler() - constructor called. [01:15:27] CMySQLHandler::CMySQLHandler() - Connecting to "somehost" | DB: "database" | Username: "user" ... [01:15:27] CMySQLHandler::Connect() - Connection was successful. [01:15:27] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
any advice is appreciated.
br