case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new hpass[129];
WP_Hash(hpass, sizeof(hpass), inputtext);
if(!strmatch(pVariables[playerid][pPassword], hpass))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1", name1);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
new string[256], string1[256];
format(string, sizeof(string), "Real pass: %s", pVariables[playerid][pPassword]);
SendClientMessageToAll(-1, string);
format(string1, sizeof(string1), "Input Pass: %s", hpass);
SendClientMessageToAll(-1, string1);
return 1;
}
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have not entered a password.\n"COL_WHITE"Type a password below to register a new account.","Register","Quit");
WP_Hash(pVariables[playerid][pPassword], 129, inputtext);
pVariables[playerid][pMoney] = 1500;
mysql_format(mysql, query, sizeof(query), "INSERT INTO `users` (`Username`, `Password`, `IP`, `Admin`, `Helper`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `Faction`, `FRank`, `Family`, `Medical`) VALUES ('%s', '%s', '%s', 0, 0, 0, 1500, '%f', '%f', '%f', '0', '0', '0', '0')", Name[playerid], pVariables[playerid][pPassword], IP[playerid], Spawn_X, Spawn_Y, Spawn_Z);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
SendClientMessage(playerid, COL_BLUE, "----Credits----");
SendClientMessage(playerid, COL_BLUE, "Scripted by Connor and Tony ( All rights reserved © SF-RP )");
SendClientMessage(playerid, COL_BLUE, "Mappings - Damon");
}
|
show we function OnAccountLoad and make sure length of column Password is 128
|
public OnPlayerConnect(playerid)
{
* * //... check roleplay name, banned, blah blah
* *
* * // Check if valid user
* * new name[MAX_PLAYER_NAME+1];
* * GetPlayerName(playerid, name, sizeof(name))
* * mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1", name);
* * new Cache:result = mysql_query(mysql, query);
* * if(cache_num_rows() > 0)
* * {
* * * * // Get password from database and set it to pVariables[playerid][pPassword]
* * * * cache_get_field_content(0,"Password",129,pVariables[playerid][pPassword]);
* * * * // Show real password from database
* * * * SendClientMessageToAll(-1, pVariables[playerid][pPassword]);
* * * * // Show login dialog
* * * * ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login","Type your password below to login.","Login","Quit");
* * }
* * else
* * {
* * * * // Show Register dialog
* * }
* * cache_delete(result);
* *
* * return 1;
}
case DIALOG_LOGIN:
{
* * if ( !response ) return Kick ( playerid );
* * if( response )
* * {
* * * * new hpass[129];
* * * * WP_Hash(hpass, sizeof(hpass), inputtext);
* * * * // Show Input Password
* * * * SendClientMessageToAll(-1, hpass);
* * * * if(!strmatch(pVariables[playerid][pPassword], hpass))
* * * * {
* * * * * * ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
* * * * }
* * * * else
* * * * {
* * * * * * mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1", name1);
* * * * * * mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
* * * * }
* * * * /*
* * * * new string[256], string1[256];
* * * * format(string, sizeof(string), "Real pass: %s", pVariables[playerid][pPassword]);
* * * * SendClientMessageToAll(-1, string);
* * * * format(string1, sizeof(string1), "Input Pass: %s", hpass);
* * * * SendClientMessageToAll(-1, string1);
* * * * */
* * * * return 1;
* * }
}