How to prevent items over a limit from being picked up

I have a hard limit of 10 of every item you can put in your bag, but you can still pick up items, they just will be automatically discarded. How do I instead make the character refuse to pick up the item with a "you have too many" message or something similar?
Control Variables to set a variable to how many of that item you have in inventory (that's under the Other Data option).
Then a Conditional Branch to see if you have less than 10.
If less than 10, pick the item up, Else show the message.
So I set it on each event for picking up an item then.

Considering that would involve a sizable amount of events I'd have to edit, are there any scripts I could use to enforce a hard limit on all items globally?
A script modification could set the limit at 10, but it would not alter the event behaviour (ie - the item would still disappear) because a script cannot assume that you are ONLY picking up the item. You could have other things happening and the script wouldn't know whether you still want to run those other things or not.

Just like, if you leave the limit at 99, and you have an item that can be picked up, the script is not going to stop you from picking up the item - it just won't add it to the inventory.
A script modification could set the limit at 10, but it would not alter the event behaviour (ie - the item would still disappear) because a script cannot assume that you are ONLY picking up the item. You could have other things happening and the script wouldn't know whether you still want to run those other things or not.

Just like, if you leave the limit at 99, and you have an item that can be picked up, the script is not going to stop you from picking up the item - it just won't add it to the inventory.

Yeah, that makes sense.

I guess I'll live with it for now then go back and edit all events later.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-prevent-items-over-a-limit-from-being-picked-up.75060/