Login with Dialog Help.
#1

I'm not the most knowledgeable when it comes to opening/writing files.

But whenever I type the wrong password it still logs me in, here's my OnPlayerLogin script which I used that I took from a tutorial.

pawn Код:
public OnPlayerLogin(playerid,password[])
{
  new string2[128];
    new playername2[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), "ZombieRP/Users/%s.ini", playername2);
    new File: UserFile = fopen(string2, io_read);
    if ( UserFile )
    {
      new PassData[64];
      new keytmp[64], valtmp[64];
      fread( UserFile , PassData , sizeof( PassData ) );
      keytmp = ini_GetKey( PassData );
      if( strcmp( keytmp , "Key" , true ) == 0 )
        {
            valtmp = ini_GetValue( PassData );
            strmid(SInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 128);
        }
        if(strcmp(SInfo[playerid][pKey],password, true ) == 0 )
        {
            new key[64],val[64];
            new Data[64];
            while ( fread( UserFile , Data , sizeof( Data ) ) )
            {
                key = ini_GetKey( Data );
                if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pAdmin] = strval( val ); }
                if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pReg] = strval( val ); }
                if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pCash] = strval( val ); }
                if( strcmp( key , "Banned" , true ) == 0 ) { val = ini_GetValue( Data ); SInfo[playerid][pBan] = strval( val ); }
            }
            fclose(UserFile);
            if(SInfo[playerid][pReg] == 0)
            {
                SInfo[playerid][pReg] = 1;
            }
            if(SInfo[playerid][pBan] == 1)
            {
              SendClientMessage(playerid, grey, "You're banned from this server");
              return 1;
            }
            format(string2, sizeof(string2), "(System): Welcome to our server, %s!",playername2);
            SendClientMessage(playerid, lg,string2);
            printf("%s has logged in.",playername2);
            new stringm[128];
            format(stringm, sizeof(stringm), "%s(%d) has logged into the server.", playername2, playerid);
            SendClientMessageToAll(white, stringm);
            if (SInfo[playerid][pAdmin] > 0)
            {
                format(string2, sizeof(string2), "(System): You have been logged in as a Level %d Administrator.",SInfo[playerid][pAdmin]);
                SendClientMessage(playerid, lg,string2);
                adminusers++;
                AllowPlayerTeleport(playerid, 1);
            }
            else{}
            gPlayerLogged[playerid] = 1;
            //ResetPlayerMoney(playerid);
            //GivePlayerCash(playerid, SInfo[playerid][pCash]);
        }
        else
        {
        fclose(UserFile);
        SendClientMessage(playerid, red, "Wrong Password!");
      Kick(playerid);
        return 1;
        }
    }
    return 1;
}
Reply
#2

Anyone?
Reply
#3

when is OnPlayerLogin called ?
Reply
#4

After my a dialog with an input text.
Reply
#5

yeah, could you show that? password[] is an array here...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)