07.05.2015, 21:01
mysql_log.txt
I'm using y_inline, y_hooks and y_dialog.
Keep in mind that this is unfinished code. I also have the account created in the database.
Code:
[17:02:55] [DEBUG] mysql_format - connection: 1, len: 1024, format: "SELECT * FROM accounts WHERE username = 'Jacob'" [17:02:55] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM accounts WHERE username = 'Jacob'", callback: "FJ37DH3JG_MYSQL_INTERNAL", format: "d" [17:02:55] [DEBUG] CMySQLQuery::Execute[FJ37DH3JG_MYSQL_INTERNAL] - starting query execution [17:02:55] [DEBUG] CMySQLQuery::Execute[FJ37DH3JG_MYSQL_INTERNAL] - query was successfully executed within 143.281 milliseconds [17:02:55] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [17:02:55] [DEBUG] Calling callback "FJ37DH3JG_MYSQL_INTERNAL".. [17:02:55] [DEBUG] cache_get_data - connection: 1 [17:02:55] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [17:02:57] [DEBUG] cache_get_field_content_int - row: 0, field_name: "accountindex", connection: 1 [17:02:57] [WARNING] cache_get_field_content_int - no active cache [17:02:57] [DEBUG] cache_get_field_content - row: 0, field_name: "username", connection: 1, max_len: 24 [17:02:57] [WARNING] cache_get_field_content - no active cache [17:02:57] [DEBUG] cache_get_field_content - row: 0, field_name: "password", connection: 1, max_len: 129 [17:02:57] [WARNING] cache_get_field_content - no active cache
Code:
hook OnPlayerConnect(playerid) { new query[1024]; mysql_format(MySQL_Handle, query, sizeof(query), "SELECT * FROM accounts WHERE username = 'Jacob'"); inline OnAccountCheck() { new row, field; cache_get_data(row, field, MySQL_Handle); if (row > 0) { inline Response(pid, dialogid, response, listitem, string:inputtext[]) { #pragma unused pid, dialogid, listitem, inputtext if (!response) { Kick(playerid); } else if (response) { AccountData[playerid][Account_ID] = cache_get_field_content_int(0, "accountindex"); cache_get_field_content(0, "username", AccountData[playerid][Account_Username], MySQL_Handle, 24); cache_get_field_content(0, "password", AccountData[playerid][Account_Password], MySQL_Handle, 129); printf("ID: %d, Username: %s, Password: %s", AccountData[playerid][Account_ID], AccountData[playerid][Account_Username], AccountData[playerid][Account_Password]); } } Dialog_ShowCallback(playerid, using inline Response, DIALOG_STYLE_PASSWORD, "{FFFFFF}San Andreas Logistics .:. Login!", "{FFFFFF}Welcome to San Andreas Logistics, Jacob!\n\nThis account is registered and you may continue by typing the password to login to it below.", "Login", "Cancel"); } else { inline Response(pid, dialogid, response, listitem, string:inputtext[]) { #pragma unused pid, dialogid, listitem, inputtext if (!response) { Kick(playerid); } else if (response) { } } Dialog_ShowCallback(playerid, using inline Response, DIALOG_STYLE_PASSWORD, "{FFFFFF}San Andreas Logistics .:. Register!", "{FFFFFF}Welcome to San Andreas Logistics, Jacob!\n\nThis account is not registered and you may continue by typing a password to register it below.", "Register", "Cancel"); } } mysql_tquery_inline(MySQL_Handle, query, using inline OnAccountCheck, ""); return 1; }