[DUV]~~> Login Box <~~
#1

Opa!

Ow Gente seguinte, com certeza eu sei que existe muita gente aqui que nгo sabe adaptar um Login Box

Entгo eu tбbem tenho essa dъvida entгo preciso da ajuda de vocкs(Pawn Masters).

Bom eu tenho o bбsico sу nгo sei adaptar os callbacks:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (response == 1)
    {
        if(dialogid == 12345)
        {
            if(strlen(inputtext))
            {
                Encrypt(inputtext);
                new player[MAX_PLAYER_NAME];
                GetPlayerName(playerid, player, 50);
                new string3[32];
                new playername3[MAX_PLAYER_NAME];
                GetPlayerName(playerid, playername3, sizeof(playername3));
                format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
                new ip[20];
                GetPlayerIp(playerid,ip,sizeof(ip));
                new File: hFile = fopen(string3, io_write);
                if (hFile)
                {
                    strmid(AccountInfo[playerid][aPassword], inputtext, 0, strlen(inputtext), 255);
                    new var[128];
                    format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
                    format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
                    fclose(hFile);
                    printf("%s is signed up.",playername3);
                    SendClientMessage(playerid, GREEN, "|- Have you registered. You can login now. -|");
                    new girismsg[256];
                    format(girismsg,256,"Welcome to the server\n\nUser Name: %s\n\nEnter your password:",playername3);
                    ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
                    register[playerid] = 0;
                    login[playerid] = 1;
                }
            }
            else if(!strlen(inputtext))
            {
                new name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                new kayitmsg[256];
                format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
                ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
                register[playerid] = 1;
                login[playerid] = 0;
            }
        }
        if(dialogid == 12346)
        {
            Encrypt(inputtext);
            new string2[128];
            new playername2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername2, sizeof(playername2));
            format(string2, sizeof(string2), ACCOUNTS_FOLDER, playername2);
            new File: UserFile = fopen(string2, io_read);
            if ( UserFile )
            {
                new PassData[256];
                new keytmp[256], valtmp[256];
                fread( UserFile , PassData , sizeof( PassData ) );
                keytmp = ini_GetKey( PassData );
                if( strcmp( keytmp , "Password" , true ) == 0 )
                {
                    valtmp = ini_GetValue( PassData );
                    strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
                }
                if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
                {
        				  if(strlen(inputtext))
				  				{
                    for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
                    {
                        inputtext[p] = '?';
                    }
                    SetTimerEx("LogIn", LOGIN_DELAY*1000, 0, "d", playerid);
                    printf("%s is logged in.",playername2);
                    new key[256] , val[256];
                    new Data[256];
                    while ( fread( UserFile , Data , sizeof( Data ) ) )

                    {
                        key = ini_GetKey( Data );
                        /*if(strcmp(key, "AdminLevel", true) == 0) // This is only an example if you want to add more stuff to store in a file.

                        {
                            val = ini_GetValue( Data );
                            AccountInfo[playerid][AdminLevel] = strval(val); // Uncommenting this will give you errors if the variable isn't defined.

                        }
                        */

                    }
                    fclose(UserFile);
									}
                }
 				else
				{
					if(strlen(inputtext))
					{
						new girismsg[256];
						printf("%s is used the wrong password.",playername2);
						format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
						ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
						login[playerid] = 1;
						register[playerid] = 0;
						fclose(UserFile);
						return 1;
					}
				}
				if(!strlen(inputtext))
				{
					new girismsg[256];
					printf("%s did not enter the password.",playername2);
					format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
					ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
					login[playerid] = 1;
					register[playerid] = 0;
					fclose(UserFile);
					return 1;
				}
            }
        }
        if(dialogid == 12347)
        {
            Encrypt(inputtext);
            new string2[128];
            new playername2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername2, sizeof(playername2));
            format(string2, sizeof(string2), ACCOUNTS_FOLDER, playername2);
            new File: UserFile = fopen(string2, io_read);
            if ( UserFile )
            {
                new PassData[256];
                new keytmp[256], valtmp[256];
                fread( UserFile , PassData , sizeof( PassData ) );
                keytmp = ini_GetKey( PassData );
                if( strcmp( keytmp , "Password" , true ) == 0 )
                {
                    valtmp = ini_GetValue( PassData );
                    strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
                }
                if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
                {
        				  if(strlen(inputtext))
				  				{
                    for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
                    {
                        inputtext[p] = '?';
                    }
                    SetTimerEx("LogIn", LOGIN_DELAY*1000, 0, "d", playerid);
                    printf("%s is logged in.",playername2);
                    new key[256] , val[256];
                    new Data[256];
                    while ( fread( UserFile , Data , sizeof( Data ) ) )

                    {
                        key = ini_GetKey( Data );
                        /*if(strcmp(key, "AdminLevel", true) == 0) // This is only an example if you want to add more stuff to store in a file.

                        {
                            val = ini_GetValue( Data );
                            AccountInfo[playerid][AdminLevel] = strval(val); // Uncommenting this will give you errors if the variable isn't defined.

                        }
                        */

                    }
                    fclose(UserFile);
									}
                }
 				else
				{
					if(strlen(inputtext))
					{
						new girismsg[256];
						printf("%s is used the wrong password.",playername2);
						format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
						ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
						login[playerid] = 1;
						register[playerid] = 0;
						fclose(UserFile);
						return 1;
					}
				}
				if(!strlen(inputtext))
				{
					new girismsg[256];
					printf("%s did not enter the password.",playername2);
					format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
					ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
					login[playerid] = 1;
					register[playerid] = 0;
					fclose(UserFile);
					return 1;
				}
            }

        }
    }
    else return Kick(playerid);
    return 0;
[font=calibri]Alguem fizer que com ele(script) ficasse um pouco mais simples pra min adaptar eu ficaria grato, entгo й isso vlw!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)