17.05.2015, 14:12
Hello!
I have a problem with my server's accounts.
Whenever a player connects to the server, even if his account is already registered, he gets the registration dialog.
If he attempts to use the registration dialog, the login dialog appears (after I edited it) as it sends him the message that the account is already registered.
I want to get rid of the registering dialog when you are already registered.
Here are the codes:
OnPlayerConnect:
OnDialogResponse:
Logging in:
Registration:
After reviewing the codes, I couldn't fix the problem. The registering dialog still appears before the login dialog.
I have a problem with my server's accounts.
Whenever a player connects to the server, even if his account is already registered, he gets the registration dialog.
If he attempts to use the registration dialog, the login dialog appears (after I edited it) as it sends him the message that the account is already registered.
I want to get rid of the registering dialog when you are already registered.
Here are the codes:
OnPlayerConnect:
PHP код:
new pname[MAX_PLAYER_NAME], path[200];
GetPlayerName(playerid, pname, sizeof(pname));
format(path, sizeof(path), "Users/%s.ini", pname);
if(!dini_Exists(path))
{
gPlayerAccount[playerid] = 1;
DisplayDialogForPlayer(playerid, 1);
SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
return 1;
}
else
{
gPlayerAccount[playerid] = 0;
DisplayDialogForPlayer(playerid, 2);
SendClientMessage(playerid, -1, "This server may use explicit content. By playing here you agree with our COPPA Compliance.");
return 1;
}
Logging in:
PHP код:
if(dialogid == 1) //LOGIN
{
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Error: You are already logged in.");
return 1;
}
if(response)
{
if(!strlen(inputtext))
{
ClearChatbox(playerid, 100);
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "Error: You must enter a password.");
return 1;
}
if(strlen(inputtext) >= 50)
{
ClearChatbox(playerid, 100);
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_WHITE, "Error: Password is too long.");
return 0;
}
new tmppass[64];
//Store Player ID & TMP pass in echo to find string used to crash server
new playername[MAX_PLAYER_NAME];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
GetPlayerName(playerid, playername, sizeof(playername));
//FadeColorForPlayer(playerid,0,0,0,0,0,0,0,255,15,0);
if(strlen(playername) == 3)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, that name is too short, please change it.");
SetTimerEx("GettingKicked", 2000, false, "i", playerid);
return 1;
}
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
DisplayDialogForPlayer(playerid, 1); //login
}
}
PHP код:
if(dialogid == 2) //REGISTER
{
if(gPlayerLogged[playerid] == 1)
{
ClearChatbox(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if(response)
{
if(strlen(inputtext) >= 50)
{
DisplayDialogForPlayer(playerid, 2); //register
ClearChatbox(playerid, 100);
SendClientMessage(playerid, COLOR_WHITE, "SERVER: Password is too long.");
return 0;
}
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new namestring = strfind(sendername, "_", true);
if(namestring == -1)
{
SendClientMessage(playerid, COLOR_YELLOW, "Your name must be in the Firstname_Lastname format. Please relog with a name such as John_Doe.");
SetTimerEx("GettingKicked", 2000, false, "i", playerid);
return 1;
}
if(strlen(sendername) == 6)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, that name is too short, please change it.");
SetTimerEx("GettingKicked", 2000, false, "i", playerid);
return 1;
}
else
{
if(!strlen(inputtext))
{
DisplayDialogForPlayer(playerid, 2); //register
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must enter a password.");
return 1;
}
format(string, sizeof(string), "Users/%s.ini", sendername);
if(dini_Exists(string))
//if(fexist(string))
{
DisplayDialogForPlayer(playerid, 1); //login
SendClientMessage(playerid, COLOR_LIGHTRED, "This name is already taken. Please proceed to login.");
return 0;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
PlayAudioStreamForPlayer(playerid,"hidden");
ClearChatbox(playerid, 100);
//FadeColorForPlayer(playerid,0,0,0,255,0,0,0,0,15,0);
OnPlayerRegister(playerid,tmppass);
OnPlayerLogin(playerid,tmppass);
//SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you have been logged in automatically.");
}
}
else
{
DisplayDialogForPlayer(playerid, 2); //register
}
}