12.03.2011, 23:37
When I connect with a unregistered account, it asks me to register.
After I've registered the account, I log off.
My PHPmyadmin shows the new made account, but when I log back on without a restart it asks me to register again. When I do, I see 2 accounts.
But if I relog after a restart it works properly.
The OnPlayerConnect is showed below.
Is it my OnPlayerConnect, or is it my account saving in register where I forgot something?
Login (dialog 1) and registration (dialog 2)
It's now the other way around than in my first post
After I've registered the account, I log off.
My PHPmyadmin shows the new made account, but when I log back on without a restart it asks me to register again. When I do, I see 2 accounts.
But if I relog after a restart it works properly.
The OnPlayerConnect is showed below.
Is it my OnPlayerConnect, or is it my account saving in register where I forgot something?
pawn Код:
public OnPlayerConnect(playerid)
{
new Query[200], Pname[24], escpname[24];\
GetPlayerName(playerid, Pname, 24);
mysql_real_escape_string(Pname, escpname);
format(Query, sizeof(Query), "SELECT * FROM `Players` WHERE `Username` = '%s'", escpname);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 0) // This asks if the result was 0. Then his not registered
{
SendClientMessage(playerid,COLOR_BROWN,"Your Account hasnt been registered yet please do it now");
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Welcome on the Server","Please enter your Password below to register your account","Register","Close");
}
else
{
SendClientMessage(playerid,COLOR_BROWN,"Your Account has been found. Please login");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Welcome on the Server","Your Account has been found","Login","Close");
}
mysql_free_result(); // clears the result
return 1;
}
pawn Код:
case 1:
{
if(strlen(inputtext) == 0)
{
SendClientMessage(playerid, COLOR_ORANGE, "Wrong Password.");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Authentication", "Welcome!\n\nPlease login by filling in your password.", "Login", "Cancel");
}
else
{
format(PlayerStats[playerid][Password], 36, inputtext);
SaveAccount(playerid);
}
}
case 2:
{
new Query[161];
if(strlen(inputtext) < 4 || strlen(inputtext) > 30)
{
SendClientMessage(playerid, COLOR_SYSTEM, "Your password must be between 4 and 30 characters.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Registration", "Welcome!\n\nPlease enter a password to register.", "Register", "Cancel");
}
else
{
new EscapedName[MAX_PLAYER_NAME];
GetPlayerName(playerid, EscapedName, MAX_PLAYER_NAME);
format(Query, sizeof(Query), "INSERT INTO `Players` (Username, Password) VALUES('%s', '%s')", EscapedName, inputtext);
mysql_query(Query);
}
}