help with login
#1

if they fail times it kicks but if they login successfuly it kicks them why?
pawn Код:
dcmd_login(playerid,params[])
{
    new file[128],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    format(file,sizeof(file),"MyAdmin/Users/%s.ini",n);
    if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
    if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
    if(strlen(params))
    {
        if(dini_Exists(file))
        {
            if(PInfo[playerid][failedlogins] == MAX_FAILLOGINS)
            {
                new pName[MAX_PLAYER_NAME], string[128];
                GetPlayerName(playerid, pName, sizeof(pName));
                format(string,sizeof(string),"KICKED: %s has been kicked [reason: failed logins %d/%d]", pName, PInfo[playerid][failedlogins],MAX_FAILLOGINS);
                SendClientMessageToAll(red,string);
                Kick(playerid);
            }
            else if(strcmp(params,dini_Get(file,"Password"),false) != 0)
            {
                new string[128],pName[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pName,sizeof(pName));
                format(string,sizeof(string), "SERVER: Wrong password [%d/%d]", PInfo[playerid][failedlogins],MAX_FAILLOGINS);
                SendClientMessage(playerid,red,string);
                format(string,sizeof(string), "%s failed login [pass: %s]",pName,params);
                MessageToAdmins(WHITE, string);
                PInfo[playerid][failedlogins]++;
            }
            else
            {
                dini_IntSet(file,"Logged",1);
                PInfo[playerid][Logged] = 1;
                PInfo[playerid][Level] = dini_Int(file,"Level");
                PInfo[playerid][Muted] = dini_Int(file,"Muted");
                PInfo[playerid][Jailed] = dini_Int(file,"Jailed");
                PInfo[playerid][Frozen] = dini_Int(file,"Frozen");
                SetPlayerScore(playerid,dini_Int(file,"Score"));
                GivePlayerMoney(playerid, dini_Int(file, "Money"));
                SendClientMessage(playerid,YELLOW,"SERVER: You are now logged in");
                return 1;
            }
        }
    }
    else
    {
        SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
        return 1;
    }
    return 1;
}
Reply
#2

Add this @ succesfull logged in
Код:
PInfo[playerid][failedlogins] = 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)