28.03.2019, 14:56
For adding the slot to the dialog you can just format the number in your existing string (as first value):
I added it before the color code, so it will be a bit darker (color codes are ignored in the response, so you can even color the slot differently if you want to).
For retrieving the ID, you can use sscanf.
So in OnDialogResponse you can do this:
I don't know the size of your inventory so I used MAX_INVENTORY as example. Change that to whatever your limit is.
You should still follow Y_Less' advice if possible. But I can see that it's a lot of work to change an underlying system if you already have a considerable amount of dialogs.
This is, at least in my opinion, still the easiest way of retrieving extra info from a dialog response the old school way. The only downside is that the number is visible in the dialog.
Code:
format(string, sizeof(string), "%d\t{FFFFFF}%s\t%d\n%s", i, GetItemName(i), PlayerItems[playerid][i], string);
For retrieving the ID, you can use sscanf.
So in OnDialogResponse you can do this:
Code:
new slot; if(sscanf(inputtext, "i", slot) || slot < 0 || slot >= MAX_INVENTORY || PlayerItems[playerid][slot] <= 0) { // An invalid slot was passed, so don't continue. You could show the dialog again here. // This can only happen if the data changed while the dialog was shown, or the dialog response was modified by the player. So it's important to verify the data here to avoid an invalid selection or array index out of bounds errors. return 1; } // slot now contains the slot the player selected
You should still follow Y_Less' advice if possible. But I can see that it's a lot of work to change an underlying system if you already have a considerable amount of dialogs.
This is, at least in my opinion, still the easiest way of retrieving extra info from a dialog response the old school way. The only downside is that the number is visible in the dialog.