How to get the next value of a specific item?
#1

Hey all, I'm wanting to have something done for a future project on my server upcoming however I'm kind of lost here.

It's my first time ever doing something like this before, I've attempted once though slightly failed. I don't know where though, all code looks correct, just confusement between ID's happens :S

** Snip

What this code is suppose to do is suposed to find the next valid value to search at. It works perfectly fine though after dropping some items and going back to the menu and clicking a ID it confuses up.

I have been thinking that it would be the listitem value since it changes after a item is deleted.

Example:

ITEM 1
ITEM 2
ITEM 3

If I delete ITEM 2 it'll show like this

ITEM 1
ITEM 3

... So on

If I manage to have at least 5 items and delete the 2nd item then reclick on the first and second item. They get confused.

Basically ITEM 1 becomes ITEM 2 and ITEM 2 becomes itself (ITEM 2)

Very hard to explain though I hope I find someone that understands me :S
After I know this I can start making private parties on my server :3

I offer reputation to the one with the closest answer possible to the solution.
Reply
#2

listitem (dialog response) will not be equal to the id of the your item (in vars) always. So, it might get confused when something is deleted. You need to store the player's results into a variable and then check the selected ID if it's valid. I hope you understand.

listitem 0: player item 1
listitem 1: player item 2
listitem 2: player item 3

now, delete the second one:

listitem 0: player item 1
listitem 1: player item 3

pawn Код:
next_item = listitem;// this will cause trouble because listitem is "1" but item is actually "3" but it will consider ID1 as a valid item.
Reply
#3

Nah, I don't like the style of inputtext, I perfer list items over it.

pawn Код:
for(next_item = listitem; next_item < MAX_ITEMS; next_item++) {
            if(IsValidItem(playerid, next_item)) break;
        }
This code makes the problem, I've never tried before though

@iPLEOMAX

Do you reckon it should be correct if I occupy the first listitem with some note?

@Southclaw

I already have that done. I just want to get the next item slot inside the loop provided.

IsValidItem is meant to direct you to a inventory item.
Reply
#4

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I'm willing to help you with this because I've had similar problems with inventories and dialogs.

1. how does your list creation work? Does it simply loop through the players inventory and inserts the item names into a string to use in ShowPlayerDialog.

2. When you drop an item what happens to that items inventory slot? Is it given some sort of invalid item ID or does all the preceding items shift up the array?

3. What relevance do the list slots in the dialog have to the inventory slots? Does each inventory slot have a menu line with the item name?


I'm being a bit assumptive as to how your system works, sorry! I assume there's an 2 dimension array along the lines of [MAX_PLAYERS][MAX_ITEMS]
To help you I need to know a bit more about how your dialog is created (the list of items etc)
I just threw the listitem plan in the bin. I mean, I didn't want to spend 10 hours to fix a simple thing. For now I'm using the input box for ID's since it's less glitchy and style can be added to the dialog.

Thanks for helping, repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)