Identify actor who used item

Hi there! I have a simple common event for a food item which may or may not be poisoned. The common event uses a random number generator and then gives stats or hp depending on the number generated. The problem is, the common event needs me to specify the actor and I don't know how to make the system gather that information. A simple variable with the id of the actor who used the item would work perfectly but I can't figure out the script or where to put said script. Thank you in advance!
You can use the script call that will return the Id of the actor that you use the item.

JavaScript:
$gameParty._targetActorId

Sou you can put in a conditional branch:
If $gameParty._targetActorId === ID
// do stuff

replace ID with the actor ID you want to check 🙂
But there's no place in the item setup to run a script call. If I run the script call in the common event, will it still recognize who the item user was?
@Xina to run a script call in the scene item, only through the code.

f I run the script call in the common event, will it still recognize who the item user was?
Yes, it will recognize. After you use the item and leave the menu, the code still will return the actor id in the scene map.
Got it!! Thank you so much!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/identify-actor-who-used-item.120605/