Inputtext must be indexed
#1

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;
}

Reply
#2

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

Can you make an example pls.
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

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

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

What is wrong here?

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

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

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))
Reply
#10

Thanks. Solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)