"That person can't use that item here!"

I have a dungeon with some unique rules regarding certain items.

I'm looking for a way to run a conditional branch that basically does the following:
If Actor " x" uses Item "y" while Switch "z" is ON: that item cannot be used.

"Potions" can normally be used both in and out of battle whenever you please.
But things are different in "Cave of Shadows".

So if "Carlos" uses a "Potion" in "Cave of Shadows" - "Carlos cannot use that item here!"

This rule applies only to said character however. "Pierre" can still use "Potions" normally.

I have a Switch set up for when the player enters the "Cave of Shadows".
I have an item common event that runs if said switch is on, but as of now it is blank as I can't seem to figure out how to event it properly.

I have a history of overthinking things regarding RPG Maker and this is probably another instance of that, but if anyone can help
I would as always appreciate it.
1) your common event needs to always run and check, and only allow the effect to happen if all conditions are true.
so attach the common event to the item and have it do the rest automatically.

2) to determine who used the item, have the item add an invisible state (no icon, no text) to the actor using it.
Then have the common event check which actor has the state and react accordingly, don't forget to remove the state after it has been checked by the common event.

it's a bit tedious doing it that way because you'll need one complete conditional branch for every actor, but it is also the most stable way with less possible problems if you are careful with your work.

Original thread: https://forums.rpgmakerweb.com/threads/that-person-cant-use-that-item-here.114680/