29.08.2014, 03:54
So I've built a registration system using MySQL and it worked like acouple of hours ago now it didn't so I assume I touched something but now I can not fix it.
It doesn't fetch the password if the player has registered, like I log in and if I need to register it'll insert the pass into the database then when it asks for log-in details after I register it doesn't fetch the password correctly.
I do not know how to fix it, I've tried several methods with cache(im using cache btw) and even tried to put a certain result into the password variable which I have a public there to fetch the password.
So like if I disconnect and reconnet suddenly it works, like it's kind of not "dynamic" I guess? Maybe? Well it just doesn't fetch it after you register, here's the code and the publics, etc...
I'm hoping for an explanation when you give an answer please, thank you
It doesn't fetch the password if the player has registered, like I log in and if I need to register it'll insert the pass into the database then when it asks for log-in details after I register it doesn't fetch the password correctly.
I do not know how to fix it, I've tried several methods with cache(im using cache btw) and even tried to put a certain result into the password variable which I have a public there to fetch the password.
So like if I disconnect and reconnet suddenly it works, like it's kind of not "dynamic" I guess? Maybe? Well it just doesn't fetch it after you register, here's the code and the publics, etc...
Код:
forward OnMySQL_LOAD(playerid); public OnMySQL_LOAD(playerid) { new rows, fields; cache_get_data(rows, fields); if(rows) { cache_get_field_content(0, "Name", pInfo[playerid][Name], connection, MAX_PLAYER_NAME); cache_get_field_content(0, "Password", pInfo[playerid][Password], connection, 128); pInfo[playerid][PosX] = cache_get_field_content_float(0, "PosX", connection); pInfo[playerid][PosY] = cache_get_field_content_float(0, "PosY", connection); pInfo[playerid][PosZ] = cache_get_field_content_float(0, "PosZ", connection); pInfo[playerid][AdminLevel] = cache_get_field_content_int(0, "AdminLevel", connection); pInfo[playerid][IsBanned] = cache_get_field_content_int(0, "IsBanned", connection); if(pInfo[playerid][PosX] == 0 && pInfo[playerid][PosY] == 0 && pInfo[playerid][PosZ] == 0) { SpawnPlayer(playerid); } else { SpawnPlayer(playerid); SetPlayerPos(playerid, pInfo[playerid][PosX], pInfo[playerid][PosY], pInfo[playerid][PosZ]); } } return 1; } if(dialogid == DIALOG_LOGIN) { if(!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome! Login Please! - No PASSWORD entered!", "Welcome!\nIt appears that you haven't entered a login password\nIt also seems that you haven't entered anything at all.\nPlease insert your password below:", "Log-in", "Quit"); else { if(!strcmp(inputtext, pInfo[playerid][Password])) { printf("Player ID %s(%d) has successfully logged in - Password used: '%s'", GetName(playerid), playerid, inputtext); MySQL_LOAD(playerid); } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome! Login Please! - Incorrect PASSWORD!", "Welcome!\nIt appears that you haven't entered a CORRECT login password\nTherefore you must enter a CORRECT password\nPlease insert your password below:", "Log-in", "Quit"); } } } return 1; } stock MySQL_LOAD(playerid) { new query[256]; format(query, sizeof(query), "SELECT * FROM accounts WHERE Name = '%s'", GetName(playerid)); mysql_function_query(connection, query, true, "OnMySQL_LOAD", "i", playerid); return 1; }