01.11.2009, 16:51
Код:
public OnPlayerLogin(playerid, Pass[]) { new Name[MAX_PLAYER_NAME], str[128]; GetPlayerName(playerid, Name, sizeof Name); format(str, sizeof str,"/Accounts/%s.txt", Name); new File:account = fopen(str, io_write); 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(AccInfo[playerid][password], value, 0, strlen(value)-1, 128); } if (!strcmp(AccInfo[playerid][password], Pass, true)) { while (fread(account, pass, 256)) { passres = GetFileString(pass); if (strfind(passres, "AdminLevel") != -1) { value = GetFileValue(pass); AccInfo[playerid][AdminLevel] = strval(value); } if (strfind(passres, "Cash") != -1) { value = GetFileValue(pass); AccInfo[playerid][Cash] = strval(value); } fclose(account); AccInfo[playerid][Logged] = 1; } else <== 215 { SendClientMessage(playerid, RED, "Incorrect Password."); fclose(account); return 1; } GivePlayerMoney(playerid, AccInfo[playerid][Cash]); <== 221 format(str, sizeof str, "You have successfully logged in as %s", Name); SendClientMessage(playerid, GREEN, str); printf("%s has logged in", Name); if (AccInfo[playerid][AdminLevel] > 0) { format(str, sizeof str, "You are now logged in as a admin level [%d]", AccInfo[playerid][AdminLevel]); SendClientMessage(playerid, WHITE, str); } } } return 1; }