error 033: array must be indexed (variable "inputtext")
#1

Код:
error 033: array must be indexed (variable "inputtext")
pawn Код:
if(dialogid == 2)
    {
        if(!response)
        {
            SendClientMessage(playerid, 0xFF0000, "You have to login to play on this server!");
            Kick(playerid);
        }
        else
        {
            new file[128], inpw;
            format(file, sizeof(file), "\\Users\\%s.ini", pName(playerid));
            inpw = dini_Int(file, "password");
            if(inputtext != inpw && countpw < 4) // <-------------------- Line with error.
            {
                new countpw = 0;
                new stringc[128];
                format(stringc,sizeof(stringc),"You have entered the wrong password for %s, you have %i tries left.", pName(playerid), countpw);
                SendClientMessage(playerid, 0xB20000, stringc);
                ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Kick");
                countpw++;
                return 1;
            }
            else if(inputtext != inpw && countpw > 3)
            {
                new stringc[128];
                format(stringc,sizeof(stringc),
                SendClientMessage(playerid, 0xFF0000, "You have been kicked for entering a wrong password for %s three times.", pName(playerid));
                Kick(playerid);
                return 1;
            }
            else
            {
                SetPlayerScore(playerid, dini_Int(file, "score"));
                GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
                SendClientMessage(playerid, 0xFFFF00, "You have successfully logged in!");
                return 1;
            }
        }
        return 1;
    }
    return 0;
Reply
#2

cant compare a string like that
pawn Код:
if(strcmp(inputtext, inpw, true, 10)&& countpw < 4)
like that
Reply
#3

I tried that.
Код:
error 035: argument type mismatch (argument 2)
Reply
#4

Lmao alright I think I fixed it, I changed
pawn Код:
if(inputtext != inpw && countpw < 4)
to
pawn Код:
if(inputtext[playerid] != inpw && countpw < 4)
I'll just test it in game.
Reply
#5

oh my..

pawn Код:
if(strcmp(inputtext,inpw, true) == 0 && countpw < 4)
Reply
#6

You appear to be trying to load a string as an integer, thus the argument type mismatch when attempting to use strcmp.
Reply
#7

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
oh my..

pawn Код:
if(strcmp(inputtext,inpw, true) == 0 && countpw < 4)
it should be if the strings dont match so like this

pawn Код:
if(strcmp(inputtext,inpw, true) != 0 && countpw < 4)
[/QUOTE]
Reply
#8

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
it should be if the strings dont match so like this

pawn Код:
if(strcmp(inputtext,inpw, true) != 0 && countpw < 4)
[/QUOTE]

Ah, yes. I wasn't paying attention, thanks.
Reply
#9

ok so you have inow as a intger getting read frome the file and inputtext as a string you cant compare theres is the password only numbers or is that hash value? if so what is your hash method?
Reply
#10

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
ok so you have inow as a intger getting read frome the file and inputtext as a string you cant compare theres is the password only numbers or is that hash value? if so what is your hash method?
Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
You appear to be trying to load a string as an integer, thus the argument type mismatch when attempting to use strcmp.
The posts I quoted are basically the only two useful posts so far.

Your 'Password' is most likely to be a string, but you're loading it as an integer:
pawn Код:
inpw = dini_Int(file, "password");
Now I don't know a damn about dini (Nor would I like to know about it ), but first you should make 'inpw' a string and not an integer:
pawn Код:
new inpw[128];
Secondly you should load the password the way you should (dini_Get?):
pawn Код:
inpw = dini_Get(file, "password");
Now to compare it with another string, you must use strcmp. This function returns zero when succesful, so:
pawn Код:
if(!strcmp(inputtext, inpw) && countpw < 4)
Good luck, if you got any questions please post 'm here again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)