[Ajuda] Dialog
#1

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if (response)
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registo",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve uma palavra-passe para te registares.","Registar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_WriteString("Password",inputtext);
                INI_WriteInt("Score",1);
                INI_WriteInt("Cash",5000);
                INI_WriteInt("Admin",0);


                INI_Save();
                INI_Close();
               
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Entrada",""WHITE"Escreve a tua palavra-passe para entrares.","Entrar","Sair");
               
                               
               
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, ""WHITE"Qual й o teu sexo ?",""WHITE"Masculino\nFeminino","Seguinte","Sair");
            }
        }
    }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);

                if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste a palavra-passe errada.\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                SetPlayerScore( playerid, INI_ReadInt("Score" ) );
                ResetPlayerMoney( playerid );
                GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                INI_Close();
                }
            }
        }
    }
        case DIALOG_SEXO:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, "Qual й o teu sexo ?","Masculino\nFeminino","Seguinte","Sair");
            }
            else if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo masculino.");
                        PlayerStat[playerid][pSexo] = 1;
                        SetPlayerSkin(playerid, 50);
                    }
                    case 1:
                    {
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo feminino.");
                        PlayerStat[playerid][pSexo] = 0;
                        SetPlayerSkin(playerid, 191);
                    }
                }
            }
        }
    }
    return 1;
}
Erro na linha:
pawn Код:
case DIALOG_SEXO:

Erros:
pawn Код:
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : warning 217: loose indentation
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : error 014: invalid statement; not in switch
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : warning 215: expression has no effect
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : error 001: expected token: ";", but found ":"
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : error 029: invalid expression, assumed zero
C:\Users\NOOBRE\Desktop\lol\gamemodes\lol-pt.pwn(1325) : fatal error 107: too many error messages on one line
Reply
#2

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if (response)
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registo",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve uma palavra-passe para te registares.","Registar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_WriteString("Password",inputtext);
                INI_WriteInt("Score",1);
                INI_WriteInt("Cash",5000);
                INI_WriteInt("Admin",0);


                INI_Save();
                INI_Close();
               
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Entrada",""WHITE"Escreve a tua palavra-passe para entrares.","Entrar","Sair");
               
                               
               
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, ""WHITE"Qual й o teu sexo ?",""WHITE"Masculino\nFeminino","Seguinte","Sair");
            }
        }
    }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);

                if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste a palavra-passe errada.\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                SetPlayerScore( playerid, INI_ReadInt("Score" ) );
                ResetPlayerMoney( playerid );
                GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                INI_Close();
                }
            }
    }
        case DIALOG_SEXO:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, "Qual й o teu sexo ?","Masculino\nFeminino","Seguinte","Sair");
            }
            else if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo masculino.");
                        PlayerStat[playerid][pSexo] = 1;
                        SetPlayerSkin(playerid, 50);
                    }
                    case 1:
                    {
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo feminino.");
                        PlayerStat[playerid][pSexo] = 0;
                        SetPlayerSkin(playerid, 191);
                    }
                }
          }
    }
    return 1;
}
Tenta aн ^^
Reply
#3

Tenta usar assim:
pawn Код:
case DIALOG_SEXO:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, "Qual й o teu sexo ?","Masculino\nFeminino","Seguinte","Sair");
            }
            case 0:
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo masculino.");
                PlayerStat[playerid][pSexo] = 1;
                SetPlayerSkin(playerid, 50);
            }
            case 1:
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo feminino.");
                PlayerStat[playerid][pSexo] = 0;
                SetPlayerSkin(playerid, 191);
            }
        }
    }
Reply
#4

@.FuneraL. Nгo funcionou :/
@doodem dб erro no "case 0" ,etc.
Reply
#5

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if (response)
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registo",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve uma palavra-passe para te registares.","Registar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_WriteString("Password",inputtext);
                INI_WriteInt("Score",1);
                INI_WriteInt("Cash",5000);
                INI_WriteInt("Admin",0);


                INI_Save();
                INI_Close();
                } //faltou aqui uma chave e outra coisa nгo podes colocar 2 dialogs ao mesmo tempo...                        
               
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, ""WHITE"Qual й o teu sexo ?",""WHITE"Masculino\nFeminino","Seguinte","Sair");
            }
        }
    }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste uma palavra-passe com caracteres invalidos!\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                if(INI_Open(getINI(playerid))) {
                INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);


                if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Entrada",""RED"Introduziste a palavra-passe errada.\n"WHITE"Escreve a tua palavra-passe para te entrares.","Entrar","Sair");
                }

                SetPlayerScore( playerid, INI_ReadInt("Score" ) );
                ResetPlayerMoney( playerid );
                GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                INI_Close();
                }
            }
        }
    }
        case DIALOG_SEXO:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(!strlen(inputtext)) {
                ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, "Qual й o teu sexo ?","Masculino\nFeminino","Seguinte","Sair");
            }
            else if(response)
            {
        if(!strcmp(inputtext,"Masculino",true)){
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo masculino.");
                        PlayerStat[playerid][pSexo] = 1;
                        SetPlayerSkin(playerid, 50);
                }
                else if(!strcmp(inputtext,"Feminino",true)){
                        SendClientMessage(playerid, 0xFFFFFFFF, "Portanto, es do sexo feminino.");
                        PlayerStat[playerid][pSexo] = 0;
                        SetPlayerSkin(playerid, 191);
                }
        else
            ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_INPUT, "Qual й o teu sexo ?","Masculino\nFeminino","Seguinte","Sair");
            }
        }
    }
    return 1;
}
  • Erros
    • Existia uma zona onde nгo tinhas chaveta.
    • No dialog de sexo tu colocaste input em vez de listitem.
    • Troca de listitem para strcmp para verificar as strings
AVISO: Tenta indentar o teu cуdigo assim й um pouco difнcil de entender.
Reply
#6

BlueX , agora deu erro no "Case DIALOG_LOGIN" o:
Originalmente sу havia o dialog do registo e do login mas eu tentei adicionar o do sexo e comeзou a dar imensos erros.
Reply
#7

Quote:
Originally Posted by noobre
Посмотреть сообщение
BlueX , agora deu erro no "Case DIALOG_LOGIN" o:
Originalmente sу havia o dialog do registo e do login mas eu tentei adicionar o do sexo e comeзou a dar imensos erros.
Tente refazer os dialogs novamente, as vezes sгo erros estъpidos, nгo й por falta de incompetкncia, mas as vezes nгo reparamos no que estamos a fazer e depois aparecem erros estъpidos e demoramos 1h a resolver, mas tente refazer os dialogs todos.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)