if(dialogid == 2) { if(response) { new string[128]; if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in."); new plname[MAX_PLAYER_NAME]; GetPlayerName(playerid, plname, sizeof(plname)); format(string, sizeof(string), "/sAccounts/%s.seifadmin", plname); if(!fexist(string)) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register your account.", "Please input the password you want to register with", "Register", "Cancel"); return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]"); } if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel"); OnPlayerLogin(playerid,inputtext); } } return 0; }
Originally Posted by XxCozzaxX
yeah, good idea... use strcmp for a dialog...
|
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
Originally Posted by ♣ Joker ♠
Quote:
pawn Код:
So I dont see the problem |
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0) { OnPlayerLogin(playerid,inputtext); } else { SendClientMessage(playerid, RED, "Incorrect Password."); ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel"); return 1;
public OnPlayerLogin(playerid, password[])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
new File:account = fopen(str, io_read);
if (account)
{
new pass[256];
new passres[128], value[128];
fread(account, pass, sizeof pass);
passres = GetFileString(pass);
if (!strcmp("Password", passres))
{
value = GetFileValue(pass);
strmid(AccountInfo[playerid][Password], value, 0, strlen(value)-1, 128);
}
if (!strcmp(AccountInfo[playerid][Password], password, true))
{
while (fread(account, pass, 256))
{
passres = GetFileString(pass);
if (strfind(passres, "AdminLevel") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][AdminLevel] = strval(value);
}
if (strfind(passres, "Cash") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][Cash] = strval(value);
}
if (strfind(passres, "Warnings") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][Warns] = strval(value);
}
if (strfind(passres, "WarnReason1") != -1)
{
value = GetFileValue(pass);
strmid(AccountInfo[playerid][WarnReason1], value, 0, strlen(value)-1, 128);
}
if (strfind(passres, "WarnReason2") != -1)
{
value = GetFileValue(pass);
strmid(AccountInfo[playerid][WarnReason2], value, 0, strlen(value)-1, 128);
}
if (strfind(passres, "WarnReason3") != -1)
{
value = GetFileValue(pass);
strmid(AccountInfo[playerid][WarnReason3], value, 0, strlen(value)-1, 128);
}
}
fclose(account);
AccountInfo[playerid][Logged] = 1;
}
else
{
SendClientMessage(playerid, RED, "Incorrect Password.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
fclose(account);
return 1;
}
GivePlayerMoney(playerid, AccountInfo[playerid][Cash]);
format(str, sizeof str, "|- You have successfully logged in as %s -|", name);
SendClientMessage(playerid, GREEN, str);
printf("%s has logged in", name);
if (AccountInfo[playerid][AdminLevel] > 0)
{
format(str, sizeof str, "|» You are now logged in as a level %d admin «|", AccountInfo[playerid][AdminLevel]);
SendClientMessage(playerid, LIGHTGREEN, str);
ViewCmds[playerid] = 0;
}
}
return 1;
}
if(dialogid == 2)
{
if(response) {
new string[128];
if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "/sAccounts/%s.seifadmin", plname);
if(!fexist(string))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register your account.", "Please input the password you want to register with", "Register", "Cancel");
return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
}
if(fexist(string))
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
{
OnPlayerLogin(playerid,inputtext);
}
else
{
SendClientMessage(playerid, RED, "Incorrect Password.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
return 1;
}
}
}
}
return 0;
}