How to trigger a self switch outside of the event?

How do I make a self switch trigger from outside the event? So suppose I wanted self switch A in event001 to be triggered by event002 after talking to them?

I want to do this so that when you come within a specific coordinates you can kill the enemy (that enemy being event001)

Any ideas how I could do this? I don't want to do a specific switch for every event because I'm planning on putting many on one map.

Thanks for the help.
Use this in a script call:
$gameSelfSwitches.setValue([MapID, eventID, 'A'], true/false)

edit: p.s. you can see an example in my sig link below for the "proximity, chase puzzle events" under the chase event spoiler
edit 2: I see you posted this in MV but your use says MZ, but the script will work in either version.
edit 3: fixed the typo Soulrender noted below
Not quite

$gameSelfSwitches.setValue([mapId, eventid, "A"], True)

You must provide valid event id, not event object in argument array.
Oops yes, that's what I meant copied from a note lol
That is brilliant thank you very much. I'm wondering if there's a way to trigger the specific self switch when within a specific coordinate. Any clue on how I may do that?

So if event is in a radius of the event which you can do with co-ordinate X and y then that specific self switch turns on.

Sorry it was my fault for not adding more details to the question.
Yes, here's the basic concept:

Set up a parallel event with a conditional branch (script):
$gamePlayer.x >= $gameMap.event(n).x - 1 && $gamePlayer.y >= $gameMap.event(n).y - 1 && $gamePlayer.x <= $gameMap.event(n).x + 1 && $gamePlayer.y <= $gameMap.event(n).y + 1

Then have that condition run the self switch trigger switch we outlined earlier.

The above example will trigger any time the player is within one square of event(n). You can change the +/- values to increase the range/shape of the trigger, etc.

Make sure to set a wait time of at least 1 with the parallel event to avoid lag.
Something to this effect:
1628724071814.png

edit: fixed a typo in the picture (true/false need to be lowercase)
Yes, here's the basic concept:

Set up a parallel event with a conditional branch (script):
$gamePlayer.x >= $gameMap.event(n).x - 1 && $gamePlayer.y >= $gameMap.event(n).y - 1 && $gamePlayer.x <= $gameMap.event(n).x + 1 && $gamePlayer.y <= $gameMap.event(n).y + 1

Then have that condition run the self switch trigger switch we outlined earlier.

The above example will trigger any time the player is within one square of event(n). You can change the +/- values to increase the range/shape of the trigger, etc.

Make sure to set a wait time of at least 1 with the parallel event to avoid lag.
Something to this effect:
View attachment 198406
edit: fixed a typo in the picture (true/false need to be lowercase)

You are truly a legend! Thank you, this is perfect!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-trigger-a-self-switch-outside-of-the-event.139460/