29.01.2017, 11:52
(
Последний раз редактировалось AndreiWow; 29.01.2017 в 12:22.
)
Hey guys, what is wrong with this code?
So, at the first textdraw I tried to make if he press on Login, that would be loginscreen[8] it will check if his account is registered.
if(mysql_num_rows() != 0)
means if there are more than 0 rows execute this: (right?)
and if there are 0 rows execute this:
And, I joined the server with a not registered name, clicked on login button and the login dialog showed, it means that there are more than 0 rows? but how because there is no registered account..
#EDIT
I added (rows == 1) and (rows == 0), now if I join with a unregistered account it won't let me log in anymore but won't let me register either, it will say that I already have an account.
Code:
This is what I get in phpmyadmin
Created an account mannually, went in game and tried to log in, it told me that it is not registered..
Код:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) { if(_:playertextid != INVALID_TEXT_DRAW) { new Query[80],pName[24],string[164]; GetPlayerName(playerid,pName,24); if(playertextid == loginscreen[8][playerid]) { format(Query,sizeof(Query),"SELECT `Username` FROM `players` WHERE `Username` = '%s' LIMIT 1;",pName); mysql_query(Query); mysql_store_result(); if(mysql_num_rows() != 0) { format(string,sizeof(string),"Welcome back, %s! \nPlease type your password below to log in!",pName); ShowPlayerDialog(playerid,2016,DIALOG_STYLE_INPUT,"Login",string,"Login",""); } else { ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"ERROR","This username is not registered! \nPress on Register to register this username.","OK",""); } } else if(playertextid == loginscreen[9][playerid]) { if(mysql_num_rows() == 0) { format(string,sizeof(string),"Welcome, %s! \nPlease type a password below to register!",pName); ShowPlayerDialog(playerid,2017,DIALOG_STYLE_INPUT,"Register",string,"Register",""); } else { ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX,"ERROR","This username is already registered! \nPress on Login to log in...","OK",""); } } } return 1; }
So, at the first textdraw I tried to make if he press on Login, that would be loginscreen[8] it will check if his account is registered.
if(mysql_num_rows() != 0)
means if there are more than 0 rows execute this: (right?)
Код:
{ format(string,sizeof(string),"Welcome back, %s! \nPlease type your password below to log in!",pName); ShowPlayerDialog(playerid,2016,DIALOG_STYLE_INPUT,"Login",string,"Login",""); }
Код:
ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"ERROR","This username is not registered! \nPress on Register to register this username.","OK","");
#EDIT
I added (rows == 1) and (rows == 0), now if I join with a unregistered account it won't let me log in anymore but won't let me register either, it will say that I already have an account.
Code:
Код:
if(_:playertextid != INVALID_TEXT_DRAW) { new Query[80],pName[24],string[164]; new rows = mysql_num_rows(); GetPlayerName(playerid,pName,24); if(playertextid == loginscreen[8][playerid]) { format(Query,sizeof(Query),"SELECT `Username` FROM `players` WHERE `Username` = '%s' LIMIT 1;",pName); mysql_query(Query); mysql_store_result(); if(rows == 1) { format(string,sizeof(string),"Welcome back, %s! \nPlease type your password below to log in!",pName); ShowPlayerDialog(playerid,2016,DIALOG_STYLE_INPUT,"Login",string,"Login",""); } else { ShowPlayerDialog(playerid, 5, DIALOG_STYLE_MSGBOX,"ERROR","This username is not registered! \nPress on Register to register this username.","OK",""); } } else if(playertextid == loginscreen[9][playerid]) { format(Query,sizeof(Query),"SELECT `Username` FROM `players` WHERE `Username` = '%s' LIMIT 1;",pName); mysql_query(Query); mysql_store_result(); if(rows == 0) { format(string,sizeof(string),"Welcome, %s! \nPlease type a password below to register!",pName); ShowPlayerDialog(playerid,2017,DIALOG_STYLE_INPUT,"Register",string,"Register",""); } else { ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX,"ERROR","This username is already registered! \nPress on Login to log in...","OK",""); } } }
Код:
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0001 sec)
Created an account mannually, went in game and tried to log in, it told me that it is not registered..