new DBResult:Result, Query[1200];
format(Query, sizeof(Query),"SELECT PASS FROM USERS WHERE NAME = '%s'", Player[playerid][Name]); //Change by the variables of your database and game mode.
Result = db_query(database, Query);
if(db_num_rows(Result))
{
Player[playerid][Pass] = db_get_field_int(Result, 0);
Player[playerid][Registered] = true;
//show dialog to login
}
else //If the player is not registered.
{
}
db_free_result(Result);
First you must check from the database if the player is registered or not.
PHP код:
|
new
Query[600],
DBResult: Result,
storedip[71],
ip[20]
;
GetPlayerIp(playerid, ip, 20);
format(Query, sizeof(Query), "Choose `password`, `IP` from `users` where `username` = '%s'", DB_Escape(User[playerid][accountName]));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
db_get_field_assoc(Result, "IP", storedip, 20);
db_get_field_assoc(Result, "password", User[playerid][accountPassword], 129);
if((!strcmp(ip, storedip, true)))
{
LoginPlayer(playerid);
LoginPremium(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", ""grey"Welcome to Express FreeRoam 2.1.\nYour account is registered in our database, Type your password below to log in.\n\nTIP: IF you are not the owner of this account,please type /q and choose another nickname.", "Login", "Cancel");
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", ""grey"Welcome to our updated Express FreeRoam 2.1.\nThis account is not registered in our database,please enter a password to continue.\n\nСЪВЕТ: Make a strong password,so your account will be more secured.", "Register", "Quit");
}
db_free_result(Result);
return 1;
}
new
Query[600],
DBResult:Result,
storedip[16],
ip[16]
;
GetPlayerIp(playerid, ip, 16);
format(Query, sizeof(Query), "SELECT `password`, `IP` FROM `users` WHERE `username` = '%q'", User[playerid][accountName]);
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
db_get_field_assoc(Result, "IP", storedip, 16);
db_get_field_assoc(Result, "password", User[playerid][accountPassword], 129);
if(strcmp(ip, storedip, false))
{
LoginPlayer(playerid);
LoginPremium(playerid);
return 1;
}
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", ""grey"Welcome to Express FreeRoam 2.1.\nYour account is registered in our database, Type your password below to log in.\n\nTIP: IF you are not the owner of this account,please type /q and choose another nickname.", "Login", "Cancel");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", ""grey"Welcome to our updated Express FreeRoam 2.1.\nThis account is not registered in our database,please enter a password to continue.\n\nСЪВЕТ: Make a strong password,so your account will be more secured.", "Register", "Quit");
}
db_free_result(Result);
PHP код:
|