SA-MP Forums Archive
Dialog Login problems - 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: Dialog Login problems (/showthread.php?tid=223875)



Dialog Login problems - iLcke - 10.02.2011

Well if someone does help, thanks. Lets get back on topic now, anyway, When you connect to the server you'd have to login via a dialog, if you put something in, like asd and password is asq, it won't work, but if you leave the text blank, and just click login, it would log you in? I have no clue on how I could fix this, so thanks if anyone attempts to help me out a bit.


Re: Dialog Login problems - HyperZ - 10.02.2011

Show your Login Code.


Re: Dialog Login problems - iLcke - 10.02.2011

Right.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[256];
new plname[MAX_PLAYER_NAME];
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "users/%s.ini", plname);
OnPlayerLogin(playerid,inputtext);
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You have left the server..");
Kick(playerid);
}
return 1;
}
Thats what im using for them to login.
OnPlayerLogin:
pawn Код:
public OnPlayerLogin(playerid,password[])
{
    new string2[64];
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), "users/%s.ini", playername2);
    new File: file = fopen(string2, io_read);
    if (file)
    {
        new PassData[256];
        new keytmp[256], valtmp[256];
        fread( file , PassData , sizeof( PassData ) );
        keytmp = ini_GetKey( PassData );
        if( strcmp( keytmp , "pPassword" , true ) == 0 )
        {
            valtmp = ini_GetValue( PassData );
            strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
        }
        if(strcmp(PlayerInfo[playerid][pPassword],password, true ) == 0 )
        {
                new key[ 256 ] , val[ 256 ];
                new Data[ 256 ];
                while ( fread( file , Data , sizeof( Data ) ) )
                {
                    key = ini_GetKey( Data );
                    // Bunch of account variables go here.
                    }
                fclose(file);
                gPlayerLogged[playerid] = 1;
                SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
                PlayerInfo[playerid][pHotwire] = 25;
format(string2, sizeof(string2), "SERVER: Welcome %s",playername2);
SendClientMessage(playerid, COLOR_WHITE,string2);
SetTimerEx("SetPlayerWeapons", 1000, false, "i", playerid);
printf("%s has logged in",playername2);
SetSpawnInfo(playerid, 1, PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
if(gTeam[playerid] == 0)
{
gTeam[playerid] = 3;
}
else
{
gTeam[playerid] = PlayerInfo[playerid][pTeam];
}
gPlayerLogged[playerid] = 1;
if(accountplay)
{
gPlayerSpawned[playerid] = 0;
}
if(justreg[playerid] == 1)
{
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "~w~Welcome ~y~%s~n~~w~You may now choose a character", playername2);
DateProp(playerid);
GameTextForPlayer(playerid, string2, 5000, 1);
ResetPlayerMoney(playerid);
PlayerInfo[playerid][pCash] = 5000;
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
return 1;
}
SpawnPlayer(playerid);
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "~w~Welcome ~n~~y~ %s", playername2);
DateProp(playerid);
GameTextForPlayer(playerid, string2, 5000, 1);
return 1;
}

        else
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{FF0000}Wrong password!", "{FFFFFF}The password you typed in doesn't much the account's name.\nType your password in below.", "Login", "Leave");
            fclose(file);
        }
        if(PlayerInfo[playerid][pLevel] == -999) //autoban
        {
            Ban(playerid);
        }
    }
        return 1;
        }