SA-MP Forums Archive
Inputtext must be indexed - 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: Inputtext must be indexed (/showthread.php?tid=101335)



Inputtext must be indexed - Justsmile - 10.10.2009

I get an Error, that inputtext must be indexed, but i don't know how to fix.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    if(dialogid == 1)
    {
      if(strval(inputtext))
      {
        if(strval(inputtext) <= PlayerInfo[playerid][pAccount] || strval(inputtext) >= 1)
        {
            ConsumingMoney[playerid] = 1;
                GetsMoney[playerid] = 1; PlayerMoney[playerid] = PlayerMoney[playerid] += inputtext;
                PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-inputtext;
                format(string, sizeof(string), " You Have Withdrawn $%d from your account Total: $%d ", inputtext,PlayerInfo[playerid][pAccount]);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                new hour, minute, year, month, day;
                getdate(year, month, day);
                gettime(hour, minute);
                format(string, sizeof(string), "Player %s took $%d from his account . Date:(%d-%d-%d)(%d:%d Uhr)", sendername,inputtext ,month,day,year,hour,minute);
                MoneyLog(string);
                return 1;
            }
        }
    }
    return 0;
}




Re: Inputtext must be indexed - Sergei - 10.10.2009

strval? It's strlen to check input's length. And use IsNumeric to check if only numbers are in inputtext.


Re: Inputtext must be indexed - Justsmile - 10.10.2009

Can you make an example pls.


Re: Inputtext must be indexed - Correlli - 10.10.2009

As you can see, inputtext[] is a string. Convert it to integer by using strval function.

Try and change this:
pawn Код:
GetsMoney[playerid] = 1; PlayerMoney[playerid] = PlayerMoney[playerid] += inputtext;
to this:
pawn Код:
GetsMoney[playerid] = 1; PlayerMoney[playerid] = PlayerMoney[playerid] += strval(inputtext);
and this:
pawn Код:
PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-inputtext;
to this:
pawn Код:
PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-strval(inputtext);
and this:
pawn Код:
format(string, sizeof(string), " You Have Withdrawn $%d from your account Total: $%d ", inputtext,PlayerInfo[playerid][pAccount]);
to this:
pawn Код:
format(string, sizeof(string), " You Have Withdrawn $%d from your account Total: $%d ", strval(inputtext),PlayerInfo[playerid][pAccount]);
and this:
pawn Код:
format(string, sizeof(string), "Player %s took $%d from his account . Date:(%d-%d-%d)(%d:%d Uhr)", sendername,inputtext ,month,day,year,hour,minute);
to this:
pawn Код:
format(string, sizeof(string), "Player %s took $%d from his account . Date:(%d-%d-%d)(%d:%d Uhr)", sendername,strval(inputtext) ,month,day,year,hour,minute);
And use strlen to check the length of the string, not strval.


Re: Inputtext must be indexed - Justsmile - 10.10.2009

I've done it like this now:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    if(dialogid == 1)
    {
      if(IsNumeric(strlen(inputtext)))
      {

        if(strlen(inputtext) <= PlayerInfo[playerid][pAccount] || strlen(inputtext) >= 1)
      {
        ConsumingMoney[playerid] = 1;
            GetsMoney[playerid] = 1; PlayerMoney[playerid] = PlayerMoney[playerid] += strval(inputtext);
            PlayerInfo[playerid][pAccount]=PlayerInfo[playerid][pAccount]-strval(inputtext);
            format(string, sizeof(string), " You Have Withdrawn $%d from your account Total: $%d ", strval(inputtext),PlayerInfo[playerid][pAccount]);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new hour, minute, year, month, day;
            getdate(year, month, day);
            gettime(hour, minute);
            format(string, sizeof(string), "Player %s took $%d from his account . Date:(%d-%d-%d)(%d:%d Uhr)", sendername,strval(inputtext) ,month,day,year,hour,minute);
            MoneyLog(string);
            return 1;
        }
        }
    }
    return 0;
}



Re: Inputtext must be indexed - Sergei - 10.10.2009

Tags for pawn code are
because scripting language is named pawn, pwn is just a file extension for its files.


Re: Inputtext must be indexed - Correlli - 10.10.2009

And also, you don't need 256 cells, change it to 128.


Re: Inputtext must be indexed - Justsmile - 10.10.2009

What is wrong here?

pawn Код:
if(IsNumeric(strlen(inputtext)))
To check he types only numbers.

Error:
pawn Код:
error 035: argument type mismatch (argument 1)



Re: Inputtext must be indexed - erorcun - 10.10.2009

Quote:
Originally Posted by #.'
What is wrong here?

pawn Код:
if(IsNumeric(strlen(inputtext)))
To check he types only numbers.

Error:
pawn Код:
error 035: argument type mismatch (argument 1)
Try:
pawn Код:
if(IsNumeric(inputtext))



Re: Inputtext must be indexed - Justsmile - 10.10.2009

Thanks. Solved.