30.05.2012, 11:29
Heey all,
How can i detect if the player is in my mysql database?
I am using:
But its dont detects it,it skips it.
How can i fix this?
Thanks Admigo
How can i detect if the player is in my mysql database?
I am using:
pawn Код:
new rows = mysql_num_rows(); //We get how many rows the query returned.
if(!rows)
{
//If the rows are equal to 0. This means that the query did not find
//anyone under the name we connected under in the database.
//So here we send the player the register dialog.
ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT, "Register","Your user is {FF0000}not{FFFFFF} registered! Please {0000FF}register{FFFFFF} with a password below!","Register","Cancel"); //Shows our register dialog :).
}
if(rows == 1)
{
//If the rows are equal to 1, this means there is a player already registered
//so we can initiate the login dialog to the player or check if the players
//current IP is the same one as in the database.
new IP[2][16]; //We create a variable with two IP strings, one for retrieving the mysql field and one for GetPlayerIP.
mysql_fetch_field_row(IP[0],"IP");
GetPlayerIp(playerid, IP[1], 16);
if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true)) //Checks that the MySQL IP has a value and that they are the same.
{
MySQL_Login(playerid);
}
else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
{
ShowPlayerDialog(playerid, 15500, DIALOG_STYLE_INPUT, "Login","Your user is {FF0000}registered{FFFFFF}! Please {0000FF}login{FFFFFF} with your password below!","Login","Cancel"); //Shows our login dialog :).
IsRegistered[playerid] = 1; //Sets the registered variable to 1 (Shows that the player is registered).
}
}
How can i fix this?
Thanks Admigo