07.09.2017, 11:54
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_REGISTER: { if(!response)return Kick(playerid); if(strlen(inputtext) < 3 || strlen(inputtext) > 30){ ShowRegisterDialog(playerid, "Password length must be above 3 characters AND below 30 characters long."); return true; } new query[128]; mysql_format(sqlConnection, query, sizeof(query), "INSERT INTO players (Name, Password, RegIP) VALUES('%e', sha1('%e%'), '%e')", GetName(playerid), inputtext, GetIP(playerid)); mysql_pquery(sqlConnection, query, "SQL_OnAccountRegister", "i", playerid); } case DIALOG_LOGIN: { if(!response)return Kick(playerid); if(strlen(inputtext) < 3 || strlen(inputtext) > 30) { ShowLoginDialog(playerid, "Password length must be above 3 characters AND below 30 characters long."); return true; } new query[128]; mysql_format(sqlConnection, query, sizeof(query), "SELECT id FROM players WHERE Name = '%e' AND Password = sha1('%e') LIMIT 1", GetName(playerid), inputtext); mysql_pquery(sqlConnection, query, "SQL_OnAccountLogin", "i", playerid); } } return false; }
Код:
Server:SQL_OnAccountRegister(playerid) { SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered onto the server."); DefaultPlayerValues(playerid); PlayerData[playerid][pSQLID] = cache_insert_id(); }