SA-MP Forums Archive
Help with dialog 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)
+--- Thread: Help with dialog inputtext (/showthread.php?tid=515660)



Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

pawn Код:
if(dialogid == admin_security)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                if(inputtext == "anypasshere") // error line
                {
                    SCM(playerid,COLOR_SKYBLUE,"You Have Entered the correct admin password");
                    return 1;
                }
                else
                {
                    SCM(playerid,COLOR_RED,"You Have Entered the Wrong admin password");
                    ShowPlayerDialog(playerid,admin_security,DIALOG_STYLE_INPUT,"Admin Password",""SKYBLUE"Place The Admin Password Here","Admin Login","");
                }
            }
            else
            {
            ShowPlayerDialog(playerid,admin_security,DIALOG_STYLE_INPUT,"Admin Password",""SKYBLUE"Place The Admin Password Here","Admin Login","");
            SCM(playerid,COLOR_RED,"You Have Entered the Wrong admin password");
            }
        }
    }
error
pawn Код:
(7827) : error 033: array must be indexed (variable "inputtext")



Re: Help with dialog inputtext - Riddick94 - 27.05.2014

Inputtext is a string. You can't do a check like on the variable, to compare your inputtext to something use:

https://sampwiki.blast.hk/wiki/Strcmp


Re: Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

can u set it ??


Re: Help with dialog inputtext - Riddick94 - 27.05.2014

Can you read the link I have sent you?


Re: Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

i read it but i don't know how to do it


Re: Help with dialog inputtext - Riddick94 - 27.05.2014

Okey, let me explain that to you like to 6 years old kid.

This is your error 033 line, isn't it? You have also found it:
pawn Код:
if(inputtext == "anypasshere")
Unfortunately, my dear boy you can't check STRING* like you're checking your variables. For example, when you check your normal variable, you're doing check (==) if your variable is the same as something else or some value.

* STRING is a pack of characters, like your message, text or anything else that contains characters. Read more about it in pawn.pdf or any other programming book.

In this case, my dear you have to use STRCMP which stands for STRING COMPARE. Simply, boy you have to use IF statement as you did, but instead of doing double equal sign you have to use strcmp function.

Syntax of STRCMP has been wonderfully described at WIKI page (the link I have sent before). Let's check on that then!



Wait! Doesn't it make sense now, and code just writing itself?
pawn Код:
if(strcmp(what is your first string???, what do you want to compare it to???))



Re: Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

thanks bro now i got it all


Re: Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

sorry but even i enter any other thing it works


Re: Help with dialog inputtext - Konstantinos - 27.05.2014

When the 2 strings are the same, it returns 0*. So:
pawn Код:
if (!strcmp(inputtext, "anypasshere"))
{
    // correct password
}
else
{
    // wrong password
}
* It also returns 0 when a string is null/emtpy so checking if the inputtext's lenght is not 0 would be useful.


Re: Help with dialog inputtext - AroseKhanNiazi - 27.05.2014

thanks and should i return an value on wrong pass too