Possible inputtext bug.
#1

Hello everyone! I have been playing around with dialogs lately and I wanted for some reason to find a substring in the inputtext returned by OnDialogResponse. I am using DIALOG_STYLE_TABLIST_HEADERS so the inputtext should be whatever written on the list item.

Now my list item is something like this "int\tstring\tstring\n" and this is my code:
Код:
format(str, sizeof(str), "%d\t%s\t%s\n", ....
It's in a loop and I'm using strcat but I guess that doesn't really matter.
What I am trying to do now is try to find out using strfind if a substring stored in an array I made actually is in that second %s or not.

So I would have something like this:
Код:
new ItemName[MAX_ITEMS][] =
{
	"Something",
	"Something else",
        "Etc..."
};

// somewhere in OnDialogResponse
for(new i; i < MAX_ITEMS; i++)
{
    if(strfind(inputtext, ItemName[i], true) != -1)
    {
	  ShowItemOption(playerid, i);
	  return 1;
    }
}
So even though that should have worked, it didn't. After debugging it turned out that "1\tstring1\tstring2" that (should?) be returned in inputtext is actually just "1" and everything after that \t is missing. So is that a bug, am I doing anything wrong or that's how it's supposed to work?
Reply
#2

too late for report

it was found 1'st day when 7 released
Reply
#3

I was not aware of that. I don't visit the bugs reporting section a lot.
Reply
#4

Store a global integer, something like;

pawn Код:
new numberofitems;
new ListItemIsItemNo[MAXITEMS];
Now, every time you use strcat (new listitem), add to these;

pawn Код:
numberofitems++;
ListItemIsItemNo[numberofitems-1] = ITEMID; // -1 because the array will be our dialog listitem ID (First listitem is 0 and so on)
OnDialogResponse
pawn Код:
// To retrieve the integer (ID of "ITEM")
new ITEMID = ListItemIsItemNo[listitem];
format(str,sizeof(str),"You selected item %s",ItemName[ITEMID]);
There might be a way better way to do this, but this is what my brains worked out when I needed a way :P
I think It's faster than strfind, well atleast now when It doesn't work for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)