SA-MP Forums Archive
error 033: array must be indexed (variable "inputtext") - 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: error 033: array must be indexed (variable "inputtext") (/showthread.php?tid=231128)



error 033: array must be indexed (variable "inputtext") - maramizo - 24.02.2011

Код:
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;



Re: error 033: array must be indexed (variable "inputtext") - (SF)Noobanatior - 25.02.2011

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


Re: error 033: array must be indexed (variable "inputtext") - maramizo - 25.02.2011

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



Re: error 033: array must be indexed (variable "inputtext") - maramizo - 25.02.2011

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.


Re: error 033: array must be indexed (variable "inputtext") - Antonio [G-RP] - 25.02.2011

oh my..

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



Re: error 033: array must be indexed (variable "inputtext") - bigcomfycouch - 25.02.2011

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


Re: error 033: array must be indexed (variable "inputtext") - (SF)Noobanatior - 25.02.2011

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]


Re: error 033: array must be indexed (variable "inputtext") - Antonio [G-RP] - 25.02.2011

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.


Re: error 033: array must be indexed (variable "inputtext") - (SF)Noobanatior - 25.02.2011

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?


Re: error 033: array must be indexed (variable "inputtext") - Hiddos - 25.02.2011

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.