Код:
public LoginPlayer(playerid, password[])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "%s.ini", 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][aPassword], value, 0, strlen(value)-1, 128);
}
if (!strcmp(AccountInfo[playerid][aPassword], password, true))
{
while (fread(account, pass, 256))
{
passres = GetFileString(pass);
if (strfind(passres, "Cash") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aCash] = strval(value);
}
if (strfind(passres, "Score") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aScore] = strval(value);
}
if (strfind(passres, "X") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aX] = floatstr(value);
}
if (strfind(passres, "Y") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aY] = floatstr(value);
}
if (strfind(passres, "Z") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aZ] = floatstr(value);
}
if (strfind(passres, "Angle") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aA] = floatstr(value);
}
if (strfind(passres, "Newbie") != -1)
{
value = GetFileValue(pass);
AccountInfo[playerid][aNewbie] = floatstr(value);
}
}
fclose(account);
AccountInfo[playerid][aLogged] = 1;
}
else
{
SendClientMessage(playerid, 0xE60000FF, "Incorrect Password.");
fclose(account);
return 1;
}
SpawnPlayer(playerid);
GivePlayerMoney(playerid, AccountInfo[playerid][aCash]);
SetPlayerScore(playerid, AccountInfo[playerid][aScore]);
SetPlayerPos(playerid, AccountInfo[playerid][aX], AccountInfo[playerid][aY], AccountInfo[playerid][aZ]);
SetPlayerFacingAngle(playerid, AccountInfo[playerid][aA]);
AccountInfo[playerid][aNewbie] = AccountInfo[playerid][aNewbie];
SendClientMessage(playerid, 0x21DD00FF, "* Senha aceita, vocк estб logado agora, bom jogo.");
printf("%s has logged in", name);
}
return 1;
}