05.08.2016, 13:26
PHP код:
CMD:login(playerid,params[])
{
if (pInfo[playerid][Logged] == 1) return SendClientMessage(playerid,lighterblue,"You are already logged in");
format(Jstring, 128, ACCOUNTS_PATH, GetName(playerid));
if(!fexist(Jstring))
{
SendClientMessage(playerid,red,"Nick name isn't registered!");
SendClientMessage(playerid,lighterblue,"Please '/register' to create your account");
return 1;
}
format(Jstring, sizeof(Jstring),"Account \"%s\"\nPlease enter the password to login", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Account Access", Jstring, "Login", "Quit");
return 1;
}
PHP код:
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
new Jfile[100],pIP[16],buf[145];
new joinMsg[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(Jfile, 60, ACCOUNTS_PATH, GetName(playerid));
INI_ParseFile(Jfile, "GetPassword", .bExtra = true, .extra = playerid);
WP_Hash(buf, sizeof(buf),inputtext);
if(strcmp(pInfo[playerid][Password], buf, false) == 0)
{
format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));
INI_ParseFile(Jfile, "LoginPlayer", .bExtra = true, .extra = playerid);
SendClientMessage(playerid,green,"You have been succesfully logged In!");
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Cash]);
pInfo[playerid][Logged] = 1;
GetPlayerIp(playerid,pIP,16);
format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));
new INI:ACCOUNT = INI_Open(Jfile);
INI_WriteString(ACCOUNT, "LastLoggedIP", pIP);
INI_Close(ACCOUNT);
#if LoginTextDraw == true
TextDrawHideForPlayer(playerid, TEXT_PASSWORD);
TextDrawHideForPlayer(playerid, TEXT_REGISTER);
TextDrawHideForPlayer(playerid, TEXT_REGISTERED);
CancelSelectTextDraw(playerid);
#endif
format(joinMsg, sizeof(joinMsg), "02[%d] 038,2 %s Has Logged In As Level %d", playerid, name,pInfo[playerid][pLevel]);
IRC_GroupSay(groupID, IRC_CHANNEL, joinMsg);
}
else
{
pInfo[playerid][LoginAttempts]++;
if(pInfo[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS)
{
format(Jstring, sizeof(Jstring),"%s has been automatically kicked | Reason: 'Incorrect password'", GetName(playerid));
SendToAdmins(orange,Jstring);
ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX, "WARRING","You have been automatically kicked | Reason: 'Incorrect password'", "Ok", "");
SetTimerEx("KickPlayer",100,false,"d",playerid);
return 1;
}
format(Jstring, sizeof(Jstring),"Account \"%s\"\nEnter your password to login\n{FF0000}*Incorrect password", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login error",Jstring, "Login", "Quit");
}
}