SA-MP Forums Archive
Login with Dialog Help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Login with Dialog Help. (/showthread.php?tid=110447)



Login with Dialog Help. - Giacomand - 26.11.2009

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;
}



Re: Login with Dialog Help. - Giacomand - 26.11.2009

Anyone?


Re: Login with Dialog Help. - ExoSanty - 26.11.2009

when is OnPlayerLogin called ?


Re: Login with Dialog Help. - Giacomand - 27.11.2009

After my a dialog with an input text.


Re: Login with Dialog Help. - ExoSanty - 27.11.2009

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