Quest system with a command block?
Solution 1:
If I understand it correctly, you want to remove the items from the inventory from the player and give him/her other items back. There are multiple ways in which you can achieve this behaviour
First: remove items from the players inventory
The easiest way is to just use the clear
command:
/clear @p
This command removes all items from all slots from the player, including the armor slots and the offhand slot.
or better(Thanks to @Fabian):
/clear @p minecraft:stick 0 10
this command clears up to 10 sticks from a players inventory
If you only want certain slots to be emptied, you can use the replaceitem
command:
/replaceitem entity @p slot.hotbar.0 minecraft:air 1 0
The above command empties the first slot in the hotbar
Now to give players an item, there are two methods as well:
The give
command gives a player an item, as if the player picked the item up from the ground. This makes sure that the item is placed in a slot which is not filled with something else, but if the inventory is full, the item lands on the ground
/give @p minecraft:stick 1 0
The above command gives a player a stick
You can also use the replaceitem
command again like this:
/replaceitem entity @p slot.hotbar.0 minecraft:stick 1 0
This command places 1 stick in the first slot of the hotbar, overwriting any item that was present in this slot before. The benefit here is that a player is guaranteed to have this item in his/her inventory, however, if there is an item already in that specific slot, that item gets lost.
So you see there are multiple methods to achieve what you want, each with pros and cons. Now it's up to you to decide which method fits your needs.
If you want to test for specific items in the players inventory and remove only those, I'll have to disappoint you. There is no way to check if a player has an item unless you want to get crazy with the command blocks and do a check on all inventory slots. If this is some sort of crafting system that you want to make, you should have a look at floor crafting which allows players to throw items on the ground in exchange for new items.
In the upcoming 1.13 update, you can add custom recipes, which could very well suit your needs. Again: I don't quite understand what your question is about, but I think I have covered most possible interpretations.