21.10.2014, 21:49
(
Последний раз редактировалось PowerPC603; 21.10.2014 в 23:16.
)
I've got a problem with the latest MySQL plugin (R39-2).
I got no errors, my gamemode starts up properly, but when launching the game, I get no register/login dialog.
I've added some printf statements through the code and the problem lies in calling the callback with mysql_tquery.
OnPlayerConnect:
The last printf-statement that gets executed is:
Running query to select password
Query: SELECT Password FROM playerdata WHERE PlayerName = 'PowerPC603' LIMIT 1
The callback "Player_OnPasswordLoad" isn't executed at all ("Executed Player_OnPasswordLoad" doesn't get printed onto the server console).
The query is recorded into the MySQL logs though, it's only the callback that doesn't get executed.
I reverted back to MySQL plugin R34 by replacing:
- pawno/include/a_mysql.inc
- plugins/mysql.dll
- plugins/mysql.pdb
- deleting libmysql.dll from the root folder of the server
I didn't modify any code, only recompiled the code after replacing the include/plugin files.
Then everything works fine and I get my register/login dialog and I can properly login.
Also, every printf-statement you see in my code gets printed to the console.
What could be the problem?
I'm using samp server 0.3z R4.
I'm running 1 filterscript and the gamemode, which only connects to the database but doesn't use it (yet).
So the callback cannot be in 2 different scripts.
Another user experienced the same problem as me a few pages back (page 507), he's also using R39-2.
Log from R39-2:
Log from R34:
Another problem is, when I look at my logs, the filterscript (which holds my register/login system and alot more), only connects once to the MySQL server, gets data from the database using non-threaded queries (mysql_query) as this data must be loaded before the server is ready to accept players (gas-stations, police-stations, speedcams, vehicledata, ...), then the gamemode is loaded, which connects 3 times in a row to the MySQL server.
While in the code, there is only 1 mysql_connect statement.
Using R34, both scripts connect only once as there are only 2 connect log-entries instead of 4.
For now, I'll just be using R34 instead of the latest R39-2.
I got no errors, my gamemode starts up properly, but when launching the game, I get no register/login dialog.
I've added some printf statements through the code and the problem lies in calling the callback with mysql_tquery.
OnPlayerConnect:
pawn Код:
// Try to get the password from the SQL-table (he might have already registered and needs to login properly by entering the password, or he might be a new player)
printf("Executing Player_PasswordLoad");
Player_PasswordLoad(playerid);
pawn Код:
// This function is called when the player logs in (OnPlayerConnect) and sends a query to try to retrieve the password for this player
Player_PasswordLoad(playerid)
{
printf("Executed Player_PasswordLoad");
// Setup local variables
new Query[128];
// Try to get the password from the SQL-table
mysql_format(SQL_db, Query, sizeof(Query), "SELECT Password FROM %s WHERE PlayerName = '%e' LIMIT 1", table_playerdata, APlayerData[playerid][PlayerName]);
printf("Running query to select password");
printf("Query: %s", Query);
mysql_tquery(SQL_db, Query, "Player_OnPasswordLoad", "i", playerid);
}
// This custom callback is called when a player connects to the server (MySQL received a query to get his password using the function "Player_PasswordLoad")
forward Player_OnPasswordLoad(playerid);
public Player_OnPasswordLoad(playerid)
{
printf("Executed Player_OnPasswordLoad");
// Check if this player's account exists (number of rows should be 1)
if (cache_get_row_count(SQL_db) == 1)
{
// Store the password from the query-result
cache_get_row(0, 0, APlayerData[playerid][PlayerPassword], SQL_db, 130);
printf("Password: %s", APlayerData[playerid][PlayerPassword]);
// Ask the player to enter his password to login
ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "Welcome", "Please login by entering your password:", "Login", "Cancel");
}
else // The player isn't registered yet (he has no account), so let him enter a password to register his account
ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_PASSWORD, "Welcome", "Please register by entering your password:", "Register", "Cancel");
return 1;
}
Running query to select password
Query: SELECT Password FROM playerdata WHERE PlayerName = 'PowerPC603' LIMIT 1
The callback "Player_OnPasswordLoad" isn't executed at all ("Executed Player_OnPasswordLoad" doesn't get printed onto the server console).
The query is recorded into the MySQL logs though, it's only the callback that doesn't get executed.
I reverted back to MySQL plugin R34 by replacing:
- pawno/include/a_mysql.inc
- plugins/mysql.dll
- plugins/mysql.pdb
- deleting libmysql.dll from the root folder of the server
I didn't modify any code, only recompiled the code after replacing the include/plugin files.
Then everything works fine and I get my register/login dialog and I can properly login.
Also, every printf-statement you see in my code gets printed to the console.
What could be the problem?
I'm using samp server 0.3z R4.
I'm running 1 filterscript and the gamemode, which only connects to the database but doesn't use it (yet).
So the callback cannot be in 2 different scripts.
Another user experienced the same problem as me a few pages back (page 507), he's also using R39-2.
Log from R39-2:
Код:
[00:45:32] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT Password FROM %s WHERE PlayerName = '%e' LIMIT 1" [00:45:32] [DEBUG] mysql_tquery - connection: 1, query: "SELECT Password FROM playerdata WHERE PlayerName = 'PowerPC603' ", callback: "Player_OnPasswordLoad", format: "i" [00:45:32] [DEBUG] CMySQLQuery::Execute[Player_OnPasswordLoad] - starting query execution [00:45:32] [DEBUG] CMySQLQuery::Execute[Player_OnPasswordLoad] - query was successfully executed within 0.369 milliseconds [00:45:32] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [00:45:32] [DEBUG] Calling callback "Player_OnPasswordLoad".. [00:45:32] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [00:45:44] [DEBUG] mysql_close - connection: 1 [00:45:44] [DEBUG] CMySQLConnection::Disconnect - connection was closed [00:45:44] [DEBUG] CMySQLConnection::Disconnect - connection was closed [00:45:44] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
Код:
[00:51:28] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT Password FROM %s WHERE PlayerName = '%e' LIMIT 1" [00:51:28] [DEBUG] mysql_tquery - connection: 1, query: "SELECT Password FROM playerdata WHERE PlayerName = 'PowerPC603' ", callback: "Player_OnPasswordLoad", format: "i" [00:51:28] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [00:51:28] [DEBUG] mysql_tquery - scheduling query "SELECT Password FROM playerdata WHERE PlayerName = 'PowerPC603' LIMIT 1".. [00:51:28] [DEBUG] CMySQLQuery::Execute[Player_OnPasswordLoad(i)] - starting query execution [00:51:28] [DEBUG] CMySQLQuery::Execute[Player_OnPasswordLoad(i)] - query was successful [00:51:28] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [00:51:28] [DEBUG] CMySQLQuery::Execute[Player_OnPasswordLoad(i)] - data being passed to ProcessCallbacks() [00:51:28] [DEBUG] Calling callback "Player_OnPasswordLoad".. [00:51:28] [DEBUG] cache_get_row_count - connection: 1 [00:51:28] [DEBUG] cache_get_row - row: 0, field_idx: 0, connection: 1, max_len: 130 [00:51:28] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "96655ca25611e89ba5090709b70950605691cd8e4578f4d1d1fd8a9ceca49e921451de31a7d3d37abd01691b82a6d8256075b11790a779b803a320d27727d78" [00:51:28] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [00:51:28] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called [00:51:31] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM %s WHERE PlayerName = '%e' LIMIT 1" [00:51:31] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM playerdata WHERE PlayerName = 'PowerPC603' LIMIT 1", callback: "Player_OnAccountLoad", format: "i" [00:51:31] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [00:51:31] [DEBUG] mysql_tquery - scheduling query "SELECT * FROM playerdata WHERE PlayerName = 'PowerPC603' LIMIT 1".. [00:51:31] [DEBUG] CMySQLQuery::Execute[Player_OnAccountLoad(i)] - starting query execution [00:51:31] [DEBUG] CMySQLQuery::Execute[Player_OnAccountLoad(i)] - query was successful [00:51:31] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [00:51:31] [DEBUG] CMySQLQuery::Execute[Player_OnAccountLoad(i)] - data being passed to ProcessCallbacks() [00:51:31] [DEBUG] Calling callback "Player_OnAccountLoad".. [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "SpeedInMph", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "SpeedInMph", data: "0" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "ID", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "ID", data: "3" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Fines", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Fines", data: "0" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Tickets", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Tickets", data: "0" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "TicketCost", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "TicketCost", data: "0" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Money", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Money", data: "811256" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Score", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Score", data: "5961" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "AdminLevel", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "AdminLevel", data: "6" [00:51:31] [DEBUG] cache_get_field_content_int - row: 0, field_name: "JailTime", connection: 1 [00:51:31] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "JailTime", data: "0" [00:51:31] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [00:51:31] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called [00:51:43] [DEBUG] mysql_close - connection: 1, wait: true [00:51:43] [DEBUG] CMySQLConnection::Disconnect - connection was closed [00:51:43] [DEBUG] CMySQLConnection::Disconnect - connection was closed [00:51:43] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
While in the code, there is only 1 mysql_connect statement.
Using R34, both scripts connect only once as there are only 2 connect log-entries instead of 4.
For now, I'll just be using R34 instead of the latest R39-2.