inputtext seams
#1

when player input what ever he logged in, any inputtext is correct :S

here is code:

pawn Код:
if(dialogid == DIALOG_LOGIN)
    {
        if(!response) Kick(playerid);
        new iStr[128],gTries;
        if(gTries == 3)
        {
            new pName[30];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(iStr,sizeof(iStr),"%s is kicked.",pName);
            SendClientMessageToAll(red,iStr);
            return Kick(playerid);
        }
        if(!strlen(inputtext))
        {
            gTries++;
            format(iStr,sizeof(iStr),"Please input your password. Tries: %i/3",gTries);
            return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Prijava",iStr,"Login","Back");
        }
        if(strcmp(pInfo[playerid][Pass], inputtext, true) == 0)
        {
            pLogged[playerid] = 1;
            LoginAcc(playerid);
        }
        else
        {
            format(iStr,sizeof(iStr),"Wrong password. Tries: %i/3",gTries);
            ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Prijava",iStr,"Login","Back");
            gTries++;
            return 1;
        }
        return 1;
    }
i have no errors but when any player type something as password it logged :S
Reply
#2

Are you sure that pInfo[playerid][Pass] contains any data? If it's an empty array then it will always cause strcmp to return 0. Print the contents of pInfo[playerid][Pass] in that snippet of code and make sure it contains data.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Are you sure that pInfo[playerid][Pass] contains any data? If it's an empty array then it will always cause strcmp to return 0. Print the contents of pInfo[playerid][Pass] in that snippet of code and make sure it contains data.
it seams not

i try to do something and i do that:

pawn Код:
pInfo[playerid][Pass] = inputtext;
and i get error at this line:
pawn Код:
error 006: must be assigned to an array
what is wrong :S
Reply
#4

Are you sure that it's an array? Show me where you enumerate it.
Reply
#5

Here you go:

pawn Код:
enum iDetails
{
    Pass,
    Cash,
    Admin,
    Tut,
    Score
};
new pInfo[MAX_PLAYERS][iDetails];
Reply
#6

There's your problem, how can you expect to store a string which consists of multiple characters in a single cell, it's not going to work! You need to have several cells to store that data, which is what we call an array. For example:

pawn Код:
enum iDetails
{
    Pass[50],
    Cash,
    Admin,
    Tut,
    Score
};
new pInfo[MAX_PLAYERS][iDetails];
Does that make sense?
Reply
#7

yes

but here is another problem -.-

pawn Код:
error 047: array sizes do not match, or destination array is too small
at this line:

pawn Код:
pInfo[playerid][Pass] = inputtext;
Now dosent make sense

edit:

dialog register:

pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
//      GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Pass","Input password:","Register","Back");
        new INI:iFile = INI_Open(PlayerPath(playerid));
        INI_SetTag(iFile,"data");
        INI_WriteString(iFile,"Pasword",inputtext);
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",REGISTERED_MONEY);
        INI_WriteInt(iFile,"Score",1);
        INI_WriteInt(iFile,"Admin",0);
        INI_WriteInt(iFile,"Tut",-1);
        INI_Close(iFile);
        pInfo[playerid][Pass] = inputtext;
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You have reister with password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }
Reply
#8

Yes it does make sense, because inputtext's size is unknown to the compiler, so it cannot assign it to an array that has a pre-set size. You need to use a function like strcat, for example:

pawn Код:
strcat(pInfo[playerid][Pass], inputtext);
This is some fairly basic programming knowledge, I suggest you go through the PAWN manuals over at CompuPhase again assuming you've already read them (why would you be asking for help here if you've not read them? )

Now doesn't that make sense?
Reply
#9

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Yes it does make sense, because inputtext's size is unknown to the compiler, so it cannot assign it to an array that has a pre-set size. You need to use a function like strcat, for example:

pawn Код:
strcat(pInfo[playerid][Pass], inputtext);
This is some fairly basic programming knowledge, I suggest you go through the PAWN manuals over at CompuPhase again assuming you've already read them (why would you be asking for help here if you've not read them? )

Now doesn't that make sense?
now is nice it makes sense now

Ty you for that (reputation +)

Becouse i am to laisy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)