26.02.2014, 20:51
(
Последний раз редактировалось Aerotactics; 28.02.2014 в 08:46.
)
DELETED AND CREATED A NEW THREAD
Well the answer might be very easy.
When you connect you are automatically going to the "request classes", no matter if you're opening a dialog or if you're checking a file (account exists). You shouldn't use the ShowPlayerDialog() in OnPlayerRequestClass, let it pop up after a player is successfully registered or logged in |
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER) //register dialog
{
if(response)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
new file[96];
format(file,sizeof(file),"/User_Database/%s.ini",pName);
new INI:handler = INI_Open(file);
INI_WriteString(handler,"Password",inputtext);
INI_WriteInt(handler,"Score", 0);
INI_WriteInt(handler,"Money", 0.0);
INI_WriteInt(handler,"Playerlevel", 0);
INI_WriteFloat(handler, "PosX", 0);
INI_WriteFloat(handler, "PosY", 0);
INI_WriteFloat(handler, "PosZ", 0);
INI_WriteInt(handler,"FirstLog", 1);
INI_Close(handler);
PlayerInfo[playerid][FirstLog] = 1;
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
}
else Kick(playerid);
}
if(dialogid == DIALOG_LOGIN) //login dialog
{
if(response)
{
new pName[MAX_PLAYER_NAME];GetPlayerName(playerid, pName, sizeof(pName));
new file[96];format(file,sizeof file,"/User_Database/%s.ini",pName);
INI_ParseFile(file, "GetData", .bExtra = true, .extra =playerid);
if (strcmp(inputtext, PlayerInfo[playerid][password]))
{
new string[128];
if (attempt[playerid] <3)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
attempt[playerid]++;
PlayerPlaySound(playerid,1057,0,0,0);
printf("%s has failed to login", pName);
format(string,sizeof string,"Invalid password! [%i/3]",attempt[playerid]);
SendClientMessage(playerid, 0xFF3200FF, string);
attempt[playerid] = attempt[playerid]++;
} else {
GetPlayerName(playerid,pName,8);
format(string,sizeof string,"%s(%i) Has been kicked by the server(Failed to login).",pName,playerid);
SendClientMessageToAll(COLOR_GRAY,string);
Kick(playerid);
}
}
else if (!strcmp(inputtext, PlayerInfo[playerid][password]))
{
if (PlayerInfo[playerid][FirstLog] == 0)
{
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_GREEN,"You have succesfully logged in!");
return 1;
}
if (PlayerInfo[playerid][FirstLog] == 1)
{
ForceClassSelection(playerid);
return 1;
}
}
}
else Kick(playerid);
}
return 0;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "ConnectTime", GetTickCount());
new file[96],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(file,sizeof(file),"/User_Database/%s.ini",pName);
attempt[playerid] = 0;
if(!fexist(file))
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account", "A registration is required to play on this server. \nPlease fill in a password to create a free account!", "Register", "Cancel");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account", "Your accountname is registered! \nPlease fill in your password here:", "Login", "Quit");
}
SpamCount[playerid]=0;
AutoRepairUsed[playerid] = 0;
AdminDuty[playerid] = 0;
AutoRepairTrigger[playerid] = 0;
PlayerInfo[playerid][FirstLog] = 0;
TextDrawShowForPlayer(playerid,WebsiteTextdraw);
return 1;
}
Try this, replace the currents with these...
BTW, the value you currently register with, (GetPlayerMoney, GetPlayerScore) are already 0 if they had just registered, and the same for the admin level, its already 0, so just type 0 for the newly registered ini files... (I already did it, just pointing this out) |