12.09.2009, 06:56
Maybe try going the way around it, you said after 2 wrong passwords it doesn't let you log-in anymore?
Then try make some sort of protection like this, it checks how much times he failed to log-in, then kicks him after next try.
Add this on top
If you don't really like how it is made, maybe try this one, Untested.
What i did is just removed the string thing and added the dini_get in the login check, since your kinda using it once here.
Maybe it is all about speed, so try it with this one if you don't like the one i did above.
If all of this doesn't work, try follow and take some stuff from Boogeyman's tutorial
http://forum.sa-mp.com/index.php?topic=69810.0
Then try make some sort of protection like this, it checks how much times he failed to log-in, then kicks him after next try.
Add this on top
pawn Код:
new PWFails[MAX_PLAYERS];
pawn Код:
public OnPlayerLogin(playerid, password[])
{
new name[MAX_PLAYER_NAME], str[128], string[MAX_STRING];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/CoDS/Accounts/%s.account", name);
string = dini_Get(str, "Password");
if(strcmp(string, password, false))
{
if (PWFails[playerid] < 2)
{
PWFails[playerid]++;
SendClientMessage(playerid, COLOR_RED, "Incorrect Password.");
}
if (PWFails[playerid] == 2)
{
Kick(playerid);
}
return 1;
}
AccountInfo[playerid][AdminLevel] = dini_Int(str, "AdminLevel");
AccountInfo[playerid][MWeap1] = dini_Int(str, "MeleeWeap1");
AccountInfo[playerid][PWeap1] = dini_Int(str, "PrimaryWeap1");
AccountInfo[playerid][SWeap1] = dini_Int(str, "SecondaryWeap1");
AccountInfo[playerid][SPWeap1] = dini_Int(str, "SpecialWeap1");
AccountInfo[playerid][MWeap2] = dini_Int(str, "MeleeWeap2");
AccountInfo[playerid][PWeap2] = dini_Int(str, "PrimaryWeap2");
AccountInfo[playerid][SWeap2] = dini_Int(str, "SecondaryWeap2");
AccountInfo[playerid][SPWeap2] = dini_Int(str, "SpecialWeap2");
AccountInfo[playerid][Rank] = dini_Int(str, "Rank");
AccountInfo[playerid][Kills] = dini_Int(str, "Kills");
AccountInfo[playerid][Deaths] = dini_Int(str, "Deaths");
AccountInfo[playerid][RoundsWon] = dini_Int(str, "RoundsWon");
SetPlayerScore(playerid, AccountInfo[playerid][RoundsWon]);
SpawnPlayer(playerid);
printf("%s has logged in", name);
AccountInfo[playerid][Logged] = 1;
if (AccountInfo[playerid][AdminLevel] > 0)
{
format(str, sizeof str, "You have successfully logged in as %s [Admin level %d]", name, AccountInfo[playerid][AdminLevel]);
SendClientMessage(playerid, COLOR_YELLOW, str);
}
else
{
format(str, sizeof str, "You have successfully logged in as %s", name);
SendClientMessage(playerid, COLOR_YELLOW, str);
}
return 1;
}
pawn Код:
public OnPlayerLogin(playerid, password[])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/CoDS/Accounts/%s.account", name);
if(strcmp(dini_Get(str, "Password"), password, false))
{
SendClientMessage(playerid, COLOR_RED, "Incorrect Password.");
return 1;
}
AccountInfo[playerid][AdminLevel] = dini_Int(str, "AdminLevel");
AccountInfo[playerid][MWeap1] = dini_Int(str, "MeleeWeap1");
AccountInfo[playerid][PWeap1] = dini_Int(str, "PrimaryWeap1");
AccountInfo[playerid][SWeap1] = dini_Int(str, "SecondaryWeap1");
AccountInfo[playerid][SPWeap1] = dini_Int(str, "SpecialWeap1");
AccountInfo[playerid][MWeap2] = dini_Int(str, "MeleeWeap2");
AccountInfo[playerid][PWeap2] = dini_Int(str, "PrimaryWeap2");
AccountInfo[playerid][SWeap2] = dini_Int(str, "SecondaryWeap2");
AccountInfo[playerid][SPWeap2] = dini_Int(str, "SpecialWeap2");
AccountInfo[playerid][Rank] = dini_Int(str, "Rank");
AccountInfo[playerid][Kills] = dini_Int(str, "Kills");
AccountInfo[playerid][Deaths] = dini_Int(str, "Deaths");
AccountInfo[playerid][RoundsWon] = dini_Int(str, "RoundsWon");
SetPlayerScore(playerid, AccountInfo[playerid][RoundsWon]);
SpawnPlayer(playerid);
printf("%s has logged in", name);
AccountInfo[playerid][Logged] = 1;
if (AccountInfo[playerid][AdminLevel] > 0)
{
format(str, sizeof str, "You have successfully logged in as %s [Admin level %d]", name, AccountInfo[playerid][AdminLevel]);
SendClientMessage(playerid, COLOR_YELLOW, str);
}
else
{
format(str, sizeof str, "You have successfully logged in as %s", name);
SendClientMessage(playerid, COLOR_YELLOW, str);
}
return 1;
}
Maybe it is all about speed, so try it with this one if you don't like the one i did above.
If all of this doesn't work, try follow and take some stuff from Boogeyman's tutorial
http://forum.sa-mp.com/index.php?topic=69810.0

