SQLite problem with login password
#1

Hello guys i have one problem.

my problem is here

Код:
if(!strcmp(inputtext,P_DATA[playerid][password],false))return ShowPlayerDialog(playerid,DIALOG_LOG,DIALOG_STYLE_INPUT,"LOGIN","TYPE YOUR PASSWORD","LOGIN","KICK");
if player input false password again login without any problems.

onplayerconnect function for get password.
Код:
public OnPlayerConnect(playerid){
	for(var i;i<_:info;++i)P_DATA[playerid][info:i]=0;
	//var is new in pawn, why i like javascript :D
	var name[MAX_PLAYER_NAME];
	static Q[256],DBResult:Result;
	GetPlayerName(playerid,name,sizeof(name));
	format(Q,sizeof(Q),"SELECT password FROM USERS WHERE username = '%s'",name);
	Result = db_query(database,Q);
	if(db_num_rows(Result)){
	    db_get_field_assoc(Result,"password",P_DATA[playerid][password],256);
		ShowPlayerDialog(playerid,DIALOG_LOG,DIALOG_STYLE_INPUT,"LOGIN","TYPE YOUR PASSWORD","LOGIN","KICK");
	}
	else{
	    ShowPlayerDialog(playerid,DIALOG_REG,DIALOG_STYLE_INPUT,"REGISTER","TYPE YOUR PASSWORD","REGISTER","KICK");
	}
	db_free_result(Result);

	over 1;  //over is return :D #define over return
}
Thanks!
Reply
#2

strcmp returns 0 when both strings are equal/same or even if one/both is/are NULL.

pawn Код:
if(strcmp(inputtext,P_DATA[playerid][password],false))return ShowPlayerDialog(playerid,DIALOG_LOG,DIALOG_STYLE_INPUT,"LOGIN","TYPE YOUR PASSWORD","LOGIN","KICK");
This will show the dialog when the inputtext does not match with the password you stored before.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
strcmp returns 0 when both strings are equal/same or even if one/both is/are NULL.

pawn Код:
if(strcmp(inputtext,P_DATA[playerid][password],false))return ShowPlayerDialog(playerid,DIALOG_LOG,DIALOG_STYLE_INPUT,"LOGIN","TYPE YOUR PASSWORD","LOGIN","KICK");
This will show the dialog when the inputtext does not match with the password you stored before.
oh thank you very much

if i use
Код:
if(!strcmp(inputtext,P_DATA[playerid][password],true))retrun Show...
else{

update stats

}
can use this?
Reply
#4

The false/true is about case sensitive/case insensitive in string comparison. All you have to do is to check if what strcmp returns is not 0 and re-show the dialog.
Reply
#5

aa okey thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)